@sapienx/agentos 0.5.7 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/agentos.js +113 -2
- package/bin/terminal-boot.js +383 -76
- package/bundle/.next/BUILD_ID +1 -1
- package/bundle/.next/app-path-routes-manifest.json +9 -8
- package/bundle/.next/build-manifest.json +3 -3
- package/bundle/.next/prerender-manifest.json +3 -3
- package/bundle/.next/react-loadable-manifest.json +2 -2
- package/bundle/.next/required-server-files.json +1 -1
- package/bundle/.next/routes-manifest.json +6 -0
- package/bundle/.next/server/app/_global-error/page.js +2 -2
- package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_global-error.html +1 -1
- package/bundle/.next/server/app/_global-error.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found/page.js +2 -2
- package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_not-found.html +1 -1
- package/bundle/.next/server/app/_not-found.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/bundle/.next/server/app/agents/page.js +2 -2
- package/bundle/.next/server/app/agents/page.js.nft.json +1 -1
- package/bundle/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js +4 -4
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/agents/route.js +1 -1
- package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/files/reveal/route.js +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/integrations/[integrationId]/status/route.js +1 -1
- package/bundle/.next/server/app/api/mission/route.js +1 -1
- package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/catalog/route.js +2 -2
- package/bundle/.next/server/app/api/models/catalog/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/providers/route.js +2 -2
- package/bundle/.next/server/app/api/models/providers/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/models/route.js +3 -3
- package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/route.js +2 -2
- package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/openclaw/capabilities/route.js +1 -1
- package/bundle/.next/server/app/api/openclaw/compatibility-smoke/route.js +1 -0
- package/bundle/.next/server/app/api/openclaw/compatibility-smoke/route.js.nft.json +1 -0
- package/bundle/.next/server/app/api/openclaw/compatibility-smoke/route_client-reference-manifest.js +1 -0
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js +2 -2
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/route.js +1 -1
- package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/reset/route.js +2 -2
- package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js +1 -1
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/workspace-root/route.js +1 -1
- package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/stream/route.js +2 -2
- package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/system/open-terminal/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/control/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/control/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js +2 -2
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/update/route.js +2 -2
- package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/route.js +2 -2
- package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/bundle/.next/server/app/files/page.js +2 -2
- package/bundle/.next/server/app/files/page.js.nft.json +1 -1
- package/bundle/.next/server/app/files/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/integrations/page.js +2 -2
- package/bundle/.next/server/app/integrations/page.js.nft.json +1 -1
- package/bundle/.next/server/app/integrations/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/models/page.js +2 -2
- package/bundle/.next/server/app/models/page.js.nft.json +1 -1
- package/bundle/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/page.js +2 -2
- package/bundle/.next/server/app/page.js.nft.json +1 -1
- package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/settings/page.js +2 -2
- package/bundle/.next/server/app/settings/page.js.nft.json +1 -1
- package/bundle/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/tasks/page.js +2 -2
- package/bundle/.next/server/app/tasks/page.js.nft.json +1 -1
- package/bundle/.next/server/app/tasks/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app-paths-manifest.json +9 -8
- package/bundle/.next/server/chunks/1718.js +4 -0
- package/bundle/.next/server/chunks/4391.js +45 -35
- package/bundle/.next/server/chunks/4767.js +1 -4
- package/bundle/.next/server/chunks/5151.js +14 -4
- package/bundle/.next/server/chunks/6476.js +2 -2
- package/bundle/.next/server/chunks/8849.js +1 -1
- package/bundle/.next/server/functions-config-manifest.json +1 -0
- package/bundle/.next/server/middleware-build-manifest.js +1 -1
- package/bundle/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/bundle/.next/server/pages/404.html +1 -1
- package/bundle/.next/server/pages/500.html +1 -1
- package/bundle/.next/server/server-reference-manifest.json +1 -1
- package/bundle/.next/static/C5KQaZvAavAtZzYvH3CPw/_buildManifest.js +1 -0
- package/bundle/.next/static/chunks/2396-395f5ed99e66819d.js +1 -0
- package/bundle/.next/static/chunks/7197.2385ee563e32813a.js +1 -0
- package/bundle/.next/static/chunks/7442-b2286cbca8c413fd.js +198 -0
- package/bundle/.next/static/chunks/app/_global-error/{page-73422dc4075cbfe0.js → page-8443c62570b9a078.js} +1 -1
- package/bundle/.next/static/chunks/app/_not-found/{page-73422dc4075cbfe0.js → page-8443c62570b9a078.js} +1 -1
- package/bundle/.next/static/chunks/app/api/agents/[agentId]/chat/{route-73422dc4075cbfe0.js → route-8443c62570b9a078.js} +1 -1
- package/bundle/.next/static/chunks/app/api/agents/{route-73422dc4075cbfe0.js → route-8443c62570b9a078.js} +1 -1
- package/bundle/.next/static/chunks/app/api/diagnostics/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/files/reveal/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/gateway/control/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/integrations/[integrationId]/status/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/mission/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/models/catalog/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/models/providers/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/onboarding/models/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/onboarding/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/openclaw/compatibility-smoke/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/reset/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/gateway/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/openclaw-binary/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/snapshot/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/stream/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/system/open-terminal/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/control/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/update/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/files/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/surfaces/discovery/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/route-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/app/not-found-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-8443c62570b9a078.js +1 -0
- package/bundle/.next/static/chunks/{webpack-1e021d6850c9ac01.js → webpack-13c3a46c1cdfa6e4.js} +1 -1
- package/bundle/.next/static/css/288b13e5308447b9.css +3 -0
- package/bundle/server.js +1 -1
- package/package.json +1 -1
- package/bundle/.next/static/JJw_UWORQdbCo0tnqFq68/_buildManifest.js +0 -1
- package/bundle/.next/static/chunks/1994.2c1ce6369c0b31aa.js +0 -1
- package/bundle/.next/static/chunks/2396-3a9544c281c618dd.js +0 -1
- package/bundle/.next/static/chunks/7442-0da619eb6902ba5b.js +0 -188
- package/bundle/.next/static/chunks/app/api/diagnostics/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/files/reveal/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/gateway/control/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/integrations/[integrationId]/status/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/mission/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/models/catalog/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/models/providers/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/onboarding/models/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/onboarding/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/reset/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/settings/gateway/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/settings/openclaw-binary/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/snapshot/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/stream/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/system/open-terminal/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/control/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/update/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/files/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/surfaces/discovery/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/route-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/app/not-found-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-73422dc4075cbfe0.js +0 -1
- package/bundle/.next/static/css/6de56db1be7d3d06.css +0 -3
- /package/bundle/.next/static/{JJw_UWORQdbCo0tnqFq68 → C5KQaZvAavAtZzYvH3CPw}/_ssgManifest.js +0 -0
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7442],{18027:(e,t,a)=>{"use strict";a.d(t,{j:()=>n});var s=a(70430);let r=[];function n(e,t,a={}){let[i,l]=(0,s.useState)({taskId:null,feed:[],detail:null}),[o,c]=(0,s.useState)(null),[d,p]=(0,s.useState)({taskId:null,message:null}),u="string"==typeof a.dispatchId&&a.dispatchId.trim()?a.dispatchId.trim():null,m=e.startsWith("optimistic-task:"),h=t&&m&&!u?a.optimisticFeed??r:null;(0,s.useEffect)(()=>{if(!t||h)return;let a=new URLSearchParams;u&&a.set("dispatchId",u);let s=new EventSource(`/api/tasks/${encodeURIComponent(e)}/stream${a.size>0?`?${a.toString()}`:""}`),r=t=>{try{let a=JSON.parse(t.data);"task"===a.type&&(l({taskId:e,feed:a.detail.liveFeed||[],detail:a.detail}),c(e),p({taskId:e,message:null}))}catch(t){console.error("Failed to parse task stream event",t),p({taskId:e,message:"Unable to parse task feed."})}},n=t=>{try{let a=JSON.parse(t.data);p({taskId:e,message:a.error||"Unknown error"})}catch{p({taskId:e,message:"Stream error"})}};return s.addEventListener("task",r),s.addEventListener("task-error",n),s.onerror=()=>{p(t=>t.taskId===e&&t.message?t:{taskId:e,message:"Task feed disconnected. Reconnecting…"})},()=>{s.close(),s.removeEventListener("task",r),s.removeEventListener("task-error",n)}},[e,t,u,h]);let x=h??(i.taskId===e?i.feed:[]),g=h?null:i.taskId===e?i.detail:null,b=h?null:d.taskId===e?d.message:null;return{feed:x,detail:g,loading:!h&&t&&o!==e&&null===b,error:b}}},18112:(e,t,a)=>{"use strict";a.d(t,{MissionControlShell:()=>nf});var s=a(36366),r=a(50576),n=a(15411),i=a(70430),l=a(50592),o=a(74213),c=a(47697),d=a(62071),p=a(41880),u=a(95433),m=a(44816),h=a(87408),x=a(87618),g=a(79613),b=a(67882),f=a(6658),w=a(75544),v=a(8120),y=a(19306),j=a(50243),k=a(82711),N=a(23351);let C="mission-control-recent-prompts";function S({snapshot:e,surfaceTheme:t,activeWorkspaceId:a,selectedNodeId:r,composeIntent:n,isComposerActive:l,onTargetAgentChange:o,onTargetAgentSelect:c,onComposerActiveChange:g,onRefresh:O,onOpenWorkspaceCreate:P,onOpenWorkspaceChannels:_,onMissionDispatchStart:D,onMissionDispatchFailure:E,onMissionResponse:L,onAgentCreatedVisible:U}){let F,z,[W,B]=(0,i.useState)(""),[G,q]=(0,i.useState)(""),[V,K]=(0,i.useState)("medium"),[J,H]=(0,i.useState)(!1),[Y,Z]=(0,i.useState)(!1),[Q,X]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[ea,es]=(0,i.useState)(!1),[er,en]=(0,i.useState)(!1),[ei,el]=(0,i.useState)(!1),[eo,ec]=(0,i.useState)(null),ed=(0,i.useRef)(null),ep=(0,i.useRef)(null),eu=(0,i.useRef)(null),em=(0,i.useRef)(null),eh=(0,i.useRef)(!1),ex=(0,i.useRef)(null),eg=e.workspaces.find(e=>e.id===a)??e.workspaces[0],eb=e.agents.filter(e=>!eg||e.workspaceId===eg.id),ef=eb.find(e=>e.id===G)??eb[0]??null,ew=ef?(0,k.CK)(ef):null,ev=ef?.id??null,ey=eb.map(e=>({label:(0,k.CK)(e),value:e.id})),ej=R(eg?.id??a??null,ev),ek=!!(W.trim()&&ev&&!J),eN=ew?`Compose for ${ew}...`:"Compose a mission...",eC=((F=[]).push({id:"workspace-create",label:"Create workspace",action:"open-workspace-create"}),z=new Set,F.filter(e=>{let t=`${e.action||"mission"}:${e.mission?.trim().toLowerCase()||e.label.toLowerCase()}`;return!z.has(t)&&(z.add(t),!0)}).slice(0,3)),eS=eC.length>0,eA=!l&&!Q&&0===W.trim().length&&null===eo,eT=ee&&(!ea||J)&&eA,e$=er&&eA||eT||!ee&&!ea&&eA;(0,i.useEffect)(()=>{let t=`${a??"all"}:${r??"none"}:${eb.map(e=>e.id).join(",")}`,s=function(e,t,a){let s=e.agents.find(e=>e.id===a);if(s)return s.id;let r=e.tasks.find(e=>e.id===a);if(r?.primaryAgentId)return r.primaryAgentId;let n=e.runtimes.find(e=>e.id===a);if(n?.agentId)return n.agentId;let i=e.agents.filter(e=>t?e.workspaceId===t:e.isDefault);return i.find(e=>e.isDefault)?.id||i[0]?.id||e.agents[0]?.id}(e,a,r),n=eu.current;if(n&&eb.some(e=>e.id===n)){G!==n&&q(n),eu.current=null;return}ep.current!==t&&(ep.current=t,s&&eb.some(e=>e.id===s))?q(s):eb.some(e=>e.id===G)||q(s&&eb.some(e=>e.id===s)?s:eb[0]?.id??"")},[e,a,r,G,eb]),(0,i.useEffect)(()=>{let e=globalThis.matchMedia("(min-width: 1024px)"),t=()=>{et(e.matches),e.matches||es(!1)};return t(),e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[]),(0,i.useEffect)(()=>{el(!0)},[]),(0,i.useEffect)(()=>{var e;(e=ed.current)&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[W]),(0,i.useEffect)(()=>{if(!ej||void 0===globalThis.localStorage)return;if(ex.current===ej){ex.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}}(ej);eh.current=!0,B(e?.mission??""),K(e?.thinking??"medium"),ec(null)},[ej]),(0,i.useEffect)(()=>{if(ej&&void 0!==globalThis.localStorage){if(eh.current){eh.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{}}(ej,{mission:W,thinking:V})}},[ej,W,V]),(0,i.useEffect)(()=>{o?.(ev??null)},[ev,o]),(0,i.useEffect)(()=>{if(!n||em.current===n.id)return;em.current=n.id;let e=n.mission.trim();if(!e)return;let t=R(eg?.id??a??null,n.agentId??ev);t&&(ex.current=t);let s=0===W.trim().length||W.trim()===e;ec({id:n.id,mission:e,sourceKind:n.sourceKind??"copy",sourceLabel:n.sourceLabel??"selected runtime"}),s&&B(e),n.agentId&&q(n.agentId),requestAnimationFrame(()=>{ed.current?.focus(),s&&ed.current?.setSelectionRange(e.length,e.length)})},[n,W,a,ev,eg?.id]);let eM=async e=>{let t=e.mission.trim();if(!t)return;H(!0),en(!0);let s=e.agentId||ev,r=Date.now(),n=globalThis.crypto?.randomUUID?.()||`dispatch:${r}`,i=new AbortController;eh.current=!0,B(""),ec(null),X(!1),es(!1),g?.(!1),s&&D({requestId:n,mission:t,agentId:s,workspaceId:eg?.id??a??null,submittedAt:r,abortController:i});try{var l;let o=await fetch("/api/mission",{method:"POST",headers:{"Content-Type":"application/json"},signal:i.signal,body:JSON.stringify({...e,mission:t})}),c=await o.json();if(!o.ok||c.error)throw Error(c.error||"OpenClaw rejected the mission.");L(c,{requestId:n}),ej&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(ej),s&&function(e){let t=[e,...(function(){try{let e=globalThis.localStorage.getItem(C);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[]}})().filter(t=>t.mission.trim()!==e.mission.trim()||t.agentId!==e.agentId||t.workspaceId!==e.workspaceId)].slice(0,6);try{globalThis.localStorage.setItem(C,JSON.stringify(t))}catch{}}({id:globalThis.crypto?.randomUUID?.()||`${r}`,mission:t,agentId:s,agentName:ew??"Agent",workspaceId:eg?.id??a,workspaceName:eg?.name??null,submittedAt:r});let d="string"==typeof c.meta?.outputDirRelative?`${c.status} via ${c.agentId} \xb7 ${c.meta.outputDirRelative}`:`${c.status} via ${c.agentId}`,p="stalled"===c.status&&(l=c.summary,"string"==typeof l&&(/No transcript file was found for this runtime session/i.test(l)||/No transcript entries were found for this runtime/i.test(l)));"stalled"!==c.status||p?j.o.success(p?"Mission is running silently.":"Mission queued in OpenClaw.",{description:p?"AgentOS is waiting for the first transcript update.":d}):j.o.error("Mission could not start.",{description:c.summary||d}),O().catch(()=>null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;E(n,e instanceof Error?e.message:"Unknown mission error."),B(t),ec(eo),X(Q),en(!1),es(!0),g?.(!0),requestAnimationFrame(()=>{ed.current?.focus(),ed.current?.setSelectionRange(t.length,t.length)}),j.o.error("Mission dispatch failed.",{description:e instanceof Error?e.message:"Unknown mission error."})}finally{H(!1)}},eI=(e,t={})=>{en(!1),t.thinking&&K(t.thinking),B(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(()=>{ed.current?.focus();let e=ed.current?.value??"";ed.current?.setSelectionRange(e.length,e.length)})};return(0,s.jsx)("div",{className:(0,N.cn)("mx-auto w-full transition-[width,max-width] duration-300",e$&&"max-w-[360px]",eT&&"lg:w-[360px]"),onMouseEnter:()=>{ee&&!J&&es(!0)},onMouseLeave:()=>{ee&&!J&&es(!1)},children:(0,s.jsx)(b.N,{initial:!1,mode:"wait",children:e$?(0,s.jsx)(f.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},disabled:J,onFocus:()=>{J||es(!0)},onClick:()=>{J||(en(!1),es(!0),requestAnimationFrame(()=>{ed.current?.focus()}))},className:"w-full overflow-hidden rounded-full border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] p-2 text-left shadow-[0_24px_72px_rgba(0,0,0,0.22)] isolate",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-white/[0.07] bg-[linear-gradient(180deg,rgba(20,28,43,0.9),rgba(11,17,28,0.88))] px-3 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",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:ew||"No agent"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 truncate text-[13px] text-[#f6eee5]/58",children:J?"Creating task...":eN}),(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:[J?(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(p.A,{className:"mr-1.5 h-3.5 w-3.5"}),J?"Creating":"Create task"]})]})},"collapsed"):(0,s.jsxs)(f.P.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.985},className:"overflow-hidden rounded-[26px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] p-2.5 shadow-[0_24px_72px_rgba(0,0,0,0.26)] isolate",children:[(0,s.jsx)(b.N,{initial:!1,children:eo?(0,s.jsxs)(f.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 ",eo.sourceLabel]}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>eI(eo.mission,{mode:"replace"}),children:"Replace"}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>eI(eo.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:()=>ec(null),"aria-label":"Dismiss runtime suggestion",children:(0,s.jsx)(u.A,{className:"h-3.5 w-3.5"})})]}):null}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[22px] border border-white/[0.07] bg-[linear-gradient(180deg,rgba(20,28,43,0.92),rgba(10,16,26,0.9))] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] transition-all duration-200",l&&"border-white/[0.14] bg-[linear-gradient(180deg,rgba(24,34,50,0.94),rgba(12,18,30,0.92))] shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]"),onFocusCapture:()=>{en(!1),g?.(!0)},onBlurCapture:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||(g?.(!1),ee||0!==W.trim().length||Q||null!==eo||es(!1))},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 pb-1 pt-2.5",children:[ef?(0,s.jsx)(A,{value:G,options:ey,onChange:e=>{en(!1),q(e),c?.(e)}}):(0,s.jsx)(I,{children:"No agent"}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)($,{label:"Refresh AgentOS",onClick:async()=>{Z(!0),await O(),Z(!1)},children:Y?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(m.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)($,{label:"Create workspace",onClick:P,children:(0,s.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)($,{label:"Composer settings",onClick:()=>X(e=>!e),active:Q||"medium"!==V,children:(0,s.jsxs)("span",{className:"relative inline-flex",children:[(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"}),"medium"!==V?(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)(y.T,{ref:ed,value:W,onChange:e=>{en(!1),B(e.target.value)},onKeyDown:async e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),ek&&ev&&await eM({mission:W,agentId:ev,workspaceId:a??void 0,thinking:V}))},placeholder:eN,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 shadow-none 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)(b.N,{initial:!1,children:eS?(0,s.jsxs)(f.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:[eC.map(e=>(0,s.jsx)(M,{label:e.label,onClick:()=>{"open-workspace-create"===e.action?P():e.mission&&eI(e.mission,{thinking:e.thinking})}},e.id)),eg?(0,s.jsx)(w.O,{snapshot:e,defaultWorkspaceId:eg.id,onRefresh:O,onAgentCreated:e=>{eu.current=e,q(e)},onAgentCreatedVisible:U,surfaceTheme:t,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,ei&&eg?(0,s.jsx)("button",{type:"button",onClick:()=>_(),className:"inline-flex h-8 items-center rounded-full border border-cyan-300/18 bg-cyan-400/[0.1] px-3 text-[12px] text-cyan-50 transition-all hover:border-cyan-300/28 hover:bg-cyan-400/[0.14] hover:text-white",children:"Manage Surfaces"}):null]}):(0,s.jsx)("div",{})}),(0,s.jsxs)(v.$,{className:"h-9 rounded-full bg-white px-3.5 text-slate-950 shadow-none hover:bg-white/92",disabled:!ek,onClick:async()=>{ev&&await eM({mission:W,agentId:ev,workspaceId:a??void 0,thinking:V})},children:[J?(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(p.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Create task"]})]})]}),(0,s.jsx)(b.N,{initial:!1,children:Q?(0,s.jsx)(f.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-[linear-gradient(180deg,rgba(14,20,31,0.96),rgba(10,15,24,0.94))] 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)(T,{ariaLabel:"Select thinking level",value:V,options:[{label:"off",value:"off"},{label:"minimal",value:"minimal"},{label:"low",value:"low"},{label:"medium",value:"medium"},{label:"high",value:"high"}],onChange:e=>K(e)})}),(0,s.jsx)("button",{type:"button",className:"mt-3 text-[12px] text-slate-400 transition-colors hover:text-white",onClick:()=>{en(!1),B(""),K("medium"),ec(null),eh.current=!0,ej&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(ej)},children:"Clear draft"})]})}):null})]},"expanded")})})}function A({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)(g.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"}):null]})}function T({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)(g.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"})]})}function $({label:e,active:t=!1,onClick:a,children:r}){return(0,s.jsx)("button",{type:"button","aria-label":e,title:e,onClick:a,className:(0,N.cn)("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 M({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 I({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 R(e,t){return e||t?`mission-control-composer-draft:${e??"global"}:${t??"unassigned"}`:null}var O=a(49568),P=a(94766),_=a(37227),D=a(86161),E=a(10910),L=a(46765),U=a(60159),F=a(39582),z=a(90656),W=a(2452),B=a(48583),G=a(91980),q=a(88790),V=a(38436),K=a(93028),J=a(66761),H=a(12842);let Y=["Focus on tests","Prioritize UI polish","Avoid changing public API","Continue from the latest failure"];function Z({className:e,...t}){return(0,s.jsx)(J.E,{...t,className:(0,N.cn)("!h-4 !px-1.5 !py-0 !text-[8px] !leading-none !tracking-[0.1em] !whitespace-nowrap",e)})}function Q(e){return(0,s.jsx)(X,{...e},e.selectedNodeId??"overview")}function X({snapshot:e,surfaceTheme:t,selectedNodeId:a,agentDetailFocus:r,lastMission:n,onRefresh:l,onSnapshotChange:o,onConfigureAgentCapabilities:c,onConnectModelProvider:d,onAbortTask:p,collapsed:u,onToggleCollapsed:m,activeTab:h,onActiveTabChange:x}){let g=(0,k.hv)(e.generatedAt),w=e.workspaces.find(e=>e.id===a),v=e.agents.find(e=>e.id===a),y=e.tasks.find(e=>e.id===a),j=e.runtimes.find(e=>e.id===a),C=e.models.find(e=>e.id===a),S=!!y?.metadata.optimistic,A=w||v||y||j||C||null,T=j?.id??null,$=y?.id??null,M=y&&"string"==typeof y.dispatchId?y.dispatchId:null,[I,R]=(0,i.useState)(null),[U,F]=(0,i.useState)(null),[z,W]=(0,i.useState)(null),[B,q]=(0,i.useState)(null),K=(0,i.useMemo)(()=>{var e;return S&&y?{task:e=y,runs:[],outputs:[],liveFeed:function(e){let t=new Map;for(let a of[...ep(e.metadata.optimisticEvents),...ep(e.metadata.reviewEvents)])t.set(a.id,a);return[...t.values()].sort((e,t)=>Date.parse(e.timestamp)-Date.parse(t.timestamp))}(e),createdFiles:[],warnings:ew(e)||"stalled"===e.status&&!ef(e.subtitle)?[e.subtitle]:[],integrity:ed(e)}:null},[S,y]),J=I&&I.runtimeId===T?I:null,H=U?.runtimeId===T?U.message:null,Y=z&&(z.task.id===$||M&&"string"==typeof z.task.dispatchId&&z.task.dispatchId===M)?z:null,Q=B?.taskId===$?B.message:null,er=Y??K,en=!!$&&(!S||!!M),ec=en&&!Y&&!Q,eu=!!T&&!J&&!H,em=!!v,eh=!!(j||y),ex=!!(j||y),eg=("chat"!==h||em)&&("output"!==h||eh)&&("files"!==h||ex)?h:"overview",eb="chat"===eg&&!!v,ev=y?"Feed":"Output",eA=w?.name||(v?(0,k.CK)(v):null)||(y?(0,k.$m)(y.title||y.mission||"Task",48)||"Task":null)||(j?(0,k.$m)(j.title||"Run",48)||"Run":null)||C?.name||"Gateway overview",eT=w?"workspace":v?"agent":y?"task":j?"run":C?"model":"selection",e$=(0,i.useMemo)(()=>[{id:"overview",label:"Overview",icon:O.A,enabled:!0},{id:"chat",label:"Chat",icon:P.A,enabled:em},{id:"output",label:ev,icon:_.A,enabled:eh},{id:"files",label:"Files",icon:D.A,enabled:ex},{id:"raw",label:"Raw",icon:E.A,enabled:!0}],[ev,em,ex,eh]);return(0,i.useEffect)(()=>{if(!T)return;let e=new AbortController;return fetch(`/api/runtimes/${encodeURIComponent(T)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Unable to load runtime output.");R(t),F(null)}).catch(t=>{e.signal.aborted||(R(null),F({runtimeId:T,message:t instanceof Error?t.message:"Unable to load runtime output."}))}),()=>e.abort()},[T]),(0,i.useEffect)(()=>{if(!$||!en)return;let e=new URLSearchParams;M&&e.set("dispatchId",M);let t=new EventSource(`/api/tasks/${encodeURIComponent($)}/stream${e.size>0?`?${e.toString()}`:""}`),a=e=>{try{let t=JSON.parse(e.data);if("task"!==t.type)return;W(t.detail),q(null)}catch(e){q({taskId:$,message:e instanceof Error?e.message:"Unable to parse task feed."})}},s=e=>{try{let t=JSON.parse(e.data);"error"===t.type&&q({taskId:$,message:t.error})}catch{q({taskId:$,message:"Unable to load task detail."})}};return t.addEventListener("task",a),t.addEventListener("task-error",s),t.onerror=()=>{q(e=>e?.taskId===$?e:{taskId:$,message:"Task feed disconnected. Reconnecting…"})},()=>{t.removeEventListener("task",a),t.removeEventListener("task-error",s),t.close()}},[$,en,M]),(0,s.jsxs)("div",{className:"panel-surface panel-glow flex h-full flex-row-reverse overflow-hidden rounded-none border border-r-0 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:(0,N.cn)("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-1.5 py-2",u?"w-full":"w-[60px] border-l border-white/[0.08]"),children:[(0,s.jsx)(V.A,{label:"Inspector",side:"left",surfaceTheme:t,panelCollapsed:u,children:(0,s.jsx)("button",{type:"button","aria-label":u?"Expand inspector":"Collapse inspector",onClick:m,className:"flex h-9 w-9 items-center justify-center rounded-[8px] border border-cyan-300/18 bg-cyan-400/[0.1] shadow-[0_8px_18px_rgba(34,211,238,0.14)] transition-all hover:border-cyan-200/24 hover:bg-cyan-400/[0.14]",children:(0,s.jsx)(_.A,{className:"h-3.5 w-3.5 text-cyan-200"})})}),(0,s.jsx)("div",{className:"mt-3.5 flex flex-1 flex-col items-center gap-1",children:e$.map(e=>(0,s.jsx)(eC,{icon:e.icon,label:e.label,active:eg===e.id,surfaceTheme:t,panelCollapsed:u,tooltipSide:"left",disabled:!e.enabled,onClick:()=>{e.enabled&&(x(e.id),u&&m())}},e.id))}),(0,s.jsxs)("div",{className:"mt-1.5 flex flex-col items-center gap-0.5",children:[(0,s.jsx)(Z,{variant:"muted",className:"h-4 min-w-[28px] rounded-full px-1 py-0 text-[8px] leading-none tracking-[0.12em]",children:A?"live":"idle"}),u?(0,s.jsx)("p",{className:"max-w-[44px] truncate text-center text-[8px] uppercase tracking-[0.14em] text-slate-500",children:eT}):null]})]}),u?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:(0,N.cn)("mission-scroll flex h-full min-h-0 flex-col overscroll-contain",eb?"overflow-hidden":"overflow-y-auto"),children:[(0,s.jsxs)("div",{className:"shrink-0 border-b border-white/[0.08] px-3 pb-2 pt-3",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-[9px] font-medium uppercase tracking-[0.24em] text-slate-500",children:"Inspector"}),(0,s.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5",children:[(0,s.jsx)("h2",{className:"min-w-0 truncate font-display text-[1.02rem] leading-5 text-white",children:eA}),(0,s.jsx)(Z,{variant:"muted",className:"shrink-0 h-4 px-1.5 py-0 text-[8px] leading-none tracking-[0.1em]",children:eT})]}),(0,s.jsx)("p",{className:"mt-1 truncate text-[11px] leading-4 text-slate-400",children:y?`${y.runtimeCount} runs \xb7 ${y.liveRunCount} live \xb7 ${(0,k.fw)(y.updatedAt,g)}`:j?`Run ${(0,k.m_)(j.runId||j.id,10)} \xb7 ${j.status} \xb7 ${(0,k.fw)(j.updatedAt,g)}`:v?`${v.activeRuntimeIds.length} active runs`:w?`${w.agentIds.length} agents attached`:C?`${C.provider} model`:"Live gateway context"})]}),(0,s.jsx)("div",{className:"hidden h-8 w-8 shrink-0 items-center justify-center rounded-none border border-white/10 bg-white/[0.04] text-cyan-200 sm:flex",children:(0,s.jsx)(_.A,{className:"h-3.5 w-3.5"})})]}),(0,s.jsx)("div",{className:"mt-2 flex flex-nowrap gap-1 overflow-x-auto pb-0.5",children:e$.filter(e=>e.enabled).map(e=>(0,s.jsx)(eS,{label:e.label,active:eg===e.id,onClick:()=>x(e.id)},e.id))})]}),(0,s.jsx)("div",{className:(0,N.cn)("flex-1 p-3",eb&&"min-h-0 overflow-hidden"),children:(0,s.jsx)(b.N,{mode:"wait",children:(0,s.jsxs)(f.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:(0,N.cn)("space-y-3.5",eb&&"flex h-full min-h-0 flex-col space-y-0"),children:["overview"===eg?(0,s.jsxs)(s.Fragment,{children:[w?(0,s.jsx)(et,{snapshot:e,workspaceId:w.id}):null,v?(0,s.jsx)(ea,{snapshot:e,agentId:v.id,focusSection:r,onConfigureAgentCapabilities:c}):null,y?(0,s.jsx)(es,{snapshot:e,task:y,taskId:y.id,taskDetail:er,taskDetailLoading:ec,taskDetailError:Q,onAbortTask:p,onControlComplete:l}):null,j?(0,s.jsx)(ey,{snapshot:e,runtimeId:j.id,runtimeOutput:J,runtimeOutputLoading:eu,runtimeOutputError:H}):null,C?(0,s.jsx)(eN,{snapshot:e,modelId:C.id}):null,A?null:(0,s.jsx)(ee,{snapshot:e,lastMission:n})]}):null,v?(0,s.jsx)("div",{className:(0,N.cn)("min-h-0 flex-1",eb?"block":"hidden"),"aria-hidden":!eb,children:(0,s.jsx)(G.d,{agent:v,snapshot:e,surfaceTheme:t,isVisible:eb,onRefresh:l,onSnapshotChange:o,onConnectModelProvider:d})}):null,"output"===eg&&y?(0,s.jsx)(ei,{task:y,basePath:eo(e,y,er?.runs),taskDetail:er,taskDetailLoading:ec,taskDetailError:Q,onAbortTask:p,onControlComplete:l}):null,"output"===eg&&j?(0,s.jsx)(ek,{runtime:j,basePath:e.workspaces.find(e=>e.id===j.workspaceId)?.path,runtimeOutput:J,runtimeOutputLoading:eu,runtimeOutputError:H}):null,"files"===eg&&y?(0,s.jsx)(el,{snapshot:e,task:y,taskDetail:er}):null,"files"===eg&&j?(0,s.jsx)(ej,{runtime:j,runtimeOutput:J}):null,"raw"===eg?(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(y&&er?er:j&&J?{runtime:j,output:J}:A||e,null,2)}):null]},a||"overview")})}),eb?null:(0,s.jsx)("div",{className:"shrink-0 border-t border-white/[0.08] p-3",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-3.5 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)(L.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:y?`${y.runtimeCount} runs`:j?`Run ${(0,k.m_)(j.runId||j.id,10)}`:v?`${v.activeRuntimeIds.length} active runs`:w?`${w.agentIds.length} agents`:C?C.provider:"Gateway overview"}),(0,s.jsxs)("p",{className:"mt-1 text-[12px] text-slate-400",children:[eT," \xb7"," ",y?`${er?.liveFeed.length??0} live feed events`:j?`${J?.items.length??0} transcript entries`:v?`${v.activeRuntimeIds.length} tracked runs`:w?`${w.agentIds.length} attached`:`${e.presence.length} live beacons`]})]})]})})})]})})]})}function ee({snapshot:e,lastMission:t}){let a=(0,k.hv)(e.generatedAt),r=e.diagnostics.runtime.stateWritable&&e.diagnostics.runtime.sessionStoreWritable?"passed"===e.diagnostics.runtime.smokeTest.status?"verified":"pending smoke test":"attention";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:L.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)(eA,{icon:D.A,title:"Runtime preflight",value:r,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:e.diagnostics.runtime.stateRoot}),(0,s.jsx)("p",{children:e.diagnostics.runtime.sessionStores.length>0?`${e.diagnostics.runtime.sessionStores.filter(e=>e.writable).length}/${e.diagnostics.runtime.sessionStores.length} session stores writable`:"No agent session stores have been probed yet."}),e.diagnostics.runtime.smokeTest.checkedAt?(0,s.jsxs)("p",{children:["Smoke test ",e.diagnostics.runtime.smokeTest.status," \xb7"," ",e.diagnostics.runtime.smokeTest.agentId||"unknown agent"," \xb7"," ",(0,k.fw)(Date.parse(e.diagnostics.runtime.smokeTest.checkedAt),a)]}):(0,s.jsx)("p",{children:"No runtime smoke test has been recorded yet."}),e.diagnostics.runtime.issues[0]?(0,s.jsx)("div",{className:"rounded-[14px] border border-amber-400/15 bg-amber-400/8 px-3 py-2 text-[13px] text-amber-50",children:e.diagnostics.runtime.issues[0]}):null]}),(0,s.jsxs)(eA,{icon:_.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)(eA,{icon:U.A,title:"Last mission",value:t.status,children:[(0,s.jsx)("p",{className:"text-sm text-white",children:t.summary}),(0,s.jsx)("p",{className:"font-mono text-xs text-slate-500",children:t.runId?`Run ${t.runId}`:`Dispatch ${t.dispatchId??"pending"}`}),"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 et({snapshot:e,workspaceId:t}){let a=(0,k.hv)(e.generatedAt),r=e.workspaces.find(e=>e.id===t),n=e.agents.filter(e=>e.workspaceId===t),i=r?r.modelIds.map(t=>e.models.find(e=>e.id===t)?.name||t):[],l=e.runtimes.filter(e=>e.workspaceId===t||r?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0));if(!r)return null;let o=l.filter(e=>"running"===e.status||"queued"===e.status||"idle"===e.status),c=l[0]??null,d=e_(l.flatMap(eP)).slice(0,8),p=r.bootstrap.coreFiles.every(e=>e.present)&&r.bootstrap.projectShell.every(e=>e.present)?"ready":r.bootstrap.coreFiles.some(e=>e.present)||r.bootstrap.projectShell.some(e=>e.present)?"partial":"thin",u=Array.from(new Set(n.flatMap(e=>e.observedTools??[]))),m=0===n.length?"no agents":r.capabilities.workspaceOnlyAgentCount===n.length?"workspace-only":0===r.capabilities.workspaceOnlyAgentCount?"open":"mixed";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:D.A,title:"Overview",value:r.health,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:(0,k.$7)(r.path)}),(0,s.jsx)(eM,{items:[{label:"Agents",value:String(n.length)},{label:"Models",value:String(r.modelIds.length)},{label:"Runs",value:String(l.length)},{label:"Sessions",value:String(r.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)(eR,{emptyLabel:"No models attached",items:i,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:n.map(e=>(0,s.jsx)(Z,{variant:e.isDefault?"default":"muted",children:(0,k.CK)(e)},e.id))})]})]}),(0,s.jsxs)(eA,{icon:U.A,title:"Bootstrap",value:p,children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(Z,{variant:r.bootstrap.template?"default":"muted",children:r.bootstrap.template||"template unknown"}),(0,s.jsx)(Z,{variant:r.bootstrap.sourceMode?"muted":"warning",children:r.bootstrap.sourceMode||"source unknown"}),r.bootstrap.agentTemplate?(0,s.jsx)(Z,{variant:"muted",children:r.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)(eI,{items:r.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)(eI,{items:[...r.bootstrap.optionalFiles,...r.bootstrap.folders]})]}),r.bootstrap.contextFiles?.length?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Context docs"}),(0,s.jsx)(eI,{items:r.bootstrap.contextFiles})]}):null,(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)(eI,{items:r.bootstrap.projectShell})]})]}),(0,s.jsxs)(eA,{icon:U.A,title:"Capabilities",value:m,children:[(0,s.jsxs)("p",{children:[r.capabilities.workspaceOnlyAgentCount,"/",n.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)(eR,{emptyLabel:"No explicit skills",items:r.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)(eR,{emptyLabel:"No local SKILL.md scaffolds",items:r.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:"Declared tools"}),(0,s.jsx)(eR,{emptyLabel:"No explicit tools configured",items:r.capabilities.tools,emptyVariant:"muted",itemVariant:"warning"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed tools"}),(0,s.jsx)(eR,{emptyLabel:"No runtime tool calls recovered yet",items:u,emptyVariant:"muted",itemVariant:"default"})]})]}),(0,s.jsxs)(eA,{icon:_.A,title:"Activity",value:`${o.length} live`,children:[(0,s.jsxs)("p",{children:[l.length," tracked runs across ",r.totalSessions," recorded sessions."]}),(0,s.jsx)("p",{children:c?`Latest update ${(0,k.fw)(c.updatedAt,a)}`:"No runtime activity has been recorded yet."}),l.length>0?(0,s.jsx)("div",{className:"space-y-2 pt-1",children:l.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 ",(0,k.m_)(e.runId||e.id,10)]})]}),(0,s.jsx)(Z,{variant:(0,k.Uu)(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:n.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:(0,k.CK)(e)}),(0,s.jsx)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.currentAction})]}),(0,s.jsx)(Z,{variant:"engaged"===e.status?"default":"offline"===e.status?"danger":"muted",children:e.status})]},e.id))})]})]}),(0,s.jsx)(eA,{icon:E.A,title:"Created files",value:String(d.length),children:(0,s.jsx)(e$,{files:d,basePath:r.path,emptyLabel:"No file artifacts have been detected in recent workspace runs."})})]})}function ea({snapshot:e,agentId:t,focusSection:a,onConfigureAgentCapabilities:r}){let n=(0,k.hv)(e.generatedAt),l=e.agents.find(e=>e.id===t),o=e.workspaces.find(e=>e.id===l?.workspaceId),c=e.models.find(e=>e.id===l?.modelId),d=(0,i.useRef)(null),p=(0,i.useRef)(null),u=(0,i.useRef)(null),m=l?.observedTools??[],h=l?.skills??[],x=(l?.tools??[]).filter(e=>"fs.workspaceOnly"!==e),g=l?.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[],w=l?(0,H.Cf)(l.policy.preset):null,y=h.length>0?h:w?.skillIds??[],j=x.length>0?x:w?.tools??[],C=l?[{label:"Preset",value:(0,H._P)(l.policy.preset)},{label:"Missing tools",value:(0,H.zR)(l.policy.missingToolBehavior)},{label:"Install scope",value:(0,H.UJ)(l.policy.installScope)},{label:"File access",value:(0,H.bQ)(l.policy.fileAccess)},{label:"Network",value:(0,H.Bw)(l.policy.networkAccess)}]:[],S=e.runtimes.filter(e=>l?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),[A,T]=(0,i.useState)(null),$=e_(S.flatMap(eP)).slice(0,8);return((0,i.useEffect)(()=>{if(!a)return;let e="skills"===a?d.current:"tools"===a?p.current:u.current;e?.scrollIntoView({behavior:"smooth",block:"start"})},[a]),l)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:U.A,title:"Agent identity",value:l.id,children:[(0,s.jsx)("p",{children:(0,k.CK)(l)}),(0,s.jsx)("p",{children:l.identity.emoji?`${l.identity.emoji} \xb7 ${l.identity.theme??"theme unset"}`:"No identity emoji"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[l.isDefault?(0,s.jsx)(Z,{variant:"default",children:"default agent"}):null,(0,s.jsx)(Z,{variant:(0,H.Cf)(l.policy.preset).badgeVariant,children:(0,H._P)(l.policy.preset)}),l.identity.source?(0,s.jsx)(Z,{variant:"muted",children:l.identity.source}):null]})]}),(0,s.jsxs)(eA,{icon:D.A,title:"Workspace",value:o?.name||"n/a",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:(0,k.$7)(l.workspacePath)}),(0,s.jsxs)("p",{children:[l.sessionCount," recorded sessions"]})]}),(0,s.jsxs)(eA,{icon:U.A,title:"Model assignment",value:c?.name||l.modelId,children:[(0,s.jsx)("p",{children:c?`${c.provider} \xb7 ${(0,k.FO)(c.contextWindow)} ctx`:"Model metadata unavailable"}),(0,s.jsx)("p",{children:c?.available===!1?"Currently unavailable":c?.local?"Local model route":"Remote model route"})]}),(0,s.jsx)(eA,{icon:U.A,title:"Agent summary",value:(0,H._P)(l.policy.preset),actions:(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{r?.(l.id,"tools"===a?"tools":"skills")},className:"h-7 rounded-full px-2.5 text-[11px]",children:[(0,s.jsx)(F.A,{className:"mr-1 h-3 w-3"}),"Edit"]}),children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Purpose"}),(0,s.jsx)("div",{className:"w-full rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:(0,s.jsx)("p",{className:"text-[13px] leading-5 text-slate-200",children:l.profile.purpose||"No explicit purpose was found in the workspace bootstrap files."})})]}),(0,s.jsxs)("div",{ref:d,className:(0,N.cn)("scroll-mt-4 rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5 transition-all","skills"===a&&"border-cyan-300/25 bg-cyan-400/[0.05] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Skills"}),(0,s.jsxs)(Z,{variant:"muted",children:[y.length," active"]})]}),(0,s.jsx)(eR,{emptyLabel:"No skills available",items:y,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{ref:p,className:(0,N.cn)("scroll-mt-4 rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5 transition-all","tools"===a&&"border-cyan-300/25 bg-cyan-400/[0.05] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Tools"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[g.length>0?(0,s.jsxs)(Z,{variant:"success",children:[(0,s.jsx)(z.A,{className:"mr-1 h-3 w-3"}),"policy locked"]}):null,(0,s.jsxs)(Z,{variant:"muted",children:[j.length," active"]})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(eR,{emptyLabel:"No tools available",items:j,emptyVariant:"muted",itemVariant:"warning"}),g.length>0?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Policy locked"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:g.map(e=>(0,s.jsxs)(Z,{variant:"success",children:[(0,s.jsx)(z.A,{className:"mr-1 h-3 w-3"}),e]},e))}),(0,s.jsx)("p",{className:"mt-1 text-[11px] leading-5 text-slate-500",children:"This capability is derived from the agent policy and cannot be removed here."})]}):null,m.length>0?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed"}),(0,s.jsx)(eR,{emptyLabel:"No runtime tool calls recovered yet",items:m,emptyVariant:"muted",itemVariant:"default"})]}):null]})]}),(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-3",children:[(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-400",children:w?.description??"No policy description available."}),(0,s.jsxs)("div",{className:"mt-3 grid gap-1.5 text-[13px] text-slate-300",children:[C.map(e=>(0,s.jsxs)("p",{children:[e.label,": ",(0,s.jsx)("span",{className:"text-white",children:e.value})]},e.label)),l.profile.outputPreference?(0,s.jsxs)("p",{children:["Output preference: ",(0,s.jsx)("span",{className:"text-white",children:l.profile.outputPreference})]}):null]})]})]})}),(0,s.jsxs)(eA,{icon:L.A,title:"Runtime posture",value:l.status,children:[(0,s.jsx)("p",{children:l.currentAction}),(0,s.jsxs)("p",{children:["Last active ",(0,k.fw)(l.lastActiveAt,n)]}),(0,s.jsx)("p",{children:l.heartbeat.enabled?`Heartbeat ${l.heartbeat.every}`:"Heartbeat disabled"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(Z,{variant:l.heartbeat.enabled?"success":"muted",children:l.heartbeat.enabled?"heartbeat on":"heartbeat off"}),"number"==typeof l.heartbeat.everyMs?(0,s.jsxs)(Z,{variant:"muted",children:[Math.round(l.heartbeat.everyMs/1e3),"s interval"]}):null]})]}),(0,s.jsx)("div",{ref:u,className:"scroll-mt-4",children:(0,s.jsxs)(eA,{icon:_.A,title:"Activity history",value:String(S.length),className:(0,N.cn)("sessions"===a&&"border-cyan-300/25 bg-[linear-gradient(180deg,rgba(12,25,37,0.92),rgba(8,13,24,0.88))] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("p",{children:[l.sessionCount," recorded sessions overall."]}),(0,s.jsx)("p",{children:S.length>0?`${S.length} history item${1===S.length?"":"s"} recovered from the latest agent activity.`:"No linked runtime records were recovered for this agent in the current snapshot."}),l.sessionCount>S.length?(0,s.jsxs)("p",{className:"text-[12px] text-slate-500",children:[l.sessionCount-S.length," session",l.sessionCount-S.length==1?"":"s"," do not have recovered runtime data yet."]}):null,S.length>0?(0,s.jsx)("div",{className:"space-y-2.5 pt-1",children:S.map(e=>{var t,a;let r=A===e.id,i=function(e){switch(e){case"session":return"Direct chat";case"turn":return"Conversation";case"cron":return"Scheduled";default:return"Unknown source"}}(e.source),l=function(e){if(e.taskId)return"Task";switch(e.source){case"session":return"Chat";case"turn":return"Run";case"cron":return"Scheduled";default:return"Activity"}}(e),o=e.sessionId?`session ${(0,k.m_)(e.sessionId,10)}`:e.runId?`run ${(0,k.m_)(e.runId,10)}`:"session n/a",c="number"!=typeof(t=e.tokenUsage?.total)||Number.isNaN(t)?"0 Tokens":t>=1e3?`${Math.round(t/1e3)}K Tokens`:`${t} Tokens`,d="number"!=typeof(a=e.updatedAt)||Number.isNaN(a)?"No time":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(a));return(0,s.jsxs)("div",{className:(0,N.cn)("overflow-hidden rounded-[14px] border bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] transition-all",r?"border-cyan-300/22 shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-white/[0.08]"),children:[(0,s.jsxs)("button",{type:"button","aria-expanded":r,className:"nodrag nopan flex w-full flex-col gap-2 px-3 py-2.5 text-left transition-colors hover:bg-white/[0.03]",onClick:()=>{T(t=>t===e.id?null:e.id)},onPointerDown:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)(Z,{variant:(0,k.Uu)(e.status),children:e.status}),(0,s.jsx)(Z,{variant:e.tokenUsage?.total?"default":"muted",children:c})]}),(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsx)("p",{className:"line-clamp-2 text-[13px] leading-5 text-white",children:e.title}),(0,s.jsx)("p",{className:"line-clamp-2 text-[12px] leading-5 text-slate-300",children:e.subtitle})]}),(0,s.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("p",{className:"truncate text-[9px] uppercase tracking-[0.18em] text-slate-500",children:[l," \xb7 ",o]})}),(0,s.jsx)("p",{className:"shrink-0 text-right text-[9px] uppercase tracking-[0.18em] text-slate-500",children:d})]})]}),(0,s.jsx)(b.N,{initial:!1,children:r?(0,s.jsx)(f.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18},className:"overflow-hidden border-t border-white/[0.08]",children:(0,s.jsxs)("div",{className:"space-y-3 px-3 py-3",children:[(0,s.jsx)(eM,{items:[{label:"Source",value:i},{label:"Status",value:e.status},{label:"Updated",value:(0,k.fw)(e.updatedAt,n)},{label:"Key",value:(0,k.m_)(e.key,12)}]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[e.sessionId?(0,s.jsxs)(Z,{variant:"muted",children:["session ",(0,k.m_)(e.sessionId,12)]}):null,e.runId?(0,s.jsxs)(Z,{variant:"muted",children:["run ",(0,k.m_)(e.runId,12)]}):null,e.taskId?(0,s.jsxs)(Z,{variant:"muted",children:["task ",(0,k.m_)(e.taskId,12)]}):null,e.modelId?(0,s.jsxs)(Z,{variant:"muted",children:["model ",(0,k.m_)(e.modelId,12)]}):null]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Preview"}),(0,s.jsx)("div",{className:"rounded-[12px] border border-white/[0.08] bg-white/[0.03] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-200",children:e.subtitle})})]}),e.toolNames?.length?(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)(eR,{emptyLabel:"No tool names recorded",items:e.toolNames,emptyVariant:"muted",itemVariant:"warning"})]}):null]})}):null})]},e.id)})}):null]})}),(0,s.jsx)(eA,{icon:E.A,title:"Created files",value:String($.length),children:(0,s.jsx)(e$,{files:$,basePath:l.workspacePath,emptyLabel:"No file artifacts have been detected for this agent yet."})}),(0,s.jsxs)(eA,{icon:U.A,title:"Capabilities",value:`${l.skills.length} skills`,children:[(0,s.jsx)(eR,{emptyLabel:"No explicit skills",items:l.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:"Declared tools"}),(0,s.jsx)(eR,{emptyLabel:"No explicit tools configured",items:l.tools,emptyVariant:"muted",itemVariant:"warning"})]}),(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:"Observed tools"}),(0,s.jsx)(eR,{emptyLabel:"No runtime tool calls recovered yet",items:m,emptyVariant:"muted",itemVariant:"default"})]})]})]}):null}function es({snapshot:e,task:t,taskId:a,taskDetail:r,taskDetailLoading:n,taskDetailError:i,onAbortTask:l,onControlComplete:o}){var c,d,p,u,m;let h,x=e.tasks.find(e=>e.id===a)??t,g=r?.task?(c=r.task,d=x,0===Object.keys(h=Object.fromEntries(["reviewStatus","reviewAction","reviewedAt","reviewEvents"].map(e=>[e,d.metadata[e]]).filter(([,e])=>void 0!==e))).length?c:{...c,metadata:{...c.metadata,...h}}):x,b=ew(g),f=r?.runs??e.runtimes.filter(e=>t?.runtimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),w=eo(e,g,f),v=ec(e,g,f),y=e.agents.find(e=>e.id===g?.primaryAgentId),j=r?.createdFiles??e_(f.flatMap(e=>eP(e))),N=r?.warnings??[];if(!t)return null;let C=r?.integrity??ed(t),S=eu(g),A=("string"==typeof(p=g).metadata.routedMission?p.metadata.routedMission.trim():"")||eu(p),T=(u=S,m=A,ex(u)!==ex(m)),$=em(g),M=eh(g.metadata.sessionCount,g.sessionIds.length),I=eh(g.metadata.turnCount,f.length),R=(r?.liveFeed??[]).filter(e=>eb(e)).sort((e,t)=>Date.parse(e.timestamp)-Date.parse(t.timestamp)),O=function(e){for(let t of e)if("string"==typeof t.filePath&&"string"==typeof t.displayPath)return{path:t.filePath,displayPath:t.displayPath};return null}(R);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:D.A,title:"Mission",value:b?"aborted":g.status,children:[(0,s.jsx)(eT,{label:"Original prompt",text:S,basePath:w}),(0,s.jsx)(eT,{label:"Sent to OpenClaw",text:T?A:"Same as original prompt.",basePath:w,subtle:!T}),(0,s.jsx)(eT,{label:"Latest task output",text:$||"Waiting for the first OpenClaw update.",basePath:w,subtle:!$}),(0,s.jsx)(eM,{items:[{label:"Sessions",value:String(M)},{label:"Turns",value:String(I)},{label:"Runs",value:String(g.runtimeCount)},{label:"Files",value:String(g.artifactCount)},{label:"Live",value:String(g.liveRunCount)},{label:"Tools",value:String(C.toolNames.length)}]}),(0,s.jsx)(en,{task:g,onAbortTask:l,onControlComplete:o}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v?(0,s.jsx)(Z,{variant:"muted",children:v.name}):null,y?(0,s.jsx)(Z,{variant:"default",children:(0,k.CK)(y)}):null,g.dispatchId?(0,s.jsxs)(Z,{variant:"muted",children:["dispatch ",(0,k.m_)(g.dispatchId,8)]}):null,b?(0,s.jsx)(Z,{variant:"danger",children:"aborted"}):null]}),n&&!r?(0,s.jsx)("p",{children:"Connecting live task feed…"}):null,i?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:i}):null]}),(0,s.jsx)(er,{task:g,integrity:C,basePath:w,latestEvidenceAt:([...r?.liveFeed??[]].reverse().find(e=>"assistant"===e.kind||"tool"===e.kind||"artifact"===e.kind)??null)?.timestamp??null}),(0,s.jsxs)(eA,{icon:_.A,title:"Runner logs",value:String(R.length),children:[O?(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] 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:"Log file"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:O.displayPath,className:"text-[12.5px] leading-5 text-slate-100",filePath:O.path,displayPath:O.displayPath,basePath:w})}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-slate-400",children:"Only meaningful runner diagnostics are shown here. OpenClaw bootstrap debug noise is hidden."})]}):null,0===R.length?(0,s.jsx)("p",{children:"No meaningful dispatch runner diagnostics have been captured for this task yet."}):(0,s.jsx)("div",{className:"max-h-[300px] space-y-2 overflow-y-auto pr-1",children:R.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.jsx)("div",{className:"flex min-w-0 items-center gap-2",children:(0,s.jsx)(Z,{variant:eD(e.kind,e.isError),children:e.title})}),(0,s.jsx)("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.18em] text-slate-500",children:(0,k.fw)(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("pre",{className:"mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-slate-100",children:e.detail})]},e.id))})]}),(0,s.jsxs)(eA,{icon:_.A,title:"Runs",value:String(f.length),children:[0===f.length?(0,s.jsx)("p",{children:"No OpenClaw runs have been grouped into this task yet."}):null,(0,s.jsx)("div",{className:"space-y-2",children:f.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)(Z,{variant:(0,k.Uu)(e.status),children:e.status})]},e.id))})]}),(0,s.jsx)(eA,{icon:E.A,title:"Artifacts",value:String(j.length),children:(0,s.jsx)(e$,{files:j,basePath:w,emptyLabel:"This task has not produced a detectable file artifact yet."})}),N.length>0?(0,s.jsx)(eA,{icon:L.A,title:"Warnings",value:String(N.length),children:(0,s.jsx)(eO,{items:N,emptyLabel:"No warnings detected."})}):null]})}function er({task:e,integrity:t,basePath:a,latestEvidenceAt:r}){let n=ew(e),i=!!e.metadata.optimistic&&!n&&"stalled"!==e.status,l=t.issues.find(e=>"missing-final-response"===e.id),o=t.issues.find(e=>"partial-final-response"===e.id),c=(0,K.VL)(e,{hasLiveActivity:"running"===e.status||"queued"===e.status||e.liveRunCount>0,latestEvidenceAt:r}),d=(0,K.kg)(e),p=(0,K.UF)(e),u=c?(0,K.E2)(c):n?"This task was aborted by an operator. Captured evidence may be incomplete.":i?"OpenClaw accepted this task. Session, tool, and file evidence will appear here as soon as the first runtime reports in.":l?l.detail:o?o.detail:"verified"===t.status?"AgentOS found a matching transcript and the captured result looks internally consistent.":t.sessionMismatch?"The linked transcript belongs to a different mission or stale session, so this completion cannot be trusted yet.":t.issues.some(e=>"empty-output-dir"===e.id)?"The task is marked completed, but the expected deliverables are missing from the output folder.":"error"===t.status?"The captured evidence does not line up with the requested mission.":"AgentOS recovered partial evidence, but this result still needs operator review.";return(0,s.jsxs)(eA,{icon:L.A,title:"Result integrity",value:c?(0,K.B4)(c):n?"aborted":o?"needs review":"stalled"!==e.status||t.finalResponseText?i?"pending":t.status:"waiting output",children:[(0,s.jsx)("p",{children:u}),c?(0,s.jsxs)("div",{className:"rounded-[14px] border border-emerald-400/16 bg-emerald-400/[0.06] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-emerald-100/80",children:"Operator review"}),(0,s.jsxs)("p",{className:"mt-2 text-[12px] leading-5 text-emerald-50",children:[d||(0,K.B4)(c),p?` \xb7 ${(0,k.fw)(Date.parse(p))}`:""]})]}):null,(0,s.jsx)(eM,{items:[{label:"Output files",value:String(t.outputFileCount)},{label:"Transcript turns",value:String(t.transcriptTurnCount)},{label:"Matched turns",value:String(t.matchingTranscriptTurnCount)},{label:"Tools",value:String(t.toolNames.length)},{label:"Emails",value:String(t.emails.length)}]}),t.outputDir||t.outputDirRelative?(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] 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:"Output folder"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:t.outputDirRelative||t.outputDir||"Output folder",className:"text-[12.5px] leading-5 text-slate-100",filePath:t.outputDir,displayPath:t.outputDirRelative||t.outputDir,basePath:a})}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-slate-400",children:t.outputDirExists?`${t.outputFileCount} file${1===t.outputFileCount?"":"s"} detected in the folder.`:"The output folder is not currently accessible."})]}):null,(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:["Final response ","none"!==t.finalResponseSource?`(${t.finalResponseSource})`:""]}),o?(0,s.jsx)("p",{className:"mt-2 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:o.detail}):null,(0,s.jsx)("div",{className:"mt-2",children:t.finalResponseText?(0,s.jsx)(q.G,{text:t.finalResponseText,className:"text-[12.5px] leading-5 text-slate-100",basePath:a}):(0,s.jsx)("p",{className:"text-[12.5px] leading-5 text-slate-400",children:"No final response was captured."})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Recovered tools"}),t.toolNames.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.toolNames.map(e=>(0,s.jsx)(Z,{variant:"muted",children:e},e))}):(0,s.jsx)("p",{children:"No tool calls were recovered from a matching transcript turn."})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Detected emails"}),t.emails.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.emails.map(e=>(0,s.jsx)(Z,{variant:"muted",children:e},e))}):(0,s.jsx)("p",{children:"No email addresses were detected in the captured result."})]}),t.dispatchSessionId?(0,s.jsxs)("p",{className:"font-mono text-xs text-slate-400",children:["session ",(0,k.m_)(t.dispatchSessionId,12),t.sessionMismatch?" \xb7 mismatch detected":""]}):null,t.issues.length>0?(0,s.jsxs)("div",{className:"rounded-[14px] border border-amber-400/16 bg-amber-400/[0.06] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-amber-100/80",children:"Review issues"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(eO,{items:t.issues.map(e=>`${e.title}: ${e.detail}`),emptyLabel:"No integrity issues detected."})})]}):null]})}function en({task:e,onAbortTask:t,onControlComplete:a}){var r;let[n,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(""),[d,p]=(0,i.useState)(null),u=ev(r=e)||r.liveRunCount>0,m=!!t&&ev(e),h=o.trim();if(!u)return null;let x=e=>{l(t=>t===e?null:e),c("")},g=async()=>{if(n&&h&&!d){p(n);try{let s=await fetch(`/api/tasks/${encodeURIComponent(e.id)}/control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:n,message:h,dispatchId:e.dispatchId??null})}),r=await s.json().catch(()=>null);if(!s.ok){var t;throw Error(((t=r)&&"object"==typeof t?"string"==typeof t.error?t.error:"string"==typeof t.message?t.message:null:null)||"Unable to update the running task.")}B.oR.success("steer"===n?"Steer request sent.":"Context added to session."),l(null),c(""),a?.()}catch(e){B.oR.error("steer"===n?"Steer request failed.":"Context injection failed.",{description:e instanceof Error?e.message:"Unknown control error."})}finally{p(null)}}};return(0,s.jsxs)("div",{className:"rounded-[14px] border border-cyan-300/12 bg-cyan-400/[0.05] p-2.5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(v.$,{type:"button",variant:"destructive",size:"sm",disabled:!m,className:"h-8 gap-1.5 rounded-[10px] px-2.5 text-[11px]",onClick:()=>{m&&t?.(e)},children:[(0,s.jsx)(W.A,{className:"h-3.5 w-3.5"}),"Stop"]}),(0,s.jsxs)(v.$,{type:"button",variant:"steer"===n?"default":"secondary",size:"sm",className:"h-8 gap-1.5 rounded-[10px] px-2.5 text-[11px]",onClick:()=>x("steer"),children:[(0,s.jsx)(F.A,{className:"h-3.5 w-3.5"}),"Steer"]}),(0,s.jsxs)(v.$,{type:"button",variant:"inject"===n?"default":"secondary",size:"sm",className:"h-8 gap-1.5 rounded-[10px] px-2.5 text-[11px]",onClick:()=>x("inject"),children:[(0,s.jsx)(P.A,{className:"h-3.5 w-3.5"}),"Add context"]})]}),n?(0,s.jsxs)("div",{className:"mt-2.5 space-y-2",children:[(0,s.jsx)(y.T,{value:o,disabled:!!d,rows:3,maxLength:4e3,placeholder:"steer"===n?"Focus on tests":"Inject this note/reference into the running session",className:"min-h-[76px] rounded-[12px] px-3 py-2 text-[12px] leading-5",onChange:e=>c(e.target.value)}),"steer"===n?(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:Y.map(e=>(0,s.jsx)("button",{type:"button",disabled:!!d,className:"rounded-full border border-white/[0.08] bg-white/[0.04] px-2 py-1 text-[10px] text-slate-300 transition-colors hover:border-cyan-300/25 hover:text-cyan-50 disabled:cursor-not-allowed disabled:opacity-60",onClick:()=>c(e),children:e},e))}):null,(0,s.jsxs)("div",{className:"flex flex-wrap justify-end gap-2",children:[(0,s.jsx)(v.$,{type:"button",variant:"ghost",size:"sm",disabled:!!d,className:"h-8 rounded-[10px] px-2.5 text-[11px]",onClick:()=>{l(null),c("")},children:"Cancel"}),(0,s.jsx)(v.$,{type:"button",variant:"default",size:"sm",disabled:!h||!!d,className:"h-8 rounded-[10px] px-2.5 text-[11px]",onClick:()=>void g(),children:d?"Sending...":"steer"===n?"Send steer":"Add context"})]})]}):null]})}function ei({task:e,basePath:t,taskDetail:a,taskDetailLoading:r,taskDetailError:n,onAbortTask:i,onControlComplete:l}){if(r&&!a)return(0,s.jsxs)(eA,{icon:_.A,title:"Live feed",value:"connecting",children:[(0,s.jsx)(en,{task:e,onAbortTask:i,onControlComplete:l}),(0,s.jsx)("p",{children:"Connecting to the task feed…"})]});if(n&&!a)return(0,s.jsxs)(eA,{icon:_.A,title:"Live feed",value:"error",children:[(0,s.jsx)(en,{task:e,onAbortTask:i,onControlComplete:l}),(0,s.jsx)("p",{children:n})]});let o=(function(...e){let t=new Map;for(let a of e.flat())t.set(a.id,a);return[...t.values()].sort((e,t)=>Date.parse(e.timestamp)-Date.parse(t.timestamp))})(a?.liveFeed??[],ep(e.metadata.reviewEvents)).filter(e=>!eb(e)),c=a?.integrity??ed(e);return(0,s.jsxs)(eA,{icon:_.A,title:"Live feed",value:String(o.length),children:[(0,s.jsx)(en,{task:a?.task??e,onAbortTask:i,onControlComplete:l}),n?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:n}):null,c.issues.length>0?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:c.issues[0]?.detail}):null,0===o.length?(0,s.jsx)("p",{children:"No streamed task events have arrived yet."}):null,(0,s.jsx)("div",{className:"space-y-2",children:o.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 min-w-0 items-center gap-2",children:[(0,s.jsx)(Z,{variant:eD(e.kind,e.isError),children:e.kind}),(0,s.jsx)("p",{className:"truncate text-[12px] text-white",children:e.title})]}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:(0,k.fw)(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:e.detail,className:"text-[12.5px] leading-5 text-slate-100",url:e.url,filePath:e.filePath,displayPath:e.displayPath,basePath:t})})]},e.id))})]})}function el({snapshot:e,task:t,taskDetail:a}){let r=a?.runs??e.runtimes.filter(e=>t.runtimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),n=a?.createdFiles??e_(r.flatMap(e=>eP(e))),i=a?.integrity??ed(t),l=eo(e,t,r);return(0,s.jsxs)(eA,{icon:E.A,title:"Files",value:String(n.length),children:[(0,s.jsxs)("p",{children:[r.length," run",1===r.length?"":"s"," contributed to this task."]}),i.outputDir||i.outputDirRelative?(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] 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:"Output folder"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:i.outputDirRelative||i.outputDir||"Output folder",className:"text-[12.5px] leading-5 text-slate-100",filePath:i.outputDir,displayPath:i.outputDirRelative||i.outputDir,basePath:l})}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-slate-400",children:i.outputDirExists?`${i.outputFileCount} file${1===i.outputFileCount?"":"s"} detected in the folder.`:"The output folder is not currently accessible."})]}):null,(0,s.jsx)(e$,{files:n,basePath:l,emptyLabel:"This task has not produced a detectable file artifact yet."})]})}function eo(e,t,a=[]){return ec(e,t,a)?.path??function(e,t,a=[]){for(let s of[t.primaryAgentId,...a.map(e=>e.agentId)].filter(e=>"string"==typeof e&&e.trim().length>0)){let t=e.agents.find(e=>e.id===s)?.workspacePath;if(t)return t}}(e,t,a)}function ec(e,t,a=[]){for(let s of[t.workspaceId,...a.map(e=>e.workspaceId),t.primaryAgentId?e.agents.find(e=>e.id===t.primaryAgentId)?.workspaceId:void 0,...a.map(t=>t.agentId?e.agents.find(e=>e.id===t.agentId)?.workspaceId:void 0)].filter(e=>"string"==typeof e&&e.trim().length>0)){let t=e.workspaces.find(e=>e.id===s);if(t)return t}return null}function ed(e){var t,a;let s,r,n,i=!!e.metadata.optimistic&&!ew(e)&&"stalled"!==e.status,l=(s="string"==typeof(t=e).metadata.finalResponseText?t.metadata.finalResponseText.trim():"",r="string"==typeof t.metadata.resultPreview?t.metadata.resultPreview.trim():"",!!((n=s||r)&&!(ef(a=n)||/waiting for (the first )?(transcript|output)/i.test(a)||/working silently/i.test(a)))),o=ew(e)?[{id:"task-cancelled",severity:"warning",title:"Task was cancelled by the operator",detail:"The mission dispatch was stopped before completion, so the captured evidence is intentionally incomplete."}]:"stalled"===e.status?[{id:l?"partial-final-response":"stalled-dispatch",severity:"warning",title:l?"Final response came from an incomplete runtime":"Waiting for output evidence",detail:l?"The assistant produced output, but the runtime stalled before the task completed. Treat this as the last captured response, not a verified completion.":ef(e.subtitle)?"AgentOS is still waiting for the first transcript entry from this runtime.":e.subtitle}]:[];return{status:o.some(e=>"error"===e.severity)?"error":i||o.length>0?"warning":"verified",outputDir:"string"==typeof e.metadata.outputDir&&e.metadata.outputDir.trim().length>0?e.metadata.outputDir:null,outputDirRelative:"string"==typeof e.metadata.outputDirRelative&&e.metadata.outputDirRelative.trim().length>0?e.metadata.outputDirRelative:null,outputDirExists:!1,outputFileCount:0,transcriptTurnCount:0,matchingTranscriptTurnCount:0,finalResponseText:l?em(e):null,finalResponseSource:"none",dispatchSessionId:null,sessionMismatch:!1,toolNames:[],emails:[],issues:o}}function ep(e){return Array.isArray(e)?e.filter(eg):[]}function eu(e){return e.mission?.trim()||e.title.trim()||"Untitled task"}function em(e){return("string"==typeof e.metadata.resultPreview?e.metadata.resultPreview.trim():"")||e.subtitle.trim()||""}function eh(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function ex(e){return e.replace(/\s+/g," ").trim()}function eg(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.kind&&"string"==typeof e.timestamp&&"string"==typeof e.title&&"string"==typeof e.detail}function eb(e){return e.id.startsWith("runner-log:")}function ef(e){return"string"==typeof e&&(/No transcript file was found for this runtime session/i.test(e)||/No transcript entries were found for this runtime/i.test(e))}function ew(e){let t="string"==typeof e.metadata.dispatchStatus?e.metadata.dispatchStatus:null,a=e.status;return"cancelled"===t||"aborted"===t||"cancelled"===a||"aborted"===a}function ev(e){if(ew(e))return!1;let t=e.status;return"running"===t||"queued"===t}function ey({snapshot:e,runtimeId:t,runtimeOutput:a,runtimeOutputLoading:r,runtimeOutputError:n}){let i,l=(0,k.hv)(e.generatedAt),o=e.runtimes.find(e=>e.id===t),c=e_(a?.createdFiles??(o?eP(o):[])),d=a?.warnings??(o&&Array.isArray(i=o.metadata.warnings)?i.filter(e=>"string"==typeof e&&e.trim().length>0):[]),p=a?.warningSummary??d[0]??null,u=o?e.workspaces.find(e=>e.id===o.workspaceId)?.path:void 0;return o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:_.A,title:"Runtime key",value:o.status,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:o.key}),(0,s.jsxs)("p",{children:["Session ",(0,k.m_)(o.sessionId,12)]}),o.taskId?(0,s.jsxs)("p",{children:["Task ",(0,k.m_)(o.taskId,12)]}):null,o.runId?(0,s.jsxs)("p",{children:["Run ",(0,k.m_)(o.runId,12)]}):null]}),(0,s.jsxs)(eA,{icon:L.A,title:"Activity",value:(0,k.fw)(o.updatedAt,l),children:[(0,s.jsx)("p",{children:o.subtitle}),(0,s.jsxs)("p",{children:[(0,k._y)(o.tokenUsage?.total)," tokens"]})]}),(0,s.jsxs)(eA,{icon:U.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)(q.G,{text:a?.finalText||a?.errorMessage||"No assistant output has been recorded for this runtime yet.",className:"text-[13px] leading-5 text-slate-100",basePath:u}),p?(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: ",p]}):null,a?.finalTimestamp?(0,s.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:["Updated ",(0,k.fw)(new Date(a.finalTimestamp).getTime())]}):null]}),(0,s.jsx)(eA,{icon:E.A,title:"Created files",value:String(c.length),children:(0,s.jsx)(e$,{files:c,basePath:e.workspaces.find(e=>e.id===o.workspaceId)?.path,emptyLabel:"This runtime has not produced a detectable file artifact."})})]}):null}function ej({runtime:e,runtimeOutput:t}){let a=e_(t?.createdFiles??eP(e));return(0,s.jsxs)(eA,{icon:E.A,title:"Files",value:String(a.length),children:[(0,s.jsx)("p",{children:e.title}),(0,s.jsx)(e$,{files:a,emptyLabel:"This runtime has not produced a detectable file artifact."})]})}function ek({runtime:e,basePath:t,runtimeOutput:a,runtimeOutputLoading:r,runtimeOutputError:n}){return r?(0,s.jsx)(eA,{icon:_.A,title:"Runtime output",value:"loading",children:(0,s.jsxs)("p",{children:["Loading transcript output for ",e.title,"…"]})}):n?(0,s.jsx)(eA,{icon:_.A,title:"Runtime output",value:"error",children:(0,s.jsx)("p",{children:n})}):a?(0,s.jsxs)("div",{className:"space-y-3.5",children:[a.warningSummary?(0,s.jsx)(eA,{icon:L.A,title:"Warnings",value:String(a.warnings.length),children:(0,s.jsx)("p",{children:a.warningSummary})}):null,(0,s.jsx)(eA,{icon:E.A,title:"Created files",value:String(a.createdFiles.length),children:(0,s.jsx)(e$,{files:a.createdFiles,basePath:t,emptyLabel:"This runtime transcript does not include a successful file creation."})}),(0,s.jsxs)(eA,{icon:_.A,title:"Final response",value:"stalled"===e.status||"cancelled"===e.status?"stalled"===e.status?"waiting output":e.status:a.stopReason||a.status,children:["stalled"===e.status||"cancelled"===e.status?(0,s.jsx)("p",{className:"mb-2 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:"stalled"===e.status?"This runtime is quiet or waiting for transcript output. AgentOS will keep watching for the first assistant update.":"This runtime was cancelled. The text below is the last captured assistant output, not a verified completion."}):null,a.errorMessage&&!ef(a.errorMessage)?(0,s.jsx)("p",{className:"mb-2 rounded-[12px] border border-rose-400/20 bg-rose-400/10 px-3 py-2 text-[12px] leading-5 text-rose-100",children:a.errorMessage}):null,(0,s.jsx)(q.G,{text:a.finalText||(a.errorMessage&&!ef(a.errorMessage)?a.errorMessage:"Waiting for the first assistant output from this runtime."),className:"text-[13px] leading-5 text-slate-100",basePath:t}),a.finalTimestamp?(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:new Date(a.finalTimestamp).toLocaleString()}):null]}),(0,s.jsxs)(eA,{icon:L.A,title:"Transcript trail",value:String(a.items.length),children:[0===a.items.length?(0,s.jsx)("p",{children:"Waiting for the first transcript entry."}):null,(0,s.jsx)("div",{className:"space-y-2",children:a.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)(Z,{variant:"assistant"===e.role?e.isError?"danger":"default":"toolResult"===e.role?"warning":"muted",children:e.role}),e.toolName?(0,s.jsx)(Z,{variant:"muted",children:e.toolName}):null]}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:(0,k.fw)(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:e.text,className:"text-[12.5px] leading-5 text-slate-100",basePath:t})})]},e.id))})]})]}):(0,s.jsx)(eA,{icon:_.A,title:"Runtime output",value:"missing",children:(0,s.jsx)("p",{children:"No transcript data is available for this runtime."})})}function eN({snapshot:e,modelId:t}){let a=e.models.find(e=>e.id===t);return a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eA,{icon:U.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)(eA,{icon:L.A,title:"Capacity",value:`${(0,k.FO)(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 eC({icon:e,label:t,active:a,surfaceTheme:r,panelCollapsed:n,tooltipSide:i,disabled:l=!1,onClick:o}){return(0,s.jsx)(V.A,{label:t,side:i,surfaceTheme:r,panelCollapsed:n,children:(0,s.jsx)("button",{type:"button","aria-label":t,"aria-disabled":l,tabIndex:l?-1:0,onClick:o,className:(0,N.cn)("inline-flex h-8 w-8 items-center justify-center rounded-[8px] border transition-all",l?"border-white/5 bg-white/[0.02] text-slate-600":a?"border-cyan-300/18 bg-cyan-400 text-slate-950 shadow-[0_10px_22px_rgba(96,165,250,0.28)]":"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-3 w-3"})})})}function eS({label:e,active:t,onClick:a}){return(0,s.jsx)("button",{type:"button",onClick:a,className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-1.5 text-[10px] uppercase tracking-[0.14em] whitespace-nowrap 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 eA({icon:e,title:t,value:a,actions:r,children:n,className:i}){return(0,s.jsxs)("section",{className:(0,N.cn)("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 transition-all",i),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.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:"min-w-0 font-display text-[1rem] text-white",children:a}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})]}),(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:n})]})}function eT({label:e,text:t,basePath:a,subtle:r=!1}){return(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] 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:e}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(q.G,{text:t,className:(0,N.cn)("text-[12.5px] leading-5",r?"text-slate-400":"text-slate-100"),basePath:a})})]})}function e$({files:e,basePath:t,emptyLabel:a}){return 0===e.length?(0,s.jsx)("p",{className:"text-[12px] text-slate-400",children:a}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>{var a;let r=(a=e.path).startsWith("/")||/^[A-Za-z]:[\\/]/.test(a)||!!t;return(0,s.jsx)("button",{type:"button",disabled:!r,onClick:()=>void eE(e.path,t),className:(0,N.cn)("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",r?"hover:border-cyan-300/28 hover:bg-cyan-400/[0.08]":"cursor-not-allowed opacity-60"),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:(0,k.$7)(e.path)})]}),(0,s.jsx)(Z,{variant:"muted",children:r?"reveal":"relative"})]})},e.path)})})}function eM({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 eI({items:e,missingVariant:t="muted"}){return(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(Z,{variant:e.present?"success":t,children:e.label},e.id))})}function eR({items:e,emptyLabel:t,itemVariant:a,emptyVariant:r}){return 0===e.length?(0,s.jsx)(Z,{variant:r,children:t}):(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(Z,{variant:a,children:e},e))})}function eO({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 eP(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 e_(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}function eD(e,t){if(t)return"danger";switch(e){case"assistant":return"default";case"tool":case"warning":return"warning";case"artifact":return"success";default:return"muted"}}async function eE(e,t){try{let a=await fetch("/api/files/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,basePath:t??null})}),s=await a.json();if(!a.ok)throw Error(s.error||"Unable to reveal file.");B.oR.success("Revealed file.",{description:(0,k.$7)(e)})}catch(e){B.oR.error("Could not reveal file.",{description:e instanceof Error?e.message:"Unknown file reveal error."})}}var eL=a(33494),eU=a(15054),eF=a(64248),ez=a(3342),eW=a(58386);function eB({snapshot:e,surfaceTheme:t,isInspectorOpen:a,taskAbortRequest:r,taskAbortRunState:n,taskAbortMessage:l,onTaskAbortOpenChange:o,onTaskAbortConfirm:c,updateDialogOpen:p,updateRunState:u,updateStatusMessage:m,updateResultMessage:h,updateLog:x,updateManualCommand:g,activeRuntimeCount:b,updateInstallSummary:f,onUpdateDialogOpenChange:w,onRunOpenClawUpdate:y}){let j="running"===u,k="success"===u||"error"===u,C=(0,ez.Ku)(u),S=(0,ez.SG)(u),[A,T]=(0,i.useState)(!1),$=(0,eW.T)(g),M=async()=>{if(g)try{await navigator.clipboard.writeText(g),B.oR.success("Command copied.",{description:"Open Terminal and paste it."})}catch(e){B.oR.error("Could not copy command.",{description:e instanceof Error?e.message:"Clipboard access is unavailable."})}},I=async()=>{if(g&&$){T(!0);try{let e=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:g})}),t=await e.json().catch(()=>null);if(!e.ok||t?.error)throw Error(t?.error||"Unable to open Terminal.");B.oR.success("Terminal opened.",{description:"Confirm the update there, then return to AgentOS."})}catch(e){B.oR.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command."})}finally{T(!1)}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eF.lG,{open:null!==r,onOpenChange:e=>{"running"!==n&&o(e)},children:(0,s.jsxs)(eF.Cf,{className:(0,N.cn)("max-w-[480px] gap-5 p-5 sm:p-6","light"===t?"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)(eF.c7,{children:[(0,s.jsx)(eF.L3,{className:"light"===t?"text-[#3f2f24]":"text-white",children:"Abort task?"}),(0,s.jsx)(eF.rr,{className:"light"===t?"text-[#7e6555]":"text-slate-400",children:"This stops the current OpenClaw dispatch for the selected task. It does not delete captured evidence or files."})]}),r?(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border px-4 py-4","light"===t?"border-[#e3d4c8] bg-[#fffaf6] text-[#4f3d31]":"border-rose-400/20 bg-rose-400/10 text-rose-50"),children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-slate-500",children:"Selected task"}),(0,s.jsx)("p",{className:"mt-2 font-display text-[1.02rem] leading-6 text-inherit",children:r.title}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-sm leading-6","light"===t?"text-[#8b7262]":"text-rose-100/80"),children:r.subtitle}),l?(0,s.jsx)("p",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/10 px-3 py-2 text-sm text-rose-50",children:l}):null]}):null,(0,s.jsxs)(eF.Es,{children:[(0,s.jsx)(v.$,{type:"button",variant:"secondary",disabled:"running"===n,className:"light"===t?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",onClick:()=>{"running"!==n&&o(!1)},children:"Cancel"}),(0,s.jsx)(v.$,{type:"button",variant:"destructive",disabled:!r||"running"===n,onClick:()=>{c()},children:"running"===n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Aborting..."]}):"Abort task"})]})]})}),a?null:(0,s.jsxs)("div",{className:(0,N.cn)("pointer-events-auto absolute bottom-3 right-[74px] z-30 text-[11px] tracking-[0.04em] lg:bottom-4","light"===t?"text-[#8f7664]":"text-slate-500"),children:["Built on"," ",(0,s.jsx)("a",{href:"https://openclaw.ai/",target:"_blank",rel:"noreferrer",className:(0,N.cn)("transition-colors","light"===t?"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:(0,N.cn)("transition-colors","light"===t?"text-[#6f5a4b] hover:text-[#4f3d31]":"text-slate-300 hover:text-slate-100"),children:"SapienX"})]}),(0,s.jsx)(eF.lG,{open:p,onOpenChange:e=>{j||w(e)},children:(0,s.jsxs)(eF.Cf,{className:(0,N.cn)("max-h-[calc(100vh-48px)] max-w-[468px] gap-5 overflow-y-auto p-5 sm:p-6","light"===t?"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)(eF.c7,{children:[(0,s.jsx)(eF.L3,{className:"light"===t?"text-[#3f2f24]":"text-white",children:C}),(0,s.jsx)(eF.rr,{className:"light"===t?"text-[#7e6555]":"text-slate-400",children:S})]}),k?(0,s.jsxs)("div",{className:(0,N.cn)("space-y-4","light"===t?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[24px] border px-4 py-5",(0,ez.CP)(u,t)),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:(0,N.cn)("flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border",(0,ez.to)(u,t)),children:"success"===u?(0,s.jsx)(eL.A,{className:"h-5 w-5"}):(0,s.jsx)(W.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"===u?"OpenClaw is up to date":"Update needs attention"}),(0,s.jsx)("p",{className:"mt-1 text-sm leading-6",children:h||("success"===u?"The update finished successfully.":"The update did not finish cleanly.")})]})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3","light"===t?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===t?"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",e.diagnostics.version||e.diagnostics.latestVersion||"unknown"]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3","light"===t?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===t?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Latest reported"}),(0,s.jsxs)("p",{className:"mt-2 font-display text-lg text-inherit",children:["v",e.diagnostics.latestVersion||e.diagnostics.version||"unknown"]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3","light"===t?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===t?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Detected install"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium text-inherit",children:f.label}),(0,s.jsx)("p",{className:"light"===t?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:f.detail})]})]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border","light"===t?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between border-b px-4 py-3","light"===t?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Update log"}),(0,s.jsx)("span",{className:"light"===t?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:"success"===u?"Completed":"Failed"})]}),(0,s.jsx)("pre",{className:(0,N.cn)("max-h-[180px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===t?"text-[#4f3d31]":"text-slate-200"),children:x||"No command output was captured."})]}),g?(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border px-4 py-3","light"===t?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:$?"Terminal":"Manual"}),$?(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-sm leading-6","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Open Terminal and run this command to confirm the update."}):null,(0,s.jsx)("p",{className:(0,N.cn)("mt-2 break-all font-mono text-[11px] leading-5","light"===t?"text-[#4f3d31]":"text-slate-200"),children:g}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{M()},className:"light"===t?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",children:[(0,s.jsx)(eU.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),$?(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{I()},disabled:A,className:"light"===t?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null]})]}):null]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,N.cn)("grid gap-3 sm:grid-cols-2","light"===t?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border px-4 py-4","light"===t?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]","light"===t?"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",e.diagnostics.latestVersion||e.diagnostics.version||"unknown"]}),(0,s.jsxs)("p",{className:"light"===t?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:["Current: v",e.diagnostics.version||"unknown"]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border px-4 py-4","light"===t?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Detected install"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium leading-6 text-inherit",children:f.label}),(0,s.jsx)("p",{className:"light"===t?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:f.detail})]})]}),(0,s.jsx)("div",{className:(0,N.cn)("rounded-[20px] border px-4 py-3 text-sm",b>0?"light"===t?"border-rose-300/80 bg-rose-50 text-rose-800":"border-rose-300/25 bg-rose-300/10 text-rose-100":"light"===t?"border-[#e3d4c8] bg-[#fffaf6] text-[#745e4f]":"border-white/8 bg-white/[0.03] text-slate-300"),children:b>0?`${b} running or queued runtime${1===b?"":"s"} may be interrupted during the update.`:"No running runtimes are currently tracked, so the update risk is lower."}),j?(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border","light"===t?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center gap-3 border-b px-4 py-3","light"===t?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("div",{className:(0,N.cn)("flex h-9 w-9 items-center justify-center rounded-2xl border","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#7b6453]":"border-white/10 bg-white/[0.05] text-slate-200"),children:(0,s.jsx)(d.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"===t?"text-sm font-medium text-[#4a382c]":"text-sm font-medium text-white",children:"Update in progress"}),(0,s.jsx)("p",{className:"light"===t?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:m||"Streaming OpenClaw output..."})]})]}),(0,s.jsx)("pre",{className:(0,N.cn)("max-h-[180px] min-h-[120px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===t?"text-[#4f3d31]":"text-slate-200"),children:x||"Waiting for command output..."})]}):null]}),(0,s.jsxs)(eF.Es,{children:[(0,s.jsx)(v.$,{type:"button",variant:"secondary",onClick:()=>{w(!1)},className:"light"===t?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",children:j?"Run in background":k?"Done":"Cancel"}),k?null:(0,s.jsx)(v.$,{type:"button",onClick:y,disabled:j,className:(0,N.cn)(e.diagnostics.updateAvailable?"bg-amber-400 text-slate-950 shadow-lg shadow-amber-400/20 hover:bg-amber-300":"","light"!==t||e.diagnostics.updateAvailable?"":"bg-[#c8946f] text-white shadow-[0_12px_28px_rgba(200,148,111,0.24)] hover:bg-[#b88461]"),children:j?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating..."]}):"Update now"})]})]})})]})}var eG=a(82625),eq=a(22662),eV=a(34927),eK=a(38111),eJ=a(23169);function eH(e,t){return t?e:"system"}function eY(e,t,a,s,r,n,i,l){return"cli"===e?!l&&t.diagnostics.installed?`Installed${t.diagnostics.version?` \xb7 v${t.diagnostics.version}`:""}`:"installing-cli"===a?"Installing the CLI and local wrapper.":"detecting"===a||l||!t.diagnostics.installed?"Checking whether the CLI is already installed.":"Install the OpenClaw CLI.":"gateway"===e?!l&&t.diagnostics.loaded?"Gateway is already registered.":"installing-gateway"===a?"Registering the gateway service.":"starting-gateway"===a?"Starting the gateway service.":"detecting"===a&&s?"Checking gateway registration.":n||"verifying"===a?"Gateway is up and waiting on RPC.":!l&&t.diagnostics.rpcOk?"Gateway is running directly.":"Register the gateway service once.":i?"RPC, state, and session store are ready.":"verifying"===a?"Verifying RPC, state writes, and session store access.":"starting-gateway"===a?"Starting the gateway and waiting for RPC.":r?"Gateway is up; verify RPC and runtime state.":n?"RPC is online; final runtime checks continue.":"Start the gateway and verify RPC."}function eZ(e,t){if(!e.trim())return null;let a=t.find(t=>t.id===e);return a?.name||(0,k.JZ)(e)}function eQ(e,t){return e?"complete":t?"current":"pending"}function eX(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 e0(e){let t=e.trim().toLowerCase();return"openrouter"===t?"OpenRouter":"openai-codex"===t?"ChatGPT":"openai"===t?"OpenAI":"anthropic"===t?"Anthropic":"ollama"===t?"Ollama":"xai"===t?"xAI":"google"===t||"gemini"===t?"Gemini":"deepseek"===t?"DeepSeek":"mistral"===t?"Mistral":e.split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):e).join(" ")}function e1(e){let t=e?.trim();if(!t)return null;let[a]=t.split("/",1);return a||null}function e2(e,t){let a=e1(t);return a?"openai"===a&&e5(e)?"openai-codex":(0,eJ.a3)(a)?a:null:null}function e5(e){let t=e.diagnostics.modelReadiness.authProviders,a=t.find(e=>"openai-codex"===e.provider),s=t.find(e=>"openai"===e.provider);return!!a?.connected||"openai-codex"===e.diagnostics.modelReadiness.preferredLoginProvider||!!(a?.canLogin&&!s?.connected)}function e3(e){let t=e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||null;if(t&&e.diagnostics.modelReadiness.defaultModelReady)return t;let a=e.diagnostics.modelReadiness.recommendedModelId||null;return a&&e.workspaces.length>0?a:null}function e4(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 e8(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 e6(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 e7=a(95372),e9=a(86247),te=a(66342),tt=a(85844),ta=a(14766);function ts({snapshot:e,selectedModelId:t,onSelectedModelIdChange:a,onOpenAddModels:r,autoDiscover:l=!0}){let[o,c]=(0,i.useState)(()=>(function(e,t){let a=e2(e,t);if(a)return a;let s=e.diagnostics.modelReadiness.authProviders.find(e=>e.connected&&(0,eJ.a3)(e.provider))?.provider;if(s)return s;let r=e.diagnostics.modelReadiness.preferredLoginProvider;if((0,eJ.a3)(r))return r;let n=e1(e.diagnostics.modelReadiness.recommendedModelId);return(0,eJ.a3)(n)?n:"openrouter"})(e,t)),[p,u]=(0,i.useState)({}),[m,h]=(0,i.useState)(!1),x=(0,i.useMemo)(()=>Object.values(p).flatMap(e=>e?.models??[]),[p]),g=(0,i.useMemo)(()=>(function(e,t,a=[]){let s=t?.trim();if(!s)return null;let r=a.find(e=>e.id===s&&(0,eJ.a3)(e.provider))?.provider;if((0,eJ.a3)(r))return r;let n=e.models.find(e=>e.id===s&&(0,eJ.a3)(e.provider))?.provider;return(0,eJ.a3)(n)?"openai"===n&&e5(e)?"openai-codex":n:e2(e,s)})(e,t,x),[x,t,e]);(0,i.useEffect)(()=>{g&&c(e=>e===g?e:g)},[g]),(0,i.useEffect)(()=>{M(o)},[o]);let b=(0,eJ.W2)(o),f=tn(p[o]),w=f.connection??ti(e,o),y=(0,i.useMemo)(()=>e.models.filter(e=>tl(o,e.id,e.provider)&&!1!==e.available&&!e.missing).map(t=>({id:t.id,name:t.name,provider:t.provider,input:t.input,contextWindow:t.contextWindow,local:!!t.local,available:!1!==t.available,missing:t.missing,alreadyAdded:!0,recommended:t.id===e.diagnostics.modelReadiness.recommendedModelId||t.id===e.diagnostics.modelReadiness.resolvedDefaultModel||t.id===e.diagnostics.modelReadiness.defaultModel,supportsTools:t.tags.includes("tools"),isFree:t.tags.includes("free"),tags:t.tags})),[o,e.diagnostics.modelReadiness.defaultModel,e.diagnostics.modelReadiness.recommendedModelId,e.diagnostics.modelReadiness.resolvedDefaultModel,e.models]),k=f.models.length>0?f.models:y,C=(0,i.useMemo)(()=>{let e=f.search.trim().toLowerCase();return k.slice().sort((e,t)=>{let a=Number(t.recommended)+Number(t.isFree)+Number(t.supportsTools),s=Number(e.recommended)+Number(e.isFree)+Number(e.supportsTools);return a!==s?a-s:e.name.localeCompare(t.name)}).filter(t=>!e||`${t.name} ${t.id} ${t.tags.join(" ")}`.toLowerCase().includes(e))},[k,f.search]),S=e.models.find(e=>e.id===t)?.name||C.find(e=>e.id===t)?.name||t.trim()||null,A="connecting"===f.flowState||"discovering"===f.flowState||f.statusMessage?.startsWith("Checking ")===!0&&!w.connected,T="discovering"===f.flowState?`Discovering ${b.shortLabel} models...`:"connecting"===f.flowState?f.statusMessage||`Connecting ${b.shortLabel}...`:f.statusMessage||`Checking ${b.shortLabel}...`,$=C.length>6||!!b.searchPlaceholder;async function M(e){let t=tn(p[e]);t.loaded&&t.connection||await O(e)}function I(e,t){u(a=>({...a,[e]:{...tn(a[e]),...t}}))}function R(e,t,a,s){I(e,{flowState:a,connection:t.connection,statusMessage:t.message,errorMessage:null,emptyState:t.emptyState??null,manualCommand:t.manualCommand??null,docsUrl:t.docsUrl??null,models:t.models,loaded:!0,...s})}async function O(e){let t=(0,ta.oZ)(e);I(e,{flowState:"idle",errorMessage:null,statusMessage:`Checking ${e0(e)}...`});try{let a=await t.getConnectionStatus(),s=a.connection.connected&&l&&!E(e);R(e,a,s?"discovering":"idle"),s&&await D(e,!0)}catch(t){I(e,{flowState:"error",errorMessage:t instanceof Error?t.message:"Provider status could not be loaded.",loaded:!0})}}async function P(e){let t=(0,ta.oZ)(e),a=tn(p[e]);I(e,{flowState:"connecting",errorMessage:null,statusMessage:"openai-codex"===e?"Opening the ChatGPT sign-in flow...":`Connecting ${(0,eJ.W2)(e).shortLabel}...`});try{let s=await t.connect({apiKey:a.apiKey}),r=s.connection.connected&&!s.manualCommand&&!E(e);R(e,s,r?"discovering":"idle",{apiKey:s.manualCommand?a.apiKey:""}),r&&await D(e,!0)}catch(t){I(e,{flowState:"error",errorMessage:t instanceof Error?t.message:"Provider connection failed."})}}async function D(e,t=!1){let a=(0,ta.oZ)(e),s=tn(p[e]);if(t||"discovering"!==s.flowState){I(e,{flowState:"discovering",errorMessage:null,statusMessage:"ollama"===e?"Checking the local Ollama runtime...":`Discovering ${(0,eJ.W2)(e).shortLabel} models...`});try{let t=await a.discoverModels();R(e,t,t.models.length>0?"ready":"idle",{search:s.search})}catch(t){I(e,{flowState:"error",errorMessage:t instanceof Error?t.message:"Provider discovery failed."})}}}function E(t){return e.models.some(e=>tl(t,e.id,e.provider)&&!1!==e.available&&!e.missing)}async function L(e){try{await navigator.clipboard.writeText(e),j.o.success("Copied.",{description:"Command copied to your clipboard."})}catch(e){j.o.error("Copy failed.",{description:e instanceof Error?e.message:"Clipboard access is not available."})}}async function U(e){if(!(0,eW.T)(e))return void await L(e);h(!0);try{let t=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})}),a=await t.json().catch(()=>null);if(!t.ok||a?.error)throw Error(a?.error||"Unable to open Terminal.");j.o.success("Terminal opened.",{description:"Finish auth there, then refresh this provider."})}catch(e){j.o.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command."})}finally{h(!1)}}return(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[16px] border px-3 py-3","border-white/8 bg-[rgba(255,255,255,0.03)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("p",{className:"whitespace-nowrap text-[8px] font-medium text-slate-500",children:["Provider first : ",eJ.y8.length," providers"]})}),(0,s.jsx)("div",{className:"flex shrink-0 flex-wrap gap-1.5",children:S?(0,s.jsx)(J.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Selected"}):null})]}),(0,s.jsx)("div",{className:"mt-3 flex snap-x snap-mandatory flex-nowrap gap-2 overflow-x-auto overflow-y-hidden pb-2 pr-1",children:eJ.y8.map(t=>{let r=tn(p[t.id]).connection??ti(e,t.id);return(0,s.jsx)("div",{className:"w-[128px] shrink-0 snap-start sm:w-[136px]",children:(0,s.jsx)(te.I,{descriptor:t,active:o===t.id,compact:!0,micro:!0,connected:r.connected,detail:r.detail,onClick:()=>{c(t.id),g&&g!==t.id&&a("")}})},t.id)})}),(0,s.jsxs)("div",{className:"mt-3 rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{children:(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:b.label})}),(0,s.jsx)(J.E,{variant:w.connected?"success":"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:w.connected?"Connected":"Not connected"})]}),f.statusMessage&&!A?(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[11px] text-slate-200",children:f.statusMessage})}):null,f.errorMessage?(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/[0.08] px-3 py-2 text-[11px] text-rose-100",children:f.errorMessage}):null,"apiKey"!==b.connectKind||w.connected||A?null:(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-end gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{className:"block text-[9px] uppercase tracking-[0.16em] text-slate-500",children:"API key"}),(0,s.jsx)(tt.p,{type:"password",value:f.apiKey,onChange:e=>I(o,{apiKey:e.target.value}),placeholder:"openrouter"===o?"sk-or-v1-...":"Paste API key",className:"mt-1.5 h-8 text-[11px]"})]}),(0,s.jsx)(v.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===f.flowState||!f.apiKey.trim(),onClick:()=>{P(o)},children:"connecting"===f.flowState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]}):`Connect ${b.shortLabel}`})]}),A?(0,s.jsxs)("div",{className:"relative mt-4 flex min-h-[280px] items-center justify-center overflow-hidden rounded-[28px] border border-cyan-300/20 bg-[radial-gradient(circle_at_top,rgba(34,211,238,0.16),rgba(8,15,28,0.98)_70%)] px-4 py-10 text-center shadow-[0_22px_52px_rgba(7,11,20,0.32)]",children:[(0,s.jsx)("div",{className:"absolute inset-x-8 top-8 h-px bg-gradient-to-r from-transparent via-cyan-200/70 to-transparent blur-sm animate-pulse"}),(0,s.jsx)("div",{className:"absolute inset-x-8 bottom-8 h-px bg-gradient-to-r from-transparent via-cyan-200/30 to-transparent blur-sm animate-pulse [animation-delay:180ms]"}),(0,s.jsx)("div",{className:"absolute left-8 top-8 h-24 w-24 rounded-full border border-cyan-300/15 bg-cyan-300/[0.04] blur-[1px] animate-pulse"}),(0,s.jsx)("div",{className:"absolute right-10 top-14 h-16 w-16 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:120ms]"}),(0,s.jsx)("div",{className:"absolute bottom-10 left-1/2 h-20 w-20 -translate-x-1/2 rounded-full border border-cyan-300/10 bg-cyan-300/[0.03] blur-[1px] animate-pulse [animation-delay:240ms]"}),(0,s.jsxs)("div",{className:"relative flex max-w-[340px] flex-col items-center",children:[(0,s.jsx)("div",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-full border border-cyan-300/20 bg-cyan-300/[0.08] shadow-[0_0_0_8px_rgba(34,211,238,0.05)]",children:(0,s.jsx)(d.A,{className:"h-8 w-8 animate-spin text-cyan-200"})}),(0,s.jsx)("p",{className:"font-display text-[1.1rem] leading-[1.2rem] tracking-[0.01em] text-white",children:T}),(0,s.jsx)("p",{className:"mt-2 max-w-[280px] text-[11px] leading-[1rem] text-slate-400",children:"discovering"===f.flowState?"Pulling the provider catalog into AgentOS.":"connecting"===f.flowState?"Preparing the provider connection.":"Checking provider status before discovery."}),(0,s.jsxs)("div",{className:"mt-4 flex gap-1.5",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/90"}),(0,s.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/60 [animation-delay:120ms]"}),(0,s.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-cyan-300/30 [animation-delay:240ms]"})]})]})]}):null,"oauth"!==b.connectKind||w.connected||A?null:(0,s.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Connect your ChatGPT account"}),(0,s.jsx)("p",{className:"mt-1 max-w-[500px] text-[10px] leading-[0.98rem] text-slate-400",children:"This uses OpenClaw's account-based login flow. No API key is required."})]}),(0,s.jsx)(v.$,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===f.flowState&&!f.manualCommand,onClick:()=>{P(o)},children:"connecting"!==f.flowState||f.manualCommand?"Connect ChatGPT":(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]})})]}),f.manualCommand?(0,s.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish sign-in in Terminal"}),(0,s.jsx)("p",{className:"mt-1 max-w-[460px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, complete the provider login, then come back and refresh this provider."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:m,onClick:()=>{U(f.manualCommand||"")},children:m?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,s.jsxs)(v.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{L(f.manualCommand||"")},children:[(0,s.jsx)(eU.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,s.jsxs)(v.$,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{O(o)},children:[(0,s.jsx)(n.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,s.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,s.jsx)("code",{className:"text-[10px] text-slate-200",children:f.manualCommand})})]}):null]}),w.connected&&!A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-4 flex flex-nowrap items-center justify-between gap-2 overflow-x-auto pb-1",children:[(0,s.jsx)("p",{className:"shrink-0 whitespace-nowrap text-[9px] uppercase tracking-[0.16em] text-slate-500",children:C.length>0?`Found ${C.length} model${1===C.length?"":"s"}`:"No models found"}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap gap-1.5",children:[(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>{O(o)},className:"h-6 rounded-full px-2 text-[9px]",children:[(0,s.jsx)(n.A,{className:"mr-1 h-2.5 w-2.5"}),"Refresh"]}),(0,s.jsx)(v.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(o),className:"h-6 rounded-full px-2 text-[9px]",children:"Add Models"})]})]}),$?(0,s.jsxs)("div",{className:"relative mt-3",children:[(0,s.jsx)(e9.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,s.jsx)(tt.p,{value:f.search,onChange:e=>I(o,{search:e.target.value}),placeholder:b.searchPlaceholder??"Search models",className:"h-8 pl-8 text-[11px]"})]}):null,f.emptyState?(0,s.jsx)(tr,{emptyState:f.emptyState,onRefresh:()=>{O(o)}}):null,C.length>0?(0,s.jsx)("div",{className:"mt-3 max-h-[min(34vh,260px)] space-y-1 overflow-y-auto pr-1",children:C.map(e=>{let r=t===e.id;return(0,s.jsxs)("button",{type:"button",onClick:()=>{(0,eJ.a3)(e.provider)&&c(e.provider),a(e.id)},className:(0,N.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",r?"border-cyan-300/35 bg-cyan-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:e.name}),(0,s.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:e.id}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,s.jsx)("span",{children:e.input}),e.contextWindow?(0,s.jsxs)("span",{children:[Intl.NumberFormat().format(e.contextWindow)," ctx"]}):null,e.isFree?(0,s.jsx)("span",{children:"free"}):null]})]}),(0,s.jsx)("div",{className:"shrink-0",children:r?(0,s.jsx)(J.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Selected"}):e.recommended?(0,s.jsx)(J.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):e.local?(0,s.jsx)(J.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,s.jsx)(J.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},e.id)})}):(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-dashed border-white/10 bg-white/[0.02] px-3 py-4 text-[11px] text-slate-400",children:"No models are visible yet. Refresh this provider or open the full Add Models flow."})]}):null,S&&!A?(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 rounded-[16px] border border-emerald-300/15 bg-emerald-300/[0.06] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[8px] uppercase tracking-[0.16em] text-emerald-200/75",children:"Selected model"}),(0,s.jsx)("p",{className:"truncate text-[11px] text-emerald-50",children:S})]}),(0,s.jsx)(J.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Selected"})]}):null]})]})}function tr({emptyState:e,onRefresh:t}){return(0,s.jsxs)("div",{className:"mt-3 rounded-[18px] border border-white/10 bg-white/[0.03] p-3",children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:e.title}),(0,s.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[0.98rem] text-slate-400",children:e.description}),(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-1.5",children:(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:t,children:[(0,s.jsx)(n.A,{className:"mr-1.5 h-3 w-3"}),"Refresh provider"]})})]})}function tn(e){return e||{loaded:!1,connection:null,statusMessage:null,errorMessage:null,emptyState:null,manualCommand:null,docsUrl:null,models:[],apiKey:"",search:"",flowState:"idle"}}function ti(e,t){let a=e.diagnostics.modelReadiness.authProviders.find(e=>e.provider===t),s=e.models.filter(e=>tl(t,e.id,e.provider)).length;if("ollama"===t)return{connected:s>0,detail:s>0?`${s} model${1===s?"":"s"} already visible in AgentOS.`:"Detect local models from this machine."};let r=!!a?.connected;return{connected:r,detail:r?a?.detail||(0,eJ.W2)(t).helperText:s>0?`${s} model${1===s?"":"s"} are already saved in AgentOS. Connect ${e0(t)} to use them.`:(0,eJ.W2)(t).helperText}}function tl(e,t,a){let s=a||t.split("/",1)[0]||"";return"openai-codex"===e?"openai-codex"===s||"openai"===s:s===e}function to({steps:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:l,gatewayAuthNeedsSetup:o,onOpenGatewayAuthSettings:c}){let[p,u]=(0,i.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Step 1"}),(0,s.jsx)("h2",{className:(0,N.cn)("mt-1 text-[13px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"System setup"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[10px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Install the CLI, start the gateway, and verify RPC."})]}),(0,s.jsx)("div",{className:"mt-2.5 space-y-1.5",children:e.map((e,a)=>{let r="runtime"===e.id,n="current"===e.state&&"running"===l.runState,i="complete"===e.state?"Ready":"current"===e.state?n?"Checking":r?"Needs verification":"Pending":"Pending";return(0,s.jsxs)("div",{className:(0,N.cn)("relative flex items-center gap-1.5 overflow-hidden rounded-[12px] border px-2 py-1.5",n?"light"===t?"shadow-[inset_0_1px_0_rgba(255,255,255,0.55),0_0_0_1px_rgba(215,178,154,0.18)]":"shadow-[inset_0_1px_0_rgba(255,255,255,0.03),0_0_0_1px_rgba(103,232,249,0.08)]":"",e4(e.state,t)),children:[n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-y-0 left-0 w-1/3 blur-[1px]","light"===t?"bg-gradient-to-r from-transparent via-[#d9b08d]/26 to-transparent":"bg-gradient-to-r from-transparent via-cyan-200/12 to-transparent"),animate:{x:["-30%",r?"250%":"230%"]},transition:{duration:r?1.45:2.05,repeat:1/0,ease:"linear"}}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-x-2 bottom-0 h-px rounded-full","light"===t?"bg-gradient-to-r from-transparent via-[#c99672] to-transparent":"bg-gradient-to-r from-transparent via-cyan-200/70 to-transparent"),animate:{opacity:[.28,.92,.28],scaleX:[.86,1,.86]},transition:{duration:r?1.2:1.65,repeat:1/0,ease:"easeInOut"}})]}):null,(0,s.jsxs)("span",{className:(0,N.cn)("relative mt-0.5 inline-flex h-5 w-5 items-center justify-center overflow-hidden rounded-full border text-[9px] font-medium",e8(e.state,t)),children:[n?(0,s.jsx)(f.P.span,{"aria-hidden":"true",className:(0,N.cn)("absolute inset-0 rounded-full border","light"===t?"border-[#d9b59a]/35 bg-[#f7eee7]/80":"border-cyan-200/16 bg-cyan-300/[0.06]"),animate:{scale:[1,1.16,1],opacity:[.45,.95,.45]},transition:{duration:r?1.5:1.9,repeat:1/0,ease:"easeInOut"}}):null,(0,s.jsx)("span",{className:"relative z-[1]",children:"complete"===e.state?(0,s.jsx)(eG.A,{className:"h-2.5 w-2.5"}):n?(0,s.jsx)(d.A,{className:"h-2.5 w-2.5 animate-spin"}):a+1})]}),(0,s.jsxs)("div",{className:"relative z-[1] 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:(0,N.cn)("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",e6(e.state,t)),children:i})]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[8px] leading-[0.82rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]},e.id)})}),(0,s.jsx)(tb,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,detailsOpen:p,onDetailsOpenChange:u,run:l}),o?(0,s.jsx)("div",{className:(0,N.cn)("mt-2.5 rounded-[14px] border px-2.5 py-2","light"===t?"border-amber-300 bg-amber-50 text-amber-950":"border-amber-300/22 bg-amber-300/10 text-amber-100"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(W.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[10px] font-medium",children:"Native Gateway auth needs an env credential"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[9px] leading-[0.95rem]","light"===t?"text-amber-900/78":"text-amber-100/78"),children:"OpenClaw reports the Gateway secret as redacted. Generate a local token in Settings so AgentOS can use native WS instead of CLI fallback."}),(0,s.jsx)(v.$,{type:"button",size:"sm",variant:"secondary",onClick:c,className:(0,N.cn)("mt-2",eX(t)),children:"Configure Gateway auth"})]})]})}):null]})}function tc({snapshot:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:l,modelPhase:o,selectedModelId:c,modelSwitchFeedback:d,onSelectedModelIdChange:p,onClearModelSwitchFeedback:u,onOpenAddModels:m}){let[h,x]=(0,i.useState)(!0),g=(0,i.useMemo)(()=>e.models.filter(e=>!1!==e.available&&!e.missing),[e.models]),b=(0,i.useMemo)(()=>eZ(c,g),[g,c]),f=e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||null,w=(0,eK.X2)(e),v=tm(f,g),y=tm(c,g),j=!!(c.trim()&&c.trim()!==(f?.trim()??"")),k=(0,i.useMemo)(()=>(function({statusCopy:e,run:t,selectedModelLabel:a,phase:s}){var r;let n=`${e}
|
|
4
|
-
${t.log}`.toLowerCase(),i=!!t.manualCommand||/terminal|sign-in|login|oauth|api key|provider auth/.test(n),l="verifying"===s&&(/creating a demo workspace/.test(n)||/resolving workspace settings and reserving the target directory/.test(n)||/preparing workspace folder/.test(n)||/checking input and target path/.test(n)||/reserved target directory/.test(n)||/creating a fresh workspace folder/.test(n)||/fresh workspace folder created at/.test(n)||/preparing an empty workspace scaffold/.test(n)||/generating workspace docs/.test(n)||/scaffolding workspace files/.test(n)||/workspace files and starter docs are in place/.test(n)||/workspace bootstrap is wrapping up without a kickoff mission/.test(n)||/creating the first workspace agent/.test(n)||/provisioning the first workspace agent/.test(n)||/creating agent \d+ of \d+/.test(n)||/linked to the workspace/.test(n)||/finalizing workspace bootstrap/.test(n)||/workspace bootstrap finished/.test(n)||/demo workspace is ready/.test(n));if("running"!==t.runState||i||!l)return null;let o=(r=n,/resolving workspace settings/.test(r)||/checking input and target path/.test(r)||/reserved target directory/.test(r)||/creating a demo workspace/.test(r)?1:/preparing workspace folder/.test(r)||/creating a fresh workspace folder/.test(r)||/preparing an empty workspace scaffold/.test(r)||/scaffolding workspace files/.test(r)||/fresh workspace folder created at/.test(r)||/generating workspace docs/.test(r)||/workspace files and starter docs are in place/.test(r)?2:/creating the first workspace agent/.test(r)||/provisioning the first workspace agent/.test(r)||/creating agent \d+ of \d+/.test(r)||/linked to the workspace/.test(r)?3:/finalizing workspace bootstrap/.test(r)||/workspace bootstrap is wrapping up without a kickoff mission/.test(r)||/workspace bootstrap finished/.test(r)||/demo workspace is ready/.test(r)?4:1),c=[{id:"model",label:"Default model",detail:a?`${a} is now the route powering the workspace.`:"The selected route is being saved locally."},{id:"path",label:"Workspace shell",detail:"Validating the destination and preparing the workspace folder."},{id:"scaffold",label:"Workspace scaffold",detail:"Writing docs, memory, and the bootstrap metadata."},{id:"agent",label:"Starter agent",detail:"Provisioning the first agent and wiring it into the workspace."},{id:"handoff",label:"Canvas handoff",detail:"Refreshing the graph and selecting the new workspace."}].map((e,t)=>({...e,state:t<o?"done":t===o?"current":"pending"}));return{stepIndex:o,steps:c,logLines:t.log.split(/\r?\n/).map(e=>e.trim().replace(/^>\s*/,"")).filter(e=>!!e).slice(-4),headline:"Building your demo workspace",summary:"Workspace files, the first agent, and the initial canvas handoff are being assembled in real time.",selectedModelLabel:a}})({statusCopy:a,run:l,selectedModelLabel:b,phase:o}),[o,l,b,a]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"Step 2: Model setup"})}),k?(0,s.jsx)(tf,{surfaceTheme:t,statusCopy:a,phaseLabel:n,buildScene:k}):"idle"!==d.phase?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tp,{surfaceTheme:t,feedback:d,defaultModelLabel:tm(d.previousModelId,g),nextModelLabel:tm(d.nextModelId,g),onChangeAgain:u}),(0,s.jsx)(tb,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,detailsOpen:h,onDetailsOpenChange:x,run:l})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(td,{surfaceTheme:t,defaultModelLabel:v,switchTargetLabel:y,hasPendingModelSwitch:j}),(0,s.jsx)(ts,{snapshot:e,selectedModelId:c,onSelectedModelIdChange:p,onOpenAddModels:m,autoDiscover:!w}),(0,s.jsx)(tb,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,detailsOpen:h,onDetailsOpenChange:x,run:l})]})]})}function td({surfaceTheme:e,defaultModelLabel:t,switchTargetLabel:a,hasPendingModelSwitch:r}){return(0,s.jsx)("div",{className:(0,N.cn)("mt-2 rounded-[14px] border px-2.5 py-2","light"===e?"border-[#e8d8ca] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#9a7a65]":"text-slate-500"),children:"Detected default"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 truncate text-[10px]","light"===e?"text-[#3e2f24]":"text-white"),children:t??"Not set"})]}),r?(0,s.jsxs)("div",{className:"min-w-0 text-right",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#9a7a65]":"text-slate-500"),children:"Switch to"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 truncate text-[10px]","light"===e?"text-[#7a4d2d]":"text-cyan-100"),children:a})]}):null]})})}function tp({surfaceTheme:e,feedback:t,defaultModelLabel:a,nextModelLabel:r,onChangeAgain:n}){var i;let l,o="light"===e,c="saving"===t.phase,p="success"===t.phase,u="error"===t.phase,m=t.message||(p?"AgentOS will use this route for new actions.":u?"Review the log below, then try again.":"Saving the route, refreshing OpenClaw config, and updating AgentOS."),h=(l=(i=t).message??"","saving"!==i.phase?0:/updating agentos snapshot|snapshot/i.test(l)?3:/verifying selected provider|provider/i.test(l)?2:+!!/refreshing openclaw config|config/i.test(l));return(0,s.jsx)("div",{className:(0,N.cn)("mt-3 overflow-hidden rounded-[22px] border",o?"border-[#e1d0c2] bg-[linear-gradient(180deg,rgba(255,250,246,0.98),rgba(248,240,232,0.98))]":"border-cyan-300/16 bg-[radial-gradient(circle_at_top,rgba(16,28,44,0.98),rgba(6,10,18,0.98)_72%)]"),children:(0,s.jsxs)("div",{className:"relative isolate min-h-[300px] overflow-hidden px-4 py-4 text-center",children:[(0,s.jsx)("div",{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-0",o?"bg-[radial-gradient(circle_at_50%_0%,rgba(232,186,151,0.22),transparent_34%),linear-gradient(135deg,rgba(255,255,255,0.4),transparent_48%)]":"bg-[radial-gradient(circle_at_50%_0%,rgba(34,211,238,0.18),transparent_34%),linear-gradient(135deg,rgba(255,255,255,0.04),transparent_48%)]")}),(0,s.jsxs)("div",{className:"relative z-[1] flex flex-col items-center",children:[(0,s.jsxs)("div",{className:"relative flex h-20 w-20 items-center justify-center",children:[c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("absolute h-20 w-20 rounded-full border",o?"border-[#d1a98b]":"border-cyan-200/24"),animate:{rotate:360},transition:{duration:8,repeat:1/0,ease:"linear"}}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("absolute h-14 w-14 rounded-full border border-dashed",o?"border-[#c8946f]":"border-cyan-200/40"),animate:{rotate:-360},transition:{duration:6,repeat:1/0,ease:"linear"}})]}):null,(0,s.jsx)("span",{className:(0,N.cn)("relative z-[1] inline-flex h-12 w-12 items-center justify-center rounded-full border",p?o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":u?o?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200":o?"border-[#d7b59a] bg-white text-[#9a6a48]":"border-cyan-300/20 bg-cyan-300/10 text-cyan-100"),children:p?(0,s.jsx)(eG.A,{className:"h-5 w-5"}):c?(0,s.jsx)(d.A,{className:"h-5 w-5 animate-spin"}):(0,s.jsx)(e7.A,{className:"h-5 w-5"})})]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-3 text-[8px] uppercase tracking-[0.22em]",o?"text-[#94735e]":"text-cyan-200/70"),children:"Model route"}),(0,s.jsx)("h3",{className:(0,N.cn)("mt-1 text-[17px] font-medium tracking-[-0.03em]",o?"text-[#2d2118]":"text-white"),children:p?"Default model updated":u?"Default model could not be changed":"Switching default model"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 max-w-[320px] text-[10px] leading-[1rem]",o?"text-[#6d5647]":"text-slate-300"),children:m}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 grid w-full gap-2 rounded-[16px] border px-3 py-3 text-left",o?"border-[#ead8c8] bg-white/70":"border-white/8 bg-white/[0.04]"),children:[(0,s.jsx)(tu,{label:"Previous",value:a??"Not set",surfaceTheme:e,muted:!0}),(0,s.jsx)(tu,{label:"New default",value:r??"Not selected",surfaceTheme:e})]}),c?(0,s.jsx)("div",{className:"mt-4 grid w-full gap-1.5 text-left",children:["Saving model route","Refreshing OpenClaw config","Verifying selected provider","Updating AgentOS snapshot"].map((e,t)=>(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center gap-2 rounded-[12px] border px-2.5 py-2",t===h?o?"border-[#c8946f] bg-[#fff5ed]":"border-cyan-300/24 bg-cyan-300/[0.07]":t<h?o?"border-emerald-200 bg-emerald-50/60":"border-emerald-300/16 bg-emerald-300/[0.05]":o?"border-[#ead8c8] bg-white/55":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex h-4 w-4 items-center justify-center rounded-full border text-[8px]",t<h?o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":t===h?o?"border-[#c8946f] bg-[#f8eadf] text-[#8c5d3d]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":o?"border-[#e0cec0] bg-white text-[#9a7f6c]":"border-white/10 bg-white/[0.03] text-slate-500"),children:t<h?(0,s.jsx)(eG.A,{className:"h-2.5 w-2.5"}):t+1}),(0,s.jsx)("p",{className:(0,N.cn)("text-[10px]",o?"text-[#5f4b3e]":"text-slate-300"),children:e})]},e))}):null,c?null:(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:n,className:(0,N.cn)("mt-4 h-8 rounded-full px-3 text-[10px]",eX(e)),children:"Change again"})]})]})})}function tu({label:e,value:t,surfaceTheme:a,muted:r=!1}){return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:e}),(0,s.jsx)("span",{className:(0,N.cn)("min-w-0 truncate text-right text-[10px]",r?"light"===a?"text-[#8a7261]":"text-slate-400":"light"===a?"text-[#3e2f24]":"text-white"),children:t})]})}function tm(e,t){return e?.trim()?eZ(e,t)??(0,k.JZ)(e):null}function th({surfaceTheme:e,workspaceCount:t,defaultModelLabel:a,createProgress:r,createRunState:n}){let i=t>0,l="running"===n&&!!r,o="error"===n&&!!r,c=!!r&&(l||o),d=i?`You already have ${t} workspace${1===t?"":"s"} online. Use AgentOS to inspect them or create another workspace for a new mission.`:l?"AgentOS Workspace is being provisioned now. The scaffold and starter agent are being built in the background.":o?"The first workspace creation needs attention. Review the output, then try again.":"No workspace exists yet. Create one first so the live system has a place to keep context and deliverables.";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[16px] border px-3 py-3","light"===e?"border-emerald-200/80 bg-[linear-gradient(180deg,rgba(240,250,245,0.95),rgba(248,244,236,0.95))]":"border-emerald-300/15 bg-[linear-gradient(180deg,rgba(9,18,19,0.96),rgba(7,11,18,0.94))]"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full border","light"===e?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-200"),children:(0,s.jsx)(eG.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.18em]","light"===e?"text-emerald-700/75":"text-emerald-200/75"),children:"Launchpad"}),(0,s.jsx)("h2",{className:(0,N.cn)("mt-1 text-[13px] font-medium","light"===e?"text-[#2d2118]":"text-white"),children:"OpenClaw is ready."}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[10px] leading-[0.95rem]","light"===e?"text-[#5f4b3e]":"text-slate-300"),children:d})]})]}),c?null:(0,s.jsxs)("div",{className:"mt-3 grid gap-1.5 sm:grid-cols-2",children:[(0,s.jsx)(tg,{surfaceTheme:e,label:"System",value:"Online",detail:"CLI, gateway, and runtime access verified"}),(0,s.jsx)(tg,{surfaceTheme:e,label:i?"Default model":"Detected default",value:a,detail:i?"Usable model route selected":"Detected on this machine, not yet confirmed by a workspace."}),(0,s.jsx)(tg,{surfaceTheme:e,label:"Runtime",value:"Smoke test passed",detail:"A live agent turn was verified"}),(0,s.jsx)(tg,{surfaceTheme:e,label:"Workspaces",value:String(t),detail:i?"Ready for mission planning":"Create one to begin"})]})]}),c?(0,s.jsx)(tx,{surfaceTheme:e,progress:r,runState:n}):(0,s.jsxs)("div",{className:(0,N.cn)("mt-2.5 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:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Next step"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-[1rem]","light"===e?"text-[#5f4b3e]":"text-slate-300"),children:i?"Open AgentOS to inspect the live graph, or create another workspace if you want a separate mission lane.":"Create the first workspace now. That is the shortest path from a ready system to a real mission."})]})]})}function tx({surfaceTheme:e,progress:t,runState:a}){let r="light"===e,n=t.steps.find(e=>"active"===e.status)??t.steps[0]??null,i="error"===a;return(0,s.jsxs)("div",{className:(0,N.cn)("relative mt-2.5 overflow-hidden rounded-[18px] border px-2.5 py-2.5",r?i?"border-rose-200 bg-[linear-gradient(180deg,rgba(255,248,247,0.98),rgba(252,242,242,0.96))]":"border-[#dcc7b8] bg-[linear-gradient(180deg,rgba(255,251,248,0.98),rgba(249,243,236,0.96))]":i?"border-rose-300/18 bg-[radial-gradient(circle_at_top,rgba(49,18,24,0.95),rgba(12,8,14,0.98)_72%)]":"border-cyan-300/16 bg-[radial-gradient(circle_at_top,rgba(11,21,34,0.98),rgba(5,10,18,0.98)_72%)]"),children:[(0,s.jsx)("div",{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-0",r?"bg-[radial-gradient(circle_at_20%_0%,rgba(255,255,255,0.95),transparent_28%),radial-gradient(circle_at_84%_18%,rgba(201,148,111,0.14),transparent_22%)]":i?"bg-[radial-gradient(circle_at_20%_0%,rgba(251,113,133,0.14),transparent_26%),radial-gradient(circle_at_84%_18%,rgba(248,113,113,0.08),transparent_22%)]":"bg-[radial-gradient(circle_at_20%_0%,rgba(34,211,238,0.12),transparent_26%),radial-gradient(circle_at_84%_18%,rgba(59,130,246,0.08),transparent_22%)]")}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute -left-8 top-5 h-24 w-24 rounded-full blur-3xl",r?"bg-[#efc6a8]/20":i?"bg-rose-300/10":"bg-cyan-300/10"),animate:{x:[0,10,0],y:[0,-6,0],opacity:[.45,.75,.45]},transition:{duration:7.5,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute -right-4 top-8 h-28 w-28 rounded-full blur-3xl",r?"bg-[#f6d9c2]/18":i?"bg-rose-300/8":"bg-sky-300/8"),animate:{x:[0,-12,0],y:[0,8,0],opacity:[.35,.7,.35]},transition:{duration:9.5,repeat:1/0,ease:"easeInOut"}}),(0,s.jsxs)("div",{className:"relative z-[1] flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,s.jsx)(f.P.div,{className:(0,N.cn)("mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border",r?i?"border-rose-300 bg-white text-rose-700":"border-[#d9b59a] bg-white text-[#8b6d5a]":i?"border-rose-300/25 bg-rose-300/10 text-rose-100":"border-cyan-200/20 bg-cyan-300/10 text-cyan-100"),animate:{scale:[1,1.06,1],opacity:[.82,1,.82]},transition:{duration:3.2,repeat:1/0,ease:"easeInOut"},children:i?(0,s.jsx)(W.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.18em]",r?i?"text-rose-600/75":"text-[#977b69]":i?"text-rose-200/75":"text-cyan-200/70"),children:i?"Needs attention":"Building"}),(0,s.jsx)("h3",{className:(0,N.cn)("mt-1 text-[13px] font-medium",r?i?"text-rose-950":"text-[#281d17]":i?"text-rose-50":"text-white"),children:i?"Workspace creation needs attention":t.title}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[10px] leading-[0.95rem]",r?i?"text-rose-700":"text-[#6f5a4c]":i?"text-rose-100/80":"text-slate-300"),children:i?"Review the captured output and retry when the workspace state is clean.":t.description})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-0.5 text-[8px] uppercase tracking-[0.16em]",r?i?"border-rose-200 bg-white text-rose-700":"border-[#dcc7b8] bg-white/75 text-[#8b6f5c]":i?"border-rose-300/20 bg-rose-300/8 text-rose-100":"border-cyan-300/16 bg-cyan-300/10 text-cyan-100"),children:i?"Error":`${t.percent}%`}),n?(0,s.jsx)("span",{className:(0,N.cn)("max-w-[140px] truncate rounded-full border px-2 py-0.5 text-[7px] uppercase tracking-[0.14em]",r?i?"border-rose-200 bg-white text-rose-700":"border-[#e9d7ca] bg-white text-[#8b6f5c]":i?"border-rose-300/18 bg-rose-300/8 text-rose-100":"border-white/10 bg-white/[0.04] text-slate-300"),children:n.label}):null]})]}),(0,s.jsx)("div",{className:"relative z-[1] mt-2.5 h-1.5 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)(f.P.div,{className:(0,N.cn)("h-full rounded-full transition-[width] duration-500 ease-out",r?i?"bg-rose-300/85":"bg-amber-300/85":i?"bg-rose-300/85":"bg-cyan-300/85"),style:{width:`${t.percent}%`}})}),(0,s.jsx)("div",{className:"relative z-[1] mt-2.5 space-y-1.5",children:t.steps.map((e,t)=>{let a="active"===e.status,n="done"===e.status?r?"border-emerald-200 bg-emerald-50/75":"border-emerald-400/20 bg-emerald-400/10":a?r?"border-[#d9bca5] bg-white":"border-cyan-300/18 bg-cyan-300/[0.05]":r?"border-[#eadccc] bg-white/70":"border-white/6 bg-white/[0.03]",l="done"===e.status?r?"border-emerald-300 bg-emerald-100 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":a?r?"border-[#d5b9a5] bg-[#f5ebe3] text-[#8b6d5a]":"border-cyan-200/20 bg-cyan-300/10 text-cyan-100":r?"border-[#e1ccc0] bg-white text-[#9a7f6c]":"border-white/8 bg-white/[0.03] text-slate-400";return(0,s.jsxs)("div",{className:(0,N.cn)("relative overflow-hidden rounded-[12px] border px-2.5 py-1.5",n),children:[a?(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-y-0 left-0 w-1/3 blur-[1px]",r?"bg-gradient-to-r from-transparent via-[#d9b08d]/24 to-transparent":i?"bg-gradient-to-r from-transparent via-rose-300/10 to-transparent":"bg-gradient-to-r from-transparent via-cyan-200/12 to-transparent"),animate:{x:["-25%","230%"]},transition:{duration:1.7,repeat:1/0,ease:"linear"}}):null,(0,s.jsxs)("div",{className:"relative z-[1] flex items-start gap-1.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[9px] font-medium",l),children:"done"===e.status?(0,s.jsx)(eG.A,{className:"h-2.5 w-2.5"}):a?(0,s.jsx)(d.A,{className:"h-2.5 w-2.5 animate-spin"}):t+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px]",r?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsxs)("span",{className:(0,N.cn)("text-[7px] tabular-nums",r?"text-[#8f7664]":"text-slate-400"),children:[e.percent,"%"]})]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[8px] leading-[0.82rem]",r?"text-[#8f7664]":"text-slate-500"),children:e.detail||e.description}),(0,s.jsx)("div",{className:"mt-1 h-1.5 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)(f.P.div,{className:(0,N.cn)("h-full rounded-full transition-[width] duration-500 ease-out","done"===e.status?"bg-emerald-300/85":a?r?i?"bg-rose-300/85":"bg-amber-300/85":i?"bg-rose-300/85":"bg-cyan-300/85":"bg-transparent"),style:{width:`${Math.max(e.percent,10*!!a)}%`}})}),a&&e.activities.length>0?(0,s.jsx)("div",{className:"mt-1 space-y-0.5",children:e.activities.slice(-2).map(e=>(0,s.jsxs)("div",{className:(0,N.cn)("flex items-start gap-1.5 text-[8px] leading-[0.9rem]",r?"text-[#705b4d]":"text-slate-300"),children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-[5px] 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-rose-300","pending"===e.status&&(r?"bg-[#c9b4a2]":"bg-slate-500"))}),(0,s.jsx)("span",{className:"min-w-0",children:e.message})]},e.id))}):null]})]})]},e.id)})})]})}function tg({surfaceTheme:e,label:t,value:a,detail:r}){return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[12px] border px-2.5 py-2","light"===e?"border-[#e6d7cb] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:t}),(0,s.jsx)("p",{title:a,className:(0,N.cn)("mt-1 truncate text-[10px]","light"===e?"text-[#33251c]":"text-white"),children:a}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[8px] leading-[0.85rem]","light"===e?"text-[#8f7664]":"text-slate-500"),children:r})]})}function tb({surfaceTheme:e,statusCopy:t,showDetails:a,phaseLabel:r,detailsOpen:n,onDetailsOpenChange:l,run:o}){let[c,p]=(0,i.useState)(!1),u=(0,eW.T)(o.manualCommand),m=async()=>{if(o.manualCommand)try{await navigator.clipboard.writeText(o.manualCommand),j.o.success("Command copied.",{description:"Open Terminal and paste it."})}catch(e){j.o.error("Could not copy command.",{description:e instanceof Error?e.message:"Clipboard access is unavailable."})}},h=async()=>{if(o.manualCommand&&u){p(!0);try{let e=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:o.manualCommand})}),t=await e.json().catch(()=>null);if(!e.ok||t?.error)throw Error(t?.error||"Unable to open Terminal.");j.o.success("Terminal opened.",{description:"Finish auth there, then refresh."})}catch(e){j.o.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command."})}finally{p(!1)}}};return(0,s.jsxs)("div",{className:(0,N.cn)("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.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Status"}),a?(0,s.jsx)("button",{type:"button",onClick:()=>l(!n),className:(0,N.cn)("text-[8px] uppercase tracking-[0.16em] transition-colors","light"===e?"text-[#8f7664] hover:text-[#6f5949]":"text-slate-500 hover:text-slate-300"),children:n?"Hide details":"Show details"}):null]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-[1rem]","light"===e?"text-[#5f4b3e]":"text-slate-300"),children:t})]}),a&&n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,N.cn)("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:(0,N.cn)("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Log"}),(0,s.jsx)("span",{className:"light"===e?"text-[10px] text-[#8c7362]":"text-[10px] text-slate-400",children:r})]}),(0,s.jsx)("pre",{className:(0,N.cn)("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:o.log||"No output yet.\n\nStart the step to stream logs."}),o.manualCommand?(0,s.jsxs)("div",{className:(0,N.cn)("border-t px-2.5 py-2","light"===e?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:u?"Terminal":"Manual"}),u?(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[9px] leading-[0.95rem]","light"===e?"text-[#705b4d]":"text-slate-400"),children:"Open Terminal and run this command."}):null,(0,s.jsx)("p",{className:(0,N.cn)("mt-1 break-all font-mono text-[9px] leading-[0.92rem]","light"===e?"text-[#4f3d31]":"text-slate-200"),children:o.manualCommand}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:m,className:eX(e),children:[(0,s.jsx)(eU.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),u?(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:h,disabled:c,className:eX(e),children:c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null]}),o.docsUrl?(0,s.jsxs)("a",{href:o.docsUrl,target:"_blank",rel:"noreferrer",className:(0,N.cn)("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)(eV.A,{className:"h-2.5 w-2.5"})]}):null]}):null]}):null]})}function tf({surfaceTheme:e,statusCopy:t,phaseLabel:a,buildScene:r}){let n="light"===e;return(0,s.jsx)("div",{className:(0,N.cn)("mt-3 overflow-hidden rounded-[24px] border",n?"border-[#e1d4c6] bg-[linear-gradient(180deg,rgba(255,251,247,0.96),rgba(248,241,233,0.98))]":"border-cyan-300/18 bg-[radial-gradient(circle_at_top,rgba(12,24,40,0.98),rgba(5,10,18,0.98)_72%)]"),children:(0,s.jsxs)("div",{className:"relative isolate min-h-[440px] overflow-hidden px-4 py-4 sm:px-5 sm:py-5",children:[(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-none absolute inset-0",n?"bg-[radial-gradient(circle_at_20%_20%,rgba(255,255,255,0.96),transparent_30%),radial-gradient(circle_at_80%_10%,rgba(221,182,152,0.18),transparent_24%),linear-gradient(135deg,rgba(255,255,255,0.06),transparent_30%,rgba(218,193,176,0.12)_58%,transparent_72%)]":"bg-[radial-gradient(circle_at_20%_20%,rgba(34,211,238,0.16),transparent_24%),radial-gradient(circle_at_82%_12%,rgba(56,189,248,0.11),transparent_20%),linear-gradient(135deg,rgba(255,255,255,0.03),transparent_34%,rgba(34,211,238,0.05)_58%,transparent_74%)]")}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute -left-12 top-8 h-36 w-36 rounded-full blur-3xl",n?"bg-[#f1b27d]/25":"bg-cyan-300/12"),animate:{x:[0,16,0],y:[0,-10,0],opacity:[.55,.8,.55]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute right-0 top-24 h-44 w-44 rounded-full blur-3xl",n?"bg-[#f9d8b6]/22":"bg-sky-300/10"),animate:{x:[0,-18,0],y:[0,8,0],opacity:[.35,.7,.35]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),(0,s.jsxs)("div",{className:"relative z-[1] flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[9px] uppercase tracking-[0.24em]",n?"text-[#8f6f5d]":"text-cyan-200/70"),children:"Building"}),(0,s.jsx)("h3",{className:(0,N.cn)("mt-1 text-[18px] font-medium tracking-[-0.03em] sm:text-[22px]",n?"text-[#231a15]":"text-white"),children:"Creating your demo workspace"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 max-w-[42rem] text-[11px] leading-[1rem] sm:text-[12px] sm:leading-[1.05rem]",n?"text-[#6f5a4c]":"text-slate-300"),children:t})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[8px] uppercase tracking-[0.16em]",n?"border-[#d9c3b1] bg-white/70 text-[#8b6f5c]":"border-cyan-300/18 bg-cyan-300/10 text-cyan-100"),children:a}),r.selectedModelLabel?(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex max-w-[220px] truncate rounded-full border px-2.5 py-1 text-[9px]",n?"border-[#ead8c8] bg-white text-[#5a4638]":"border-white/10 bg-white/[0.04] text-slate-200"),children:["Default model: ",r.selectedModelLabel]}):null]})]}),(0,s.jsxs)("div",{className:"relative z-[1] mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(280px,0.8fr)]",children:[(0,s.jsxs)("div",{className:(0,N.cn)("relative min-h-[290px] overflow-hidden rounded-[28px] border",n?"border-[#ead8c8] bg-[linear-gradient(180deg,rgba(255,255,255,0.92),rgba(252,246,239,0.98))] shadow-[0_18px_50px_rgba(165,126,98,0.08)]":"border-white/10 bg-[linear-gradient(180deg,rgba(9,16,28,0.98),rgba(5,10,18,0.98))] shadow-[0_18px_50px_rgba(0,0,0,0.3)]"),children:[(0,s.jsx)("div",{className:(0,N.cn)("absolute inset-0 opacity-80",n?"bg-[linear-gradient(rgba(116,85,65,0.05)_1px,transparent_1px),linear-gradient(90deg,rgba(116,85,65,0.05)_1px,transparent_1px)] bg-[size:28px_28px]":"bg-[linear-gradient(rgba(56,189,248,0.08)_1px,transparent_1px),linear-gradient(90deg,rgba(56,189,248,0.08)_1px,transparent_1px)] bg-[size:28px_28px]")}),(0,s.jsx)(f.P.div,{"aria-hidden":"true",className:(0,N.cn)("absolute inset-x-0 top-0 h-px",n?"bg-gradient-to-r from-transparent via-[#caa789] to-transparent":"bg-gradient-to-r from-transparent via-cyan-200/70 to-transparent"),animate:{opacity:[.4,1,.4]},transition:{duration:3.2,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsxs)("div",{className:"relative flex flex-col items-center text-center",children:[(0,s.jsx)(f.P.div,{className:(0,N.cn)("absolute h-56 w-56 rounded-full border",n?"border-[#d8bda5]/45":"border-cyan-200/14"),animate:{rotate:360},transition:{duration:28,repeat:1/0,ease:"linear"}}),(0,s.jsx)(f.P.div,{className:(0,N.cn)("absolute h-40 w-40 rounded-full border",n?"border-[#e2c4ad]/65":"border-cyan-200/16"),animate:{rotate:-360},transition:{duration:18,repeat:1/0,ease:"linear"}}),(0,s.jsx)(f.P.div,{className:(0,N.cn)("absolute h-24 w-24 rounded-full border",n?"border-[#f0d8c8] bg-white/90":"border-cyan-300/18 bg-cyan-300/[0.08]"),animate:{scale:[1,1.04,1],opacity:[.75,1,.75]},transition:{duration:3.8,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("div",{className:(0,N.cn)("relative flex h-24 w-24 items-center justify-center rounded-full border shadow-[0_0_0_14px_rgba(255,255,255,0.03)]",n?"border-[#d7b9a0] bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.98),rgba(246,232,219,0.98))] text-[#7c5b46]":"border-cyan-300/24 bg-[radial-gradient(circle_at_top,rgba(16,30,48,0.96),rgba(7,12,21,0.98))] text-cyan-100"),children:(0,s.jsx)(d.A,{className:"h-10 w-10 animate-spin"})}),(0,s.jsx)("p",{className:(0,N.cn)("mt-5 text-[9px] uppercase tracking-[0.22em]",n?"text-[#9a7d69]":"text-cyan-200/70"),children:"Workspace fabric"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[18px] font-medium tracking-[-0.03em]",n?"text-[#281d17]":"text-white"),children:r.headline}),(0,s.jsx)("p",{className:(0,N.cn)("mt-2 max-w-[28rem] text-[11px] leading-[1rem]",n?"text-[#6a5547]":"text-slate-300"),children:r.summary}),(0,s.jsxs)("div",{className:"mt-5 flex flex-wrap items-center justify-center gap-2",children:[(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-[9px]",n?"border-[#dec8b8] bg-white text-[#634d3d]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,s.jsx)("span",{className:(0,N.cn)("h-1.5 w-1.5 rounded-full",n?"bg-[#c98a5f]":"bg-cyan-300")}),"Building workspace"]}),(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-[9px]",n?"border-[#dec8b8] bg-white text-[#634d3d]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,s.jsx)("span",{className:(0,N.cn)("h-1.5 w-1.5 rounded-full",n?"bg-emerald-500":"bg-emerald-300")}),"Default model locked"]})]})]})}),(0,s.jsx)("div",{className:"absolute inset-x-5 bottom-5",children:(0,s.jsx)("div",{className:(0,N.cn)("relative h-2 overflow-hidden rounded-full border",n?"border-[#dec8b8] bg-white/90":"border-white/10 bg-white/[0.04]"),children:(0,s.jsx)(f.P.div,{className:(0,N.cn)("absolute inset-y-0 left-0 w-1/3 rounded-full",n?"bg-gradient-to-r from-[#b97b4c] via-[#f1c59b] to-[#e39e69]":"bg-gradient-to-r from-cyan-400 via-sky-200 to-cyan-500"),animate:{x:["-15%","125%"]},transition:{duration:2.4,repeat:1/0,ease:"linear"}})})})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-col gap-3",children:[r.steps.map((e,t)=>(0,s.jsx)(f.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:.05*t},className:(0,N.cn)("rounded-[18px] border px-3 py-2.5","current"===e.state?n?"border-[#d9b79f] bg-white shadow-[0_10px_28px_rgba(185,122,77,0.08)]":"border-cyan-300/24 bg-white/[0.05] shadow-[0_10px_28px_rgba(0,0,0,0.18)]":"done"===e.state?n?"border-[#e7d5c6] bg-[rgba(255,255,255,0.76)]":"border-white/10 bg-white/[0.03]":n?"border-[#eadccf] bg-[rgba(255,250,246,0.8)]":"border-white/8 bg-white/[0.02]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:(0,N.cn)("mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border text-[10px] font-medium","current"===e.state?n?"border-[#c78e61] bg-[#f7e6d7] text-[#6b4d39]":"border-cyan-300/28 bg-cyan-300/12 text-cyan-50":"done"===e.state?n?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/12 text-emerald-200":n?"border-[#e2d4c7] bg-white text-[#9a7f6c]":"border-white/10 bg-white/[0.03] text-slate-400"),children:"done"===e.state?(0,s.jsx)(eG.A,{className:"h-3.5 w-3.5"}):t+1}),(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] font-medium",n?"text-[#2b1f18]":"text-white"),children:e.label}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[9px] leading-[0.95rem]",n?"text-[#7c6554]":"text-slate-400"),children:e.detail})]}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full px-1.5 py-0.5 text-[7px] uppercase tracking-[0.14em]","current"===e.state?n?"bg-[#f1dfd0] text-[#835f48]":"bg-cyan-300/12 text-cyan-100":"done"===e.state?n?"bg-emerald-100 text-emerald-700":"bg-emerald-300/12 text-emerald-200":n?"bg-[#f6ece3] text-[#a0826e]":"bg-white/[0.04] text-slate-500"),children:"done"===e.state?"Ready":"current"===e.state?"Building":"Queued"})]})})]})},e.id)),(0,s.jsxs)("div",{className:(0,N.cn)("mt-auto rounded-[20px] border p-3",n?"border-[#ead8c8] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[8px] uppercase tracking-[0.18em]",n?"text-[#8f6f5d]":"text-cyan-200/60"),children:"Live build feed"}),(0,s.jsx)("span",{className:(0,N.cn)("text-[9px]",n?"text-[#8a6f5e]":"text-slate-400"),children:a})]}),(0,s.jsx)("div",{className:"mt-2 space-y-1.5",children:r.logLines.length>0?r.logLines.slice(-4).map((e,t)=>(0,s.jsxs)(f.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25,delay:.04*t},className:(0,N.cn)("flex items-start gap-2 rounded-[14px] border px-2.5 py-2 text-[10px] leading-[0.98rem]",t===r.logLines.length-1?n?"border-[#d8b79e] bg-[#fff7f0] text-[#5a4638]":"border-cyan-300/18 bg-cyan-300/[0.06] text-slate-100":n?"border-[#eee0d3] bg-[#fffdfb] text-[#735d4e]":"border-white/8 bg-white/[0.02] text-slate-300"),children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",t===r.logLines.length-1?n?"bg-[#c98758]":"bg-cyan-300":n?"bg-[#e3c8b2]":"bg-slate-500")}),(0,s.jsx)("span",{className:"min-w-0",children:e})]},`${e}-${t}`)):(0,s.jsx)("div",{className:(0,N.cn)("rounded-[14px] border border-dashed px-2.5 py-3 text-[10px]",n?"border-[#e8d7c8] text-[#7e6453]":"border-white/10 text-slate-400"),children:"Waiting for the first build signal..."})})]})]})]})]})})}function tw({snapshot:e,surfaceTheme:t,stage:a,systemReady:r,modelReady:n,systemSetupRequired:i,showReadyState:l,systemActionLabel:o,systemActionDescription:c,systemPhase:p,modelPhase:u,systemRun:m,modelRun:x,modelSwitchFeedback:g,selectedModelId:b,discoveredModels:w,onSelectedModelIdChange:y,onClearModelSwitchFeedback:j,onRunSystemSetup:k,onRunModelSetDefault:C,onOpenAddModels:S,onOpenGatewayAuthSettings:A,onCreateWorkspace:T,onEnterAgentOS:$,onContinueToModels:M,onBackToSystem:I,onSelectStage:R,launchpadCreateProgress:O,launchpadCreateRunState:P}){var _,D;let E=r??("success"===m.runState||(0,eK.h6)(e)),L=(0,ez.Id)(e),U=n??("success"===g.phase||l||(0,eK.X2)(e)),F=U&&(l||!L),z="running"===P,W=e.workspaces.length,B=W>0,G=e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||"Ready",q=e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||null,V=[{id:"system",order:1,label:"System setup",description:"CLI, gateway, RPC",state:eQ(E,"system"===a&&!E)},{id:"models",order:2,label:"Model setup",description:"Default model, auth",state:eQ(U,"models"===a&&!U)}],K=function(e,t,a={}){let s=!0===a.forcePending,r=!s&&e.diagnostics.rpcOk&&!e.diagnostics.loaded,n=!s&&e.diagnostics.installed||"installing-gateway"===t||"starting-gateway"===t||"verifying"===t||"ready"===t,i=!s&&e.diagnostics.loaded||r||"starting-gateway"===t||"verifying"===t||"ready"===t,l=!s&&e.diagnostics.rpcOk||"ready"===t,o=!s&&e.diagnostics.runtime.stateWritable&&e.diagnostics.runtime.sessionStoreWritable||"ready"===t,c=l&&o;return[{id:"cli",label:"OpenClaw CLI",description:eY("cli",e,t,n,i,l,c,s),state:eQ(n,!n&&("detecting"===t||"installing-cli"===t))},{id:"gateway",label:"Gateway service",description:eY("gateway",e,t,n,i,l,c,s),state:eQ(i,!i&&("installing-gateway"===t||n&&"detecting"===t))},{id:"runtime",label:"Runtime ready",description:eY("runtime",e,t,n,i,l,c,s),state:eQ(c,!c&&("starting-gateway"===t||"verifying"===t||i&&"detecting"===t||i||l))}]}(e,E?"ready":p,{forcePending:i}),J=eZ(b,e.models.filter(e=>!1!==e.available&&!e.missing)),H="system"===a?m:x,Y=H.statusMessage||H.resultMessage||("system"===a?c:J?`Selected model: ${J}.`:"Choose a provider, connect it, and then pick a model."),Z="system"===a?E?"ready":i?"waiting":(0,eK.iN)(e)?"ready":e.diagnostics.rpcOk?"verifying access":e.diagnostics.loaded&&!e.diagnostics.rpcOk?"verifying"===p?"connecting":"starting gateway":p?p.replace("-"," "):"waiting":(0,eK.X2)(e)?"ready":e.diagnostics.modelReadiness.ready&&"passed"!==e.diagnostics.runtime.smokeTest.status?"smoke test":u?u.replace("-"," "):"waiting",Q="idle"!==H.runState||!!H.manualCommand||H.log.trim().length>0||"models"===a&&w.length>0,X=(_=H.runState,"running"===_?"Running":U?"Ready":"success"===_?"models"===a?"Updated":"Step complete":"error"===_?"Needs attention":"system"===a?"Step 1":"Step 2"),ee=e.diagnostics.issues.some(e=>/gateway\..*auth|redacted secret|AGENTOS_OPENCLAW_GATEWAY_TOKEN|OPENCLAW_GATEWAY_TOKEN/i.test(e)),et=function(e){if("system"===e.stage)return e.systemReady&&e.modelReady?{kind:"dismiss",label:"Enter AgentOS"}:e.systemReady?{kind:"continue",label:"Continue to model setup"}:{kind:"system",label:e.systemActionLabel};let t=e.selectedModelId.trim(),a=e.defaultModelId?.trim()??"";return t?t===a?{kind:"dismiss",label:"Enter AgentOS"}:{kind:"set-default",label:"Set as default"}:e.modelReady?{kind:"dismiss",label:"Enter AgentOS"}:{kind:"select-model",label:"Select a model"}}({stage:a,systemReady:E,modelReady:U,systemActionLabel:o,selectedModelId:b,defaultModelId:q});return(0,s.jsx)(f.P.div,{initial:{opacity:0,backdropFilter:"blur(0px)"},animate:{opacity:1,backdropFilter:"blur(12px)"},exit:{opacity:0,backdropFilter:"blur(0px)"},className:(0,N.cn)("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)(f.P.div,{initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},className:(0,N.cn)("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:(0,N.cn)("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)(h.A,{className:"h-2 w-2"}),F?B?"Launchpad":z?"Building":"error"===P?"Needs attention":"Launchpad":"Welcome"]}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.16em]",(D=H.runState,"error"===D?"light"===t?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200":"success"===D||U?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"running"===D?"light"===t?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-300":"light"===t?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-400")),children:X})]}),(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)("p",{className:(0,N.cn)("whitespace-nowrap text-[9px] leading-[1rem] tracking-[0.08em]","light"===t?"text-[#33251c]":"text-slate-100"),children:F?B?"AGENTOS : OpenClaw is ready. Choose your first action below.":z?"AGENTOS : Building AgentOS Workspace.":"error"===P?"AGENTOS : Workspace creation needs attention.":"AGENTOS : OpenClaw is ready. Create the first workspace below.":"AGENTOS : Bring your local OpenClaw online."})}),(0,s.jsx)("div",{className:"mt-3 grid gap-1.5 sm:grid-cols-2",children:V.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>R(e.id),className:(0,N.cn)("rounded-[14px] border px-2.5 py-2 text-left transition-colors hover:opacity-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","light"===t?"focus-visible:ring-[#c8946f] focus-visible:ring-offset-[#fff7f1]":"focus-visible:ring-white/70 focus-visible:ring-offset-[#060a12]",e4(e.state,t)),"aria-pressed":a===e.id,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:(0,N.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-medium",e8(e.state,t)),children:"complete"===e.state?(0,s.jsx)(eG.A,{className:"h-2.5 w-2.5"}):e.order}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[8px] leading-[0.85rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",e6(e.state,t)),children:"complete"===e.state?"Ready":"current"===e.state?"Active":"Pending"})]})},e.id))}),F?(0,s.jsx)(th,{surfaceTheme:t,workspaceCount:W,defaultModelLabel:G,createProgress:O,createRunState:P}):"system"===a?(0,s.jsx)(to,{steps:K,surfaceTheme:t,statusCopy:Y,showDetails:Q,phaseLabel:Z,run:H,gatewayAuthNeedsSetup:ee,onOpenGatewayAuthSettings:A}):(0,s.jsx)(tc,{snapshot:e,surfaceTheme:t,statusCopy:Y,showDetails:Q,phaseLabel:Z,run:H,modelPhase:u,selectedModelId:b,modelSwitchFeedback:g,onSelectedModelIdChange:y,onClearModelSwitchFeedback:j,onOpenAddModels:S})]}),(0,s.jsxs)("div",{className:(0,N.cn)("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.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:F?(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-0.5 text-[8px] uppercase tracking-[0.16em]","light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-200"),children:B?"Setup complete":"running"===P?"Building workspace":"error"===P?"Needs attention":"Ready"}):"models"===a?(0,s.jsxs)(v.$,{type:"button",variant:"ghost",size:"sm",onClick:I,disabled:"running"===H.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)(eq.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Back"]}):null}),(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:F?(0,s.jsx)(s.Fragment,{children:L?(0,s.jsxs)(v.$,{type:"button",onClick:$,className:(0,N.cn)("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:["Enter AgentOS",(0,s.jsx)(eV.A,{className:"ml-1.5 h-3 w-3"})]}):z?(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-[9px] uppercase tracking-[0.16em]","light"===t?"border-[#d8c0b0] bg-white/85 text-[#8d725f]":"border-white/10 bg-white/[0.06] text-slate-300"),children:[(0,s.jsx)(d.A,{className:"h-3 w-3 animate-spin"}),"Building workspace"]}):(0,s.jsxs)(v.$,{type:"button",onClick:T,className:(0,N.cn)("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:["Create Workspace",(0,s.jsx)(eV.A,{className:"ml-1.5 h-3 w-3"})]})}):(0,s.jsxs)(s.Fragment,{children:["models"!==a||U?null:(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>S(),className:eX(t),children:"Open full Add Models"}),(0,s.jsx)(v.$,{type:"button",onClick:()=>{"system"===a?"dismiss"===et.kind?$():E?M():k():"dismiss"===et.kind?$():"set-default"===et.kind&&C(b||void 0)},disabled:"running"===H.runState||"select-model"===et.kind,className:(0,N.cn)("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"===H.runState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Working..."]}):(0,s.jsxs)(s.Fragment,{children:[et.label,(0,s.jsx)(eV.A,{className:"ml-1.5 h-3 w-3"})]})})]})})]})]})})}var tv=a(62820),ty=a(77262),tj=a(75084),tk=a(95506);function tN({open:e,target:t,surfaceTheme:a,previewState:r,preview:n,previewError:i,runState:l,statusMessage:o,resultMessage:c,backgroundLogPath:p,log:u,confirmText:m,onConfirmTextChange:h,onRefreshPreview:x,onExecute:g,onBackToSetup:b,onOpenChange:f}){let w="full-uninstall"===t?"FULL UNINSTALL":"RESET MISSION CONTROL",y="running"===l,j="success"===l||"error"===l,k=null!==t&&"ready"===r&&!y&&!j&&m.trim()===w,C="full-uninstall"===t?"Full Uninstall":"Reset AgentOS",S="light"===a?"border-rose-400/80 bg-rose-600 text-white hover:bg-rose-700":"border-rose-400/35 bg-rose-500/90 text-white hover:bg-rose-500";return(0,s.jsx)(eF.lG,{open:e,onOpenChange:e=>{(e||!y)&&f(e)},children:(0,s.jsxs)(eF.Cf,{className:(0,N.cn)("max-h-[88vh] w-[min(92vw,56rem)] max-w-[92vw] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl","light"===a?"border-[#dcc8bb] bg-[rgba(252,247,241,0.98)] text-[#402f24]":"border-white/12 bg-[rgba(7,12,22,0.96)] text-slate-100"),children:[(0,s.jsxs)(eF.c7,{children:[(0,s.jsxs)(eF.L3,{className:(0,N.cn)("flex items-center gap-2","light"===a?"text-[#3f2f24]":"text-white"),children:["full-uninstall"===t?(0,s.jsx)(tv.A,{className:"h-4 w-4"}):(0,s.jsx)(ty.A,{className:"h-4 w-4"}),C]}),(0,s.jsx)(eF.rr,{className:"light"===a?"text-[#7e6555]":"text-slate-400",children:"full-uninstall"===t?"Remove AgentOS state, task history, OpenClaw service and local state, then attempt to remove detected OpenClaw and AgentOS CLI installs.":"Remove AgentOS-managed workspaces, attached agents, task history, planner state, and browser state."})]}),"loading"===r?(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center gap-2 rounded-[16px] border px-4 py-4 text-sm","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}),"Loading the reset preview..."]}):null,"error"===r?(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-rose-200 bg-rose-50 text-rose-900":"border-rose-400/25 bg-rose-500/10 text-rose-100"),children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Preview could not be prepared."}),(0,s.jsx)("p",{className:"mt-1 text-sm",children:i||"Unknown reset preview error."})]}):null,n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,s.jsx)(tC,{label:"Delete folders",value:String(n.summary.deleteFolderCount),surfaceTheme:a}),(0,s.jsx)(tC,{label:"Keep folders",value:String(n.summary.metadataOnlyCount),surfaceTheme:a}),(0,s.jsx)(tC,{label:"Agents",value:String(n.summary.agentCount),surfaceTheme:a}),(0,s.jsx)(tC,{label:"Live agents",value:String(n.summary.liveAgentCount),surfaceTheme:a,danger:n.summary.liveAgentCount>0})]}),n.warnings.length>0?(0,s.jsx)("div",{className:(0,N.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-amber-300/90 bg-amber-50 text-amber-950":"border-amber-300/25 bg-amber-300/10 text-amber-50"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(W.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,s.jsx)("div",{className:"space-y-1 text-sm",children:n.warnings.map(e=>(0,s.jsx)("p",{children:e},e))})]})}):null,(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:"Workspace impact"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-sm","light"===a?"text-[#6d5647]":"text-slate-400"),children:"`Delete folder` removes the workspace directory. `Keep folder` only removes OpenClaw and AgentOS integration from that location."})]}),(0,s.jsx)(v.$,{type:"button",size:"sm",variant:"secondary",onClick:x,className:"light"===a?"border-[#dcc6b6] bg-white text-[#5d4739] hover:bg-[#f7eee7] hover:text-[#5d4739]":void 0,children:"Refresh preview"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:n.workspaces.map(e=>(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[14px] border px-3 py-3","light"===a?"border-[#ece0d6] 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:(0,N.cn)("text-sm font-medium","light"===a?"text-[#3f2f24]":"text-white"),children:e.name}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 break-all font-mono text-[11px]","light"===a?"text-[#7e6555]":"text-slate-400"),children:e.path})]}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]","delete-folder"===e.action?"light"===a?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-400/25 bg-rose-500/10 text-rose-200":"light"===a?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:"delete-folder"===e.action?"Delete folder":"Keep folder"})]}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-2 text-xs","light"===a?"text-[#6d5647]":"text-slate-400"),children:[e.agentCount," agents, ",e.runtimeCount," tracked runs, ",e.liveAgentCount," live agents."]}),(0,s.jsx)("div",{className:"mt-2 space-y-1",children:e.reasons.map(e=>(0,s.jsx)("p",{className:(0,N.cn)("text-xs","light"===a?"text-[#7e6555]":"text-slate-500"),children:e},e))})]},e.workspaceId))})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[(0,s.jsx)(tS,{title:"AgentOS state",items:n.missionControlPaths,surfaceTheme:a}),(0,s.jsx)(tS,{title:"Browser state",items:n.browserStorageKeys,surfaceTheme:a})]}),"full-uninstall"===t?(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[(0,s.jsx)(tS,{title:"OpenClaw state",items:n.openClawPaths,surfaceTheme:a}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:"CLI cleanup"}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:n.packageActions.map(e=>(0,s.jsxs)("div",{className:(0,N.cn)("min-w-0 overflow-hidden rounded-[14px] border px-3 py-3","light"===a?"border-[#ece0d6] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("min-w-0 break-all text-sm font-medium","light"===a?"text-[#3f2f24]":"text-white"),children:e.packageName}),(0,s.jsx)("span",{className:(0,N.cn)("shrink-0 rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",e.detected?"light"===a?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-400/25 bg-rose-500/10 text-rose-200":"light"===a?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:e.detected?"Scheduled":"Manual"})]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 break-words text-xs","light"===a?"text-[#6d5647]":"text-slate-400"),children:e.reason||"No extra detail."}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 whitespace-pre-wrap break-all font-mono text-[11px]","light"===a?"text-[#7e6555]":"text-slate-500"),children:e.command||"Automatic cleanup is not available."})]},e.packageName))})]})]}):null,(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-rose-200 bg-rose-50/70 text-rose-950":"border-rose-400/25 bg-rose-500/10 text-rose-50"),children:[(0,s.jsxs)(tk.J,{htmlFor:"reset-confirm",className:"text-sm font-medium text-inherit",children:["Type ",w," to continue"]}),(0,s.jsx)(tt.p,{id:"reset-confirm",value:m,onChange:e=>h(e.target.value),placeholder:w,disabled:y,className:(0,N.cn)("mt-2 h-10","light"===a?"border-rose-200 bg-white text-rose-950 placeholder:text-rose-300":"border-rose-300/20 bg-slate-950/50 text-rose-50 placeholder:text-rose-200/35")})]})]}):null,"idle"!==l||c||u?(0,s.jsxs)("div",{className:(0,N.cn)("min-w-0 overflow-hidden rounded-[16px] border px-4 py-4","error"===l?"light"===a?"border-rose-200 bg-rose-50 text-rose-950":"border-rose-400/25 bg-rose-500/10 text-rose-50":"success"===l?"light"===a?"border-emerald-200 bg-emerald-50 text-emerald-950":"border-emerald-400/25 bg-emerald-500/10 text-emerald-50":"light"===a?"border-[#e6d6ca] bg-white text-[#3f2f24]":"border-white/10 bg-white/[0.03] text-slate-100"),children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:o||c||"Reset status"}),c?(0,s.jsx)("p",{className:"mt-1 text-sm",children:c}):null,p?(0,s.jsxs)("p",{className:"mt-2 break-all font-mono text-[11px]",children:["Background cleanup log: ",p]}):null,(0,s.jsx)("pre",{className:(0,N.cn)("mt-3 max-h-56 w-full max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-[14px] border px-3 py-3 text-[11px] leading-relaxed","light"===a?"border-[#e6d6ca] bg-[#fffaf6] text-[#5f4a3d]":"border-white/10 bg-slate-950/45 text-slate-300"),children:u||"Waiting for command output..."})]}):null,(0,s.jsxs)(eF.Es,{children:[(0,s.jsx)(v.$,{type:"button",variant:j?"default":"secondary",onClick:()=>{"full-uninstall"===t&&"success"===l?b():f(!1)},disabled:y,className:j&&"light"===a?"bg-[#5c4437] text-white hover:bg-[#4d382d]":j?"bg-cyan-400 text-slate-950 hover:bg-cyan-300":void 0,children:"full-uninstall"===t&&"success"===l?"Back to setup":j?"Done":"Close"}),j?null:(0,s.jsx)(v.$,{type:"button",onClick:g,disabled:!k,className:S,children:y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Running..."]}):(0,s.jsxs)(s.Fragment,{children:["full-uninstall"===t?(0,s.jsx)(tv.A,{className:"mr-1.5 h-3.5 w-3.5"}):(0,s.jsx)(tj.A,{className:"mr-1.5 h-3.5 w-3.5"}),C]})})]})]})})}function tC({label:e,value:t,surfaceTheme:a,danger:r=!1}){return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[16px] border px-4 py-3",r?"light"===a?"border-rose-200 bg-rose-50":"border-rose-400/20 bg-rose-500/10":"light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.16em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:e}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 font-display text-lg","light"===a?"text-[#3f2f24]":"text-white"),children:t})]})}function tS({title:e,items:t,surfaceTheme:a}){return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:e}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:t.map(e=>(0,s.jsx)("p",{className:(0,N.cn)("break-all rounded-[12px] border px-3 py-2 font-mono text-[11px]","light"===a?"border-[#ece0d6] bg-[#fffaf6] text-[#6d5647]":"border-white/8 bg-white/[0.03] text-slate-400"),children:e},e))})]})}var tA=a(24809),tT=a.n(tA),t$=a(48758),tM=a(96551),tI=a(9152),tR=a(41363),tO=a(3324),tP=a(47377),t_=a(20872),tD=a(4974),tE=a(12482),tL=a(16055);function tU(e,t){var a,s,r,n,i,l;let o,c=tF(e?.fallbackCounts),d=!function(e,t){if(0===e.length)return!1;if(!t)return!0;let a=Date.parse(t);return!Number.isFinite(a)||e.some(e=>{let t=Date.parse(e.at);return!Number.isFinite(t)||t>=a})}(e?.recentFallbackDiagnostics??[],e?.lastConnectedAt??null)?0:c,p=function(e){switch(e){case"cli-forced":return"CLI forced";case"connected":return"Connected";case"connecting":return"Connecting";case"idle":return"Idle";case"closed":return"Closed";case"error":return"Error";default:return"Unknown"}}(e?.connectionState),u=function(e){switch(e){case"live":return"Live";case"retrying":return"Retrying";default:return"Connecting"}}(t);return{modeLabel:"native-ws"===(a=e?.mode)?"Native WS":"cli"===a?"CLI forced":"Unknown",gatewayModeLabel:function(e){switch(e){case"native-ws":return"native-ws";case"cli-forced":return"cli-forced";case"fallback-active":return"fallback-active";case"degraded":return"degraded";case"unreachable":return"unreachable";default:return"unknown"}}(e?.gatewayMode),statusLabel:(s=e,s?.statusLabel?s.statusLabel:s?"cli"===s.mode||"cli-forced"===s.connectionState?"CLI fallback forced":tF(s.fallbackCounts)>0?"CLI fallback used":"connected"===s.connectionState?"Native Gateway: OK":"error"===s.connectionState?"Native Gateway: Unreachable":"Native Gateway: Degraded":"Native Gateway: Unknown"),connectionLabel:p,protocolLabel:"number"==typeof(r=e?.protocolVersion)&&Number.isFinite(r)?`v${r}`:"Unknown",protocolRangeLabel:(n=e?.protocolRange)&&"number"==typeof n.min&&"number"==typeof n.max?`v${n.min}-v${n.max} supported`:"Unknown",streamLabel:u,fallbackTotal:c,fallbackOperationCount:tz(e?.fallbackCounts),fallbackSummaryLabel:(i=e?.fallbackTotal??c,o=tz(e?.fallbackCounts),i<=0||o<=0?"CLI fallback used: 0 operations":`CLI fallback used: ${i} ${1===i?"operation":"operations"} across ${o} ${1===o?"method":"methods"}`),lastConnectedLabel:tW(e?.lastConnectedAt),lastDisconnectedLabel:tW(e?.lastDisconnectedAt),lastNativeError:e?.lastNativeError?.trim()||null,recovery:e?.recovery?.trim()||null,recentFallbackDiagnostics:e?.recentFallbackDiagnostics??[],statusTone:"retrying"===(l={gatewayMode:e?.gatewayMode,connectionState:e?.connectionState,mode:e?.mode,streamState:t,fallbackTotal:d}).streamState||"error"===l.connectionState||"unreachable"===l.gatewayMode?"danger":"cli"===l.mode||"cli-forced"===l.connectionState||"closed"===l.connectionState||"connecting"===l.connectionState||"fallback-active"===l.gatewayMode||"degraded"===l.gatewayMode||l.fallbackTotal>0?"warning":"connected"===l.connectionState&&"live"===l.streamState?"success":"neutral"}}function tF(e){return Object.values(e??{}).reduce((e,t)=>Number.isFinite(t)&&t>0?e+t:e,0)}function tz(e){return Object.values(e??{}).filter(e=>Number.isFinite(e)&&e>0).length}function tW(e){if(!e)return"Not yet";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}let tB=[{value:"auto",label:"Auto"},{value:"local-prefix",label:"Local prefix"},{value:"global-path",label:"Global PATH"},{value:"custom",label:"Custom"}],tG=[{id:"openclaw",label:"OpenClaw",icon:t$.A},{id:"gateway",label:"Gateway",icon:tM.A},{id:"models",label:"Models",icon:tI.A},{id:"workspace",label:"Workspace",icon:tR.A},{id:"agents",label:"Agents",icon:tO.A},{id:"diagnostics",label:"Diagnostics",icon:_.A},{id:"advanced",label:"Advanced",icon:tP.A},{id:"danger-zone",label:"Danger Zone",icon:W.A,destructive:!0}];function tq(e){var t,a,r,l,o,c,p,u,m;let{snapshot:h,surfaceTheme:x,connectionState:b,gatewayDraft:f,workspaceRootDraft:w,openClawBinarySelection:y,isSavingGateway:j,isSavingWorkspaceRoot:k,isSavingOpenClawBinary:C,isCheckingForUpdates:S,updateRunState:A,selectedModelId:T,modelOnboardingRunState:$,gatewayControlAction:M,lastCheckedAt:I,onGatewayDraftChange:R,onWorkspaceRootDraftChange:O,onSelectedModelIdChange:P,onSaveGatewaySettings:D,onSaveWorkspaceRootSettings:E,onCheckForUpdates:L,onControlGateway:U,onOpenSetupWizard:F,onRunModelRefresh:z,onRunModelSetDefault:B,onOpenAddModels:G,onOpenUpdateDialog:q,onOpenResetDialog:V,onOpenClawBinarySelectionModeChange:K,onOpenClawBinarySelectionPathChange:J,onSaveOpenClawBinarySettings:H,installSummary:Y,sidebarOpen:Z=!1}=e,[Q,X]=(0,i.useState)(null),[ee,et]=(0,i.useState)(null),[ea,es]=(0,i.useState)("token"),[er,en]=(0,i.useState)(""),[ei,el]=(0,i.useState)(null),[eo,ec]=(0,i.useState)(!1),[ed,ep]=(0,i.useState)(!1),[eu,em]=(0,i.useState)(!1),[eh,ex]=(0,i.useState)(!1),[eg,eb]=(0,i.useState)(()=>t4()),ef=!!(h.diagnostics.updateAvailable&&h.diagnostics.latestVersion),ew=!!(h.diagnostics.version&&!h.diagnostics.latestVersion&&!h.diagnostics.updateError),ev=h.diagnostics.version||"unknown",ey=h.diagnostics.latestVersion||null,ej=h.diagnostics.updateInfo?.trim()||null,ek=h.diagnostics.updateError?.trim()||null,eN=h.diagnostics.modelReadiness.resolvedDefaultModel||h.diagnostics.modelReadiness.defaultModel||"",eC=T||eN||"",eS=h.models.find(e=>e.id===eC),eA=eS?.provider||h.diagnostics.modelReadiness.preferredLoginProvider||function(e){if(!e)return null;let[t]=e.split("/");return t||null}(eN)||"Not connected",eT=(0,i.useMemo)(()=>h.diagnostics.commandHistory??[],[h.diagnostics.commandHistory]).slice(0,6),e$=(0,i.useMemo)(()=>({ok:eT.filter(e=>"ok"===e.status).length,failed:eT.filter(e=>"ok"!==e.status).length}),[eT]),eM=(0,i.useMemo)(()=>tU(h.diagnostics.transport,b),[b,h.diagnostics.transport]),eI=h.diagnostics.capabilityMatrix,eR=eI?.compatibility,eO=(h.diagnostics.gatewayFallbackDiagnostics?.length?h.diagnostics.gatewayFallbackDiagnostics:eI?.fallbackDiagnostics??[]).slice(0,4),eP=Q?Q.native.ok?"Authenticated":function(e){switch(e){case"auth":return"Needs credential";case"scope-limited":return"Needs scope repair";case"rate-limited":return"Rate limited";case"disabled":return"Disabled";case"unreachable":return"Unreachable";case"timeout":return"Timed out";case"malformed-response":return"Invalid response";default:return"Check failed"}}(Q.native.kind):"Unknown",e_=(0,i.useCallback)(async()=>{ec(!0),et(null);try{X(await tX())}catch(e){et(e instanceof Error?e.message:"Unable to check Gateway auth status.")}finally{ec(!1)}},[]);(0,i.useEffect)(()=>{e_()},[e_]),(0,i.useEffect)(()=>{let e=()=>{eb(t4()),t3()};return window.addEventListener("hashchange",e),e(),()=>{window.removeEventListener("hashchange",e)}},[]),(0,i.useEffect)(()=>{t3()},[eg]);let eD=async()=>{let e=er.trim();if(!e)return void et("Gateway token/password is required.");ep(!0),et(null),el(null);try{let t=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"saveCredential",kind:ea,value:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Gateway credential could not be saved.")}let a=await t.json();X(a.authStatus),en(""),el("Saved to .env.local and applied to the current AgentOS server session.")}catch(e){et(e instanceof Error?e.message:"Unable to save Gateway credential.")}finally{ep(!1)}},eE=async()=>{em(!0),et(null),el(null);try{let e=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"generateLocalToken"})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Gateway token could not be generated.")}let t=await e.json();X(t.authStatus),el("Generated a local Gateway token and applied it to AgentOS.")}catch(e){et(e instanceof Error?e.message:"Unable to generate Gateway token.")}finally{em(!1)}},eL=async()=>{ex(!0),et(null),el(null);try{let e=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"repairDeviceAccess"})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Gateway device access could not be repaired.")}let t=await e.json();X(t.authStatus),el("Local Gateway device access repaired for AgentOS.")}catch(e){et(e instanceof Error?e.message:"Unable to repair Gateway access.")}finally{ex(!1)}};return(0,s.jsx)("main",{className:(0,N.cn)("relative z-10 min-h-screen","light"===x?"text-[#2c211a]":"text-slate-100"),children:(0,s.jsx)("section",{className:(0,N.cn)("min-w-0 pb-8 pl-[72px] pr-3 pt-[86px] sm:pl-[84px] sm:pr-6 lg:mr-[84px] lg:px-7 xl:px-8",Z?"lg:ml-[316px]":"lg:ml-[80px]"),children:(0,s.jsxs)("div",{className:"mx-auto max-w-[1160px] 2xl:max-w-[1240px]",children:[(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsx)("nav",{"aria-label":"Settings sections",className:(0,N.cn)("flex flex-wrap gap-2 rounded-[22px] border p-2 shadow-[0_18px_44px_rgba(0,0,0,0.16)] backdrop-blur-xl","light"===x?"border-[#dfd0c2]/90 bg-[#fffaf3]/80":"border-white/[0.08] bg-[#0d1624]/88"),children:tG.map(e=>{let t=eg===e.id,a=e.icon;return(0,s.jsxs)(tT(),{href:`/settings#${e.id}`,scroll:!1,"aria-current":t?"page":void 0,onClick:()=>{eb(e.id),t3()},className:(0,N.cn)("inline-flex h-10 items-center gap-2 rounded-[14px] border px-3 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/40",t&&!e.destructive?"border-cyan-300/26 bg-cyan-300/[0.14] text-cyan-50 shadow-[0_10px_26px_rgba(34,211,238,0.12)]":t&&e.destructive?"border-rose-300/28 bg-rose-300/[0.14] text-rose-50 shadow-[0_10px_26px_rgba(244,63,94,0.12)]":"light"===x?"border-[#e2d1c4] bg-white/72 text-[#6b5546] hover:bg-[#fffdf9] hover:text-[#2f251f]":"border-white/[0.08] bg-white/[0.035] text-slate-300 hover:border-white/[0.14] hover:bg-white/[0.07] hover:text-white"),children:[(0,s.jsx)(a,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{children:e.label})]},e.id)})})}),(0,s.jsxs)("div",{className:"mt-5 flex flex-col gap-4",children:["openclaw"===eg?(0,s.jsx)("section",{id:"openclaw",className:"scroll-mt-24",children:(0,s.jsxs)("div",{className:(0,N.cn)("panel-surface panel-glow min-h-full overflow-hidden rounded-[22px] p-4","light"===x?"border-white/[0.08] bg-[linear-gradient(180deg,rgba(12,19,32,0.98),rgba(6,10,18,0.97))] text-white":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(16,24,38,0.98),rgba(7,11,18,0.96))] text-slate-100"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,N.cn)("flex h-10 w-10 shrink-0 items-center justify-center rounded-full border","light"===x?"border-white/10 bg-white/[0.04] text-emerald-200":"border-cyan-300/15 bg-cyan-300/10 text-cyan-200"),children:(0,s.jsx)(t$.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("h2",{className:"font-display text-lg",children:"OpenClaw"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-xs leading-5","light"===x?"text-white/54":"text-slate-400"),children:"Source of truth for runtime and control state."})]})]}),(0,s.jsxs)("div",{className:"mt-5 grid grid-cols-2 gap-3",children:[(0,s.jsx)(tK,{label:"Current version",value:`v${h.diagnostics.version||"unknown"}`,surfaceTheme:x,dark:!0}),(0,s.jsx)(tK,{label:"Latest available",value:h.diagnostics.latestVersion?`v${h.diagnostics.latestVersion}`:"Unknown",badge:ef?"Update":"Stable",surfaceTheme:x,dark:!0})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,s.jsxs)(v.$,{type:"button",onClick:q,disabled:!ef||"running"===A,className:"h-9 rounded-full bg-emerald-600 px-4 text-xs text-white hover:bg-emerald-500",children:["running"===A?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(t_.A,{className:"h-3.5 w-3.5"}),"Update now"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void L(),disabled:S||"running"===A,className:t7(x,"px-4"),children:[(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"}),"Check"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>F(),className:t7(x,"px-4"),children:[(0,s.jsx)(tD.A,{className:"h-3.5 w-3.5"}),"Open wizard"]})]}),(0,s.jsx)(tQ,{surfaceTheme:x,isCheckingForUpdates:S,isUpdateRegistryLoading:ew,hasUpdateAvailable:ef,currentVersion:ev,latestVersion:ey,updateInfo:ej,updateError:ek,lastCheckedAt:I,isUpdateRunning:"running"===A}),(0,s.jsxs)("div",{className:"mt-5 grid gap-3 border-t border-white/10 pt-4 sm:grid-cols-2",children:[(0,s.jsx)(tK,{label:"Detected install",value:Y.label||"Unknown",surfaceTheme:x,dark:!0,compact:!0}),(0,s.jsx)(tK,{label:"Resolved path",value:t2(y.resolvedPath||"openclaw",26),surfaceTheme:x,dark:!0,compact:!0})]}),(0,s.jsxs)("div",{className:"mt-4 rounded-[18px] border border-white/10 bg-white/[0.035] p-3.5",children:[(0,s.jsx)(tk.J,{className:t8(x),children:"OpenClaw binary mode"}),(0,s.jsx)("div",{className:"mt-3 grid grid-cols-2 gap-2",children:tB.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>K(e.value),className:(0,N.cn)("h-9 rounded-full border px-3 text-xs transition-colors",y.mode===e.value?"border-emerald-300 bg-emerald-300/14 text-emerald-100":"light"===x?"border-white/10 bg-white/[0.03] text-white/70 hover:bg-white/[0.08]":"border-white/10 bg-[#121d2d] text-slate-200 hover:bg-[#182538]"),children:e.label},e.value))}),"custom"===y.mode?(0,s.jsx)(tt.p,{value:y.path??"",onChange:e=>J(e.target.value),placeholder:"/path/to/openclaw",className:t6(x,"mt-3")}):null,(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void H(y),disabled:C,className:t7(x,"mt-3 w-full"),children:[C?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tE.A,{className:"h-3.5 w-3.5"}),"Save selection"]})]})]})}):null,"gateway"===eg?(0,s.jsx)("section",{id:"gateway",className:"scroll-mt-24",children:(0,s.jsxs)(tV,{title:"Gateway",icon:tM.A,surfaceTheme:x,children:[(0,s.jsx)(tJ,{surfaceTheme:x,rows:[["Status",`${"remote"===(t=h).diagnostics.bindMode||t.diagnostics.configuredGatewayUrl?"Remote":"Local"} / ${h.diagnostics.loaded||h.diagnostics.rpcOk?"Online":"Offline"}`],["Native Gateway",eM.statusLabel],["Gateway mode",eM.gatewayModeLabel],["CLI fallback used",`${eM.fallbackTotal} operations`],["Endpoint",h.diagnostics.gatewayUrl||"Not configured"],["Auth status",eP],["Protocol",`${eM.protocolRangeLabel}, connected: ${eM.protocolLabel}`],["Compatibility",function(e){switch(e?.protocol.status){case"compatible":return"Compatible";case"unsupported":return"Unsupported";default:return"Unknown"}}(eR)],["Contract audit",function(e){if(!e)return"Unknown";let t=function(e){switch(e){case"gateway-handshake":return"handshake";case"disabled":return"disabled";case"unavailable":return"unavailable";default:return e}}(e.source);switch(e.status){case"advertised":return`Advertised via ${t}`;case"verified":return`Verified via ${t}`;case"drift":return`Drift via ${t}`;default:return`Unknown via ${t}`}}(eR?.methodContract)],["Contract gaps",(a=eR?.methodContract,r=eI?.operations,a?"advertised"===a.status||"verified"===a.status?"None":"unknown"===a.status?a.reason:a.missingOperations.length>0?t1(a.missingOperations,r):`${a.missingMethodCount} methods`:"Unknown")],["Native ops",(l=eR)?`${l.nativeOperationCount} native / ${l.degradedOperationCount} fallback`:"Unknown"],["Alias ops",(o=eR?.aliasOperations,c=eI?.operations,o?o.length>0?t1(o,c):"None":"Unknown")],["Fallback ops",(p=eR?.degradedOperations,u=eI?.operations,p?p.length>0?t1(p,u):"None":"Unknown")],["Native chat",t0(eI?.nativeMissionDispatch)],["Config patch",t0(eI?.configPatch)],["Events",t0(eI?.eventBridge)]],successIndex:1}),eM.recovery||eM.lastNativeError?(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[18px] border p-3.5",t9(x)),children:[(0,s.jsx)("p",{className:t8(x),children:"Native Gateway diagnostic"}),eM.lastNativeError?(0,s.jsxs)("p",{className:(0,N.cn)("mt-2 text-xs leading-5","light"===x?"text-[#6b5546]":"text-slate-300"),children:["Last native error: ",eM.lastNativeError]}):null,eM.recovery?(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-xs leading-5","light"===x?"text-[#52735e]":"text-slate-400"),children:["Recovery: ",eM.recovery]}):null]}):null,(0,s.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(tk.J,{className:t8(x),children:"Gateway endpoint"}),(0,s.jsx)(tt.p,{value:f,onChange:e=>R(e.target.value),placeholder:"ws://127.0.0.1:18789",className:t6(x,"mt-2")})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)(v.$,{type:"button",onClick:()=>void D(f.trim()||null),disabled:j,className:"h-9 rounded-full bg-emerald-600 text-xs text-white hover:bg-emerald-500",children:[j?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tE.A,{className:"h-3.5 w-3.5"}),"Save endpoint"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void D(null),disabled:j,className:t7(x),children:[(0,s.jsx)(ty.A,{className:"h-3.5 w-3.5"}),"Clear"]})]})]}),(0,s.jsx)("div",{className:"mt-4 grid grid-cols-3 gap-2",children:["start","stop","restart"].map(e=>(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void U(e),disabled:null!==M,className:(0,N.cn)(t7(x),"capitalize"),children:[M===e?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):null,e]},e))}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[18px] p-3.5","light"===x?"border border-emerald-200 bg-emerald-50/55":"border border-cyan-300/12 bg-cyan-300/[0.06]"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(tL.A,{className:(0,N.cn)("mt-0.5 h-4 w-4","light"===x?"text-emerald-700":"text-cyan-200")}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-sm font-medium","light"===x?"text-[#2f624b]":"text-slate-100"),children:"Native Gateway auth"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-xs leading-5","light"===x?"text-[#6f836f]":"text-slate-400"),children:"Use local repair when AgentOS reports missing operator scopes."})]})]}),(0,s.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void eL(),disabled:eh,className:t7(x,"px-3","gateway-contrast"),children:[eh?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tD.A,{className:"h-3.5 w-3.5"}),"Repair local access"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void eE(),disabled:eu,className:t7(x,"px-3","gateway-contrast"),children:[eu?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tL.A,{className:"h-3.5 w-3.5"}),"Generate token"]})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 sm:grid-cols-[112px_1fr]",children:[(0,s.jsxs)("select",{value:ea,onChange:e=>es(e.target.value),className:t6(x),children:[(0,s.jsx)("option",{value:"token",children:"Token"}),(0,s.jsx)("option",{value:"password",children:"Password"})]}),(0,s.jsx)(tt.p,{type:"password",value:er,onChange:e=>en(e.target.value),placeholder:"Paste known credential",className:t6(x)})]}),(0,s.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[(0,s.jsxs)(v.$,{type:"button",onClick:()=>void eD(),disabled:ed,className:"h-9 rounded-full bg-emerald-600 text-xs text-white hover:bg-emerald-500",children:[ed?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tE.A,{className:"h-3.5 w-3.5"}),"Save credential"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void e_(),disabled:eo,className:t7(x,void 0,"gateway-contrast"),children:[eo?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"}),"Test auth"]})]}),ee||ei||Q?.native.issue?(0,s.jsx)("p",{className:(0,N.cn)("mt-3 text-xs leading-5",ee?"light"===x?"text-red-700":"text-rose-300":"light"===x?"text-[#52735e]":"text-slate-400"),children:ee||ei||Q?.native.issue}):null]})]})}):null,"models"===eg?(0,s.jsx)("section",{id:"models",className:"scroll-mt-24",children:(0,s.jsxs)(tV,{title:"Models",icon:tI.A,surfaceTheme:x,children:[(0,s.jsx)(tJ,{surfaceTheme:x,rows:[["Default model",eN||"Not selected"],["Provider",eA],["Available",`${h.diagnostics.modelReadiness.availableModelCount} of ${h.diagnostics.modelReadiness.totalModelCount}`]]}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)(tk.J,{className:t8(x),children:"Model"}),(0,s.jsxs)("select",{value:eC,onChange:e=>P(e.target.value),className:t6(x,"mt-2"),children:[(0,s.jsx)("option",{value:"",children:"Choose model"}),h.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name||e.id},e.id))]})]}),(0,s.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[(0,s.jsxs)(v.$,{type:"button",onClick:()=>void B(eC),disabled:!eC||"running"===$,className:"h-9 rounded-full bg-emerald-600 text-xs text-white hover:bg-emerald-500",children:["running"===$?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(eG.A,{className:"h-3.5 w-3.5"}),"Use selected"]}),(0,s.jsx)(v.$,{type:"button",variant:"secondary",onClick:()=>G(null),className:t7(x),children:"Add models"})]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void z(),disabled:"running"===$,className:(0,N.cn)(t7(x),"mt-3 w-full"),children:[(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"}),"Refresh models"]})]})}):null,"workspace"===eg?(0,s.jsx)("section",{id:"workspace",className:"scroll-mt-24",children:(0,s.jsxs)(tV,{title:"Workspace",icon:tR.A,surfaceTheme:x,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(tk.J,{className:t8(x),children:"Workspace root"}),(0,s.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,s.jsx)(tt.p,{value:w,onChange:e=>O(e.target.value),placeholder:"~/Documents/AgentOS",className:t6(x)}),(0,s.jsx)("button",{type:"button","aria-label":"Copy workspace root",onClick:()=>{var e;return e=w||h.diagnostics.workspaceRoot,void("u">typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(e))},className:(m=x,(0,N.cn)("flex h-10 w-10 shrink-0 items-center justify-center rounded-[16px] border","light"===m?"border-[#e2d1c4] bg-white text-[#7b6353]":"border-white/10 bg-[#121d2d] text-slate-200 hover:bg-[#182538]")),children:(0,s.jsx)(eU.A,{className:"h-3.5 w-3.5"})})]})]}),(0,s.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[(0,s.jsxs)(v.$,{type:"button",onClick:()=>void E(w.trim()||null),disabled:k,className:"h-9 rounded-full bg-emerald-600 text-xs text-white hover:bg-emerald-500",children:[k?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(tE.A,{className:"h-3.5 w-3.5"}),"Save"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>void E(null),disabled:k,className:t7(x),children:[(0,s.jsx)(ty.A,{className:"h-3.5 w-3.5"}),"Reset"]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[18px] p-3.5","light"===x?"border border-[#eadbcf] bg-[#fbf4ec]/78":"border border-white/[0.08] bg-[#101a2a]/92"),children:[(0,s.jsx)("p",{className:t8(x),children:"Current root"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-2 break-all text-sm","light"===x?"text-[#4f3e34]":"text-slate-200"),children:t2(h.diagnostics.workspaceRoot,56)})]})]})}):null,"diagnostics"===eg?(0,s.jsx)("section",{id:"diagnostics",className:"scroll-mt-24",children:(0,s.jsx)(tV,{title:"Diagnostics",icon:_.A,surfaceTheme:x,action:(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs","light"===x?"border-[#e2d1c4] bg-white text-[#7b6353]":"border-white/[0.08] bg-[#101a2a]/92 text-slate-300"),children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"}),e$.ok," OK",e$.failed?(0,s.jsxs)("span",{className:"text-red-600",children:[e$.failed," failed"]}):null]}),children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(tY,{summary:eM,surfaceTheme:x}),eO.length?(0,s.jsxs)("div",{className:(0,N.cn)("border-l-2 py-1 pl-3","light"===x?"border-amber-300":"border-amber-300/45"),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:t8(x),children:"Gateway fallback diagnostics"}),(0,s.jsxs)("span",{className:(0,N.cn)("text-[11px]","light"===x?"text-[#8a7464]":"text-slate-400"),children:[eO.length," recent"]})]}),(0,s.jsx)("div",{className:"mt-2 space-y-2",children:eO.map(e=>(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:(0,N.cn)("text-sm font-medium","light"===x?"text-[#3b2d24]":"text-slate-100"),children:e.operationLabel}),(0,s.jsx)("code",{className:(0,N.cn)("rounded-full px-2 py-0.5 text-[10px]","light"===x?"bg-[#f3e5d8] text-[#7b6353]":"bg-white/[0.06] text-slate-300"),children:e.operation}),(0,s.jsx)("span",{className:(0,N.cn)("text-[11px]","light"===x?"text-amber-700":"text-amber-200"),children:function(e){switch(e){case"auth":return"Needs credential";case"scope-limited":return"Needs scope repair";case"protocol-mismatch":return"Protocol mismatch";case"rate-limited":return"Rate limited";case"unsupported":return"Unsupported method";case"disabled":return"Disabled";case"unreachable":return"Unreachable";case"timeout":return"Timed out";case"malformed-response":return"Invalid response";default:return"Gateway fallback"}}(e.kind)}),(0,s.jsx)("span",{className:(0,N.cn)("text-[11px]","light"===x?"text-[#8a7464]":"text-slate-500"),children:t5(e.at)})]}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-xs","light"===x?"text-[#7b6353]":"text-slate-400"),children:["Reason: ",e.issue]}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-0.5 text-xs","light"===x?"text-[#8a7464]":"text-slate-500"),children:["Recovery: ",e.recovery||function(e){switch(e){case"auth":return"Check the Gateway token/password, then restart AgentOS.";case"scope-limited":return"Repair local device access so AgentOS has operator scopes.";case"protocol-mismatch":return"Update OpenClaw or AgentOS so the Gateway protocol versions overlap.";case"rate-limited":return"Wait for the Gateway cooldown to expire, then retry the config action.";case"unsupported":return"Update OpenClaw or check AgentOS/OpenClaw compatibility for this method.";case"timeout":return"Restart the Gateway and inspect OpenClaw diagnostics for slow handlers.";case"unreachable":return"Start or repair the OpenClaw Gateway.";case"malformed-response":return"Update OpenClaw or report the incompatible Gateway response.";default:return"Inspect diagnostics and retry after Gateway repair."}}(e.kind)]})]},`${e.at}-${e.operation}`))})]}):null,eT.length?eT.map(e=>(0,s.jsxs)("details",{className:(0,N.cn)("group rounded-[16px] border","light"===x?"border-[#e7d8ca] bg-[#fffdf9]":"border-white/[0.08] bg-[#101a2a]/92"),children:[(0,s.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-3 px-3.5 py-2.5",children:[(0,s.jsxs)("code",{className:(0,N.cn)("min-w-0 flex-1 truncate font-mono text-[11px]","light"===x?"text-[#3b2d24]":"text-slate-200"),children:[e.command," ",e.args.join(" ")]}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[9px] uppercase tracking-[0.12em]","ok"===e.status?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-red-200 bg-red-50 text-red-700"),children:e.status}),(0,s.jsxs)("span",{className:(0,N.cn)("hidden text-xs sm:inline","light"===x?"text-[#9a8271]":"text-slate-400"),children:[e.durationMs," ms"]}),(0,s.jsx)(g.A,{className:(0,N.cn)("h-4 w-4 transition-transform group-open:rotate-180","light"===x?"text-[#9a8271]":"text-slate-400")})]}),(0,s.jsxs)("div",{className:(0,N.cn)("border-t p-3.5","light"===x?"border-[#eadbcf]":"border-white/[0.08]"),children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(tH,{title:"stdout",value:e.stdoutPreview,surfaceTheme:x}),(0,s.jsx)(tH,{title:"stderr",value:e.stderrPreview,surfaceTheme:x})]}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-3 text-xs","light"===x?"text-[#8a7464]":"text-slate-400"),children:["Exit code: ",e.exitCode??"n/a"," | Started: ",t5(e.startedAt)]})]})]},e.id)):(0,s.jsx)(tZ,{title:"No recent CLI calls",detail:"Diagnostics will appear after AgentOS uses fallback commands.",surfaceTheme:x})]})})}):null,"agents"===eg?(0,s.jsx)("section",{id:"agents",className:"scroll-mt-24",children:(0,s.jsxs)(tV,{title:"Agents",icon:tO.A,surfaceTheme:x,children:[(0,s.jsx)(tJ,{surfaceTheme:x,rows:[["Agents",String(h.agents.length)],["Workspaces",String(h.workspaces.length)],["Active runtimes",String(h.runtimes.filter(e=>"running"===e.status).length)]]}),(0,s.jsx)(v.$,{asChild:!0,variant:"secondary",className:(0,N.cn)(t7(x),"mt-4 w-full"),children:(0,s.jsx)(tT(),{href:"/",children:"Open mission control"})})]})}):null,"advanced"===eg?(0,s.jsx)("section",{id:"advanced",className:"scroll-mt-24",children:(0,s.jsxs)(tV,{title:"Advanced",icon:tP.A,surfaceTheme:x,children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(tK,{label:"Install method",value:h.diagnostics.updateInstallKind||Y.label||"Unknown",surfaceTheme:x}),(0,s.jsx)(tK,{label:"Updater",value:h.diagnostics.updatePackageManager||"Unknown",surfaceTheme:x}),(0,s.jsx)(tK,{label:"Last checked",value:I?new Date(I).toLocaleTimeString():"Not checked",surfaceTheme:x})]}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[18px] p-3.5","light"===x?"border border-[#eadbcf] bg-[#fbf4ec]/78":"border border-white/[0.08] bg-[#101a2a]/92"),children:[(0,s.jsx)("p",{className:t8(x),children:"Install root"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-2 break-all text-sm","light"===x?"text-[#4f3e34]":"text-slate-200"),children:t2(h.diagnostics.updateRoot||Y.root||"Not detected",80)})]})]})}):null,"danger-zone"===eg?(0,s.jsx)("section",{id:"danger-zone",className:"scroll-mt-24",children:(0,s.jsx)("div",{className:(0,N.cn)("rounded-[22px] p-4 shadow-[0_18px_44px_rgba(185,28,28,0.06)]","light"===x?"border border-red-200 bg-red-50/58":"border border-rose-400/20 bg-rose-500/[0.08]"),children:(0,s.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,N.cn)("flex h-10 w-10 shrink-0 items-center justify-center rounded-full border","light"===x?"border-red-200 bg-white text-red-600":"border-rose-300/20 bg-rose-400/10 text-rose-200"),children:(0,s.jsx)(W.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:(0,N.cn)("font-display text-lg","light"===x?"text-red-700":"text-rose-100"),children:"Danger Zone"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1.5 max-w-2xl text-sm leading-6","light"===x?"text-red-700/72":"text-rose-100/80"),children:"These actions are destructive and cannot be undone. Confirmation is required before anything runs."})]})]}),(0,s.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2 md:min-w-[340px]",children:[(0,s.jsxs)(v.$,{type:"button",variant:"destructive",onClick:()=>V("mission-control"),className:"h-9 rounded-full bg-red-600 text-xs text-white hover:bg-red-500",children:[(0,s.jsx)(tj.A,{className:"h-3.5 w-3.5"}),"Reset AgentOS"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:()=>V("full-uninstall"),className:(0,N.cn)("h-9 rounded-full text-xs","light"===x?"border-red-200 bg-white text-red-700 hover:bg-red-50":"border-rose-300/20 bg-[#121d2d] text-rose-100 hover:bg-[#182538]"),children:[(0,s.jsx)(tj.A,{className:"h-3.5 w-3.5"}),"Full uninstall"]})]})]})})}):null]})]})})})}function tV({title:e,icon:t,children:a,action:r,surfaceTheme:n}){return(0,s.jsxs)("div",{className:(0,N.cn)("min-h-full rounded-[22px] p-4 shadow-[0_20px_54px_rgba(101,74,54,0.07)] backdrop-blur-xl","light"===n?"border-[#dfd0c2]/90 bg-[#fffaf3]/80 text-[#2d211b]":"border-white/[0.08] bg-[#0d1624]/96 text-slate-100 shadow-[0_20px_54px_rgba(0,0,0,0.26)]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"light"===n?"flex h-10 w-10 items-center justify-center rounded-full border border-emerald-200 bg-emerald-50 text-emerald-700":"flex h-10 w-10 items-center justify-center rounded-full border border-cyan-300/15 bg-cyan-300/10 text-cyan-200",children:(0,s.jsx)(t,{className:"h-4 w-4"})}),(0,s.jsx)("h2",{className:(0,N.cn)("font-display text-lg","light"===n?"text-[#2d211b]":"text-slate-100"),children:e})]}),r]}),(0,s.jsx)("div",{className:"mt-4",children:a})]})}function tK({label:e,value:t,badge:a,surfaceTheme:r,dark:n=!1,compact:i=!1}){let l=n||"dark"===r;return(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px]",l?"text-white/54":"text-[#8a7464]"),children:e}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("min-w-0 truncate font-medium",i?"text-sm":"text-[1.05rem]",l?"text-white":"text-[#2f251f]"),title:t,children:t}),a?(0,s.jsx)("span",{className:(0,N.cn)("shrink-0 rounded-full border px-2 py-0.5 text-[9px] uppercase tracking-[0.12em]",l?"border-emerald-300/20 bg-emerald-300/10 text-emerald-100":"border-emerald-200 bg-emerald-50 text-emerald-700"),children:a}):null]})]})}function tJ({rows:e,successIndex:t,surfaceTheme:a}){let r="dark"===a;return(0,s.jsx)("div",{className:(0,N.cn)("overflow-hidden rounded-[18px] border","light"===a?"border-[#eadbcf] bg-[#fffdf9]":"border-white/[0.08] bg-[#0f1826]"),children:e.map(([e,n],i)=>(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-3 px-3.5 py-2.5 last:border-b-0","light"===a?"border-b border-[#eadbcf]":"border-b border-white/[0.08]"),children:[(0,s.jsx)("span",{className:(0,N.cn)("text-sm",r?"text-slate-400":"text-[#8a7464]"),children:e}),(0,s.jsx)("span",{className:(0,N.cn)("min-w-0 truncate text-right text-sm",r?"text-slate-100":"text-[#352820]",t===i?r?"rounded-full border border-emerald-300/20 bg-emerald-300/10 px-2 py-1 text-xs text-emerald-100":"rounded-full border border-emerald-200 bg-emerald-50 px-2 py-1 text-xs text-emerald-700":""),title:n,children:n})]},e))})}function tH({title:e,value:t,surfaceTheme:a}){let r="dark"===a;return(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:t8(a),children:e}),(0,s.jsx)("pre",{className:(0,N.cn)("mt-2 max-h-40 overflow-auto rounded-[14px] border p-3 text-xs",r?"border-white/[0.08] bg-[#0d1624]/92 text-slate-200":"border-[#eadbcf] bg-[#fbf4ec] text-[#4b3a30]"),children:t||"No output"})]})}function tY({summary:e,surfaceTheme:t}){var a,r;let n;return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border p-3.5",t9(t)),children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:t8(t),children:"Gateway Transport"}),(0,s.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("font-medium","light"===t?"text-[#2f251f]":"text-slate-100"),children:e.statusLabel}),(0,s.jsx)("span",{className:(a=e.statusTone,r=t,n="inline-flex shrink-0 items-center rounded-full border px-2 py-1 text-[9px] uppercase tracking-[0.12em]","success"===a?(0,N.cn)(n,"light"===r?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-100"):"danger"===a?(0,N.cn)(n,"light"===r?"border-red-200 bg-red-50 text-red-700":"border-rose-300/20 bg-rose-300/10 text-rose-100"):"warning"===a?(0,N.cn)(n,"light"===r?"border-amber-200 bg-amber-50 text-amber-700":"border-amber-300/20 bg-amber-300/10 text-amber-100"):(0,N.cn)(n,"light"===r?"border-[#e2d1c4] bg-white text-[#7b6353]":"border-white/[0.08] bg-[#101a2a]/92 text-slate-300")),children:e.gatewayModeLabel})]}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-xs","light"===t?"text-[#8a7464]":"text-slate-400"),children:[e.connectionLabel," / ",e.modeLabel]})]}),(0,s.jsxs)("div",{className:"text-left sm:text-right",children:[(0,s.jsx)("p",{className:t8(t),children:"Snapshot stream"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1.5 text-sm","light"===t?"text-[#4f3e34]":"text-slate-200"),children:e.streamLabel})]})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-4",children:[(0,s.jsx)(tK,{label:"Protocol support",value:e.protocolRangeLabel,surfaceTheme:t,dark:"dark"===t,compact:!0}),(0,s.jsx)(tK,{label:"Connected protocol",value:e.protocolLabel,surfaceTheme:t,dark:"dark"===t,compact:!0}),(0,s.jsx)(tK,{label:"CLI fallback used",value:String(e.fallbackTotal),badge:e.fallbackTotal>0?"Used":"Clean",surfaceTheme:t,dark:"dark"===t,compact:!0}),(0,s.jsx)(tK,{label:"Last connected",value:e.lastConnectedLabel,surfaceTheme:t,dark:"dark"===t,compact:!0})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(tK,{label:"Last disconnected",value:e.lastDisconnectedLabel,surfaceTheme:t,dark:"dark"===t,compact:!0}),(0,s.jsx)(tK,{label:"Fallback summary",value:e.fallbackSummaryLabel,surfaceTheme:t,dark:"dark"===t,compact:!0})]}),e.lastNativeError?(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(tH,{title:"Last native error",value:e.lastNativeError,surfaceTheme:t})}):null,e.recovery?(0,s.jsxs)("p",{className:(0,N.cn)("mt-3 text-xs leading-5","light"===t?"text-[#52735e]":"text-slate-400"),children:["Recovery: ",e.recovery]}):null]})}function tZ({title:e,detail:t,surfaceTheme:a}){return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border border-dashed p-4 text-center","light"===a?"border-[#decfc2] bg-[#fbf4ec]/60":"border-white/[0.08] bg-[#0d1624]/60"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-sm font-medium","light"===a?"text-[#5f493b]":"text-slate-100"),children:e}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-xs","light"===a?"text-[#8a7464]":"text-slate-400"),children:t})]})}function tQ({surfaceTheme:e,isCheckingForUpdates:t,isUpdateRegistryLoading:a,hasUpdateAvailable:r,currentVersion:n,latestVersion:i,updateInfo:l,updateError:o,lastCheckedAt:c,isUpdateRunning:p}){let u=t||p,m=t?"Checking registry":p?"Updating":r?"Update available":o?"Check failed":a?"Registry loading":"Up to date",h=r?"light"===e?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-100":o?"light"===e?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/20 bg-rose-300/10 text-rose-100":u||a?"light"===e?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/20 bg-amber-300/10 text-amber-100":"light"===e?"border-slate-300 bg-white text-slate-600":"border-white/10 bg-[#0f1826] text-slate-300",x=t?"Refreshing OpenClaw update registry...":p?"Installing the selected OpenClaw update.":r?"A newer release is available and ready to install.":o?"OpenClaw returned an error while checking updates.":a?"OpenClaw has not reported a latest release yet.":"No newer release is currently available.";return(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[20px] border p-3.5",t9(e)),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:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",ae(e)),children:"Update status"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[u?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin text-emerald-400"}):null,(0,s.jsx)("p",{className:(0,N.cn)("font-medium","light"===e?"text-[#2f251f]":"text-slate-100"),children:m}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-0.5 text-[9px] uppercase tracking-[0.12em]",h),children:r?"Ready":u?"Working":o?"Attention":"Stable"})]})]}),(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",ae(e)),children:"Last checked"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px]","light"===e?"text-[#6b5546]":"text-slate-300"),children:c?new Date(c).toLocaleTimeString():"Not yet"})]})]}),(0,s.jsx)("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-black/10 dark:bg-white/10",children:(0,s.jsx)("div",{className:(0,N.cn)("h-full rounded-full transition-all",u?"w-1/2 animate-pulse bg-emerald-400/80":r?"w-full bg-emerald-500":o?"w-2/3 bg-rose-400":"w-5/6 bg-slate-400/70")})}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[(0,s.jsx)(tK,{label:"Current version",value:`v${n}`,surfaceTheme:e,dark:"dark"===e,compact:!0}),(0,s.jsx)(tK,{label:"Latest available",value:i?`v${i}`:"Unknown",badge:r?"Ready":o?"Error":u||a?"Loading":"Stable",surfaceTheme:e,dark:"dark"===e,compact:!0})]}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[18px] border p-3 text-[11px] leading-5","light"===e?"border-[#eadbcf] bg-[#fffdf9] text-[#5a4638]":"border-white/[0.08] bg-[#0d1624] text-slate-300"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",ae(e)),children:"Details"}),(0,s.jsx)("p",{className:"mt-1.5",children:x}),l?(0,s.jsx)("p",{className:"mt-1.5 opacity-90",children:l}):null,o?(0,s.jsx)("p",{className:(0,N.cn)("mt-1.5","light"===e?"text-rose-700":"text-rose-200"),children:o}):null,r?(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2 text-[10px] uppercase tracking-[0.16em]",children:[(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-1",h),children:"Update ready"}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-2 py-1",ae(e)),children:"Review before install"})]}):null]})]})}async function tX(){let e=await fetch("/api/settings/gateway",{method:"GET",cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Unable to check Gateway auth status.")}return(await e.json()).authStatus}function t0(e){return"supported"===e?"Supported":"unsupported"===e?"Fallback":"Unknown"}function t1(e,t){let a=e.slice(0,3).map(e=>(function(e,t){let[a,s]=e.split(/:\s*/,2),r=t?.[a]?.label??((a||e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[._-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())||"Gateway operation");return s?`${r} via ${s}`:r})(e,t)),s=e.length>a.length?` +${e.length-a.length}`:"";return`${e.length}: ${a.join(", ")}${s}`}function t2(e,t){let a=(0,k.$7)(e);return a.length<=t?a:`${a.slice(0,Math.max(0,t-3))}...`}function t5(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function t3(){window.requestAnimationFrame(()=>{window.scrollTo({top:0,left:0,behavior:"auto"})})}function t4(){switch(window.location.hash.replace(/^#/,"")){case"gateway":return"gateway";case"models":return"models";case"workspace":return"workspace";case"agents":return"agents";case"diagnostics":return"diagnostics";case"advanced":return"advanced";case"danger-zone":return"danger-zone";default:return"openclaw"}}function t8(e){return(0,N.cn)("text-[10px] uppercase tracking-[0.18em]","light"===e?"text-[#9a8271]":"text-slate-400")}function t6(e,t){return(0,N.cn)("h-10 rounded-[16px] px-3 text-sm outline-none",t,"light"===e?"border-[#e2d1c4] bg-[#fffdf9] text-[#2d211b] placeholder:text-[#ad9889]":"border-white/10 bg-[#0f1826] text-slate-100 placeholder:text-slate-500")}function t7(e,t,a){return(0,N.cn)("h-9 rounded-full px-3 text-xs",t,"light"===e?"border-[#d7c4b6] bg-white text-[#6b5546] hover:bg-[#f4e9de]":"gateway-contrast"===a?"border-emerald-300/15 bg-[#0f1826] text-slate-100 hover:bg-[#182538]":"border-white/10 bg-[#121d2d] text-slate-200 hover:bg-[#182538]")}function t9(e){return"light"===e?"border-[#eadbcf] bg-[#f9f1e8]/80":"border-white/[0.08] bg-[#101a2a]/92"}function ae(e){return"light"===e?"text-[#8c7564]":"text-slate-400"}var at=a(73294),aa=a(93479),as=a(4606),ar=a(6246),an=a(55058),ai=a(96595),al=a(18027);function ao({open:e,task:t,snapshot:a,surfaceTheme:r,onOpenChange:l,onAccept:o,onContinue:c,onRetry:p,onDismiss:u,onOpenEvidence:m}){var h,x,g;let b,f,w,y,[j,C]=(0,i.useState)(null),S=(0,i.useMemo)(()=>{var e;return Array.isArray(e=t?.metadata.optimisticEvents)?e.filter(au):[]},[t?.metadata.optimisticEvents]),{detail:A,loading:T,error:$}=(0,al.j)(t?.id??"task-review:none",e&&!!t,{dispatchId:t?.dispatchId,optimisticFeed:S}),M=function(e,t){if(!e||!t)return e??t;let a=Object.fromEntries(["reviewStatus","reviewAction","reviewedAt","reviewEvents"].map(e=>[e,t.metadata[e]]).filter(([,e])=>void 0!==e));return 0===Object.keys(a).length?e:{...e,metadata:{...e.metadata,...a}}}(A?.task,t),I=A?.integrity??null,R=M?a.workspaces.find(e=>e.id===M.workspaceId)??null:null,P=M?a.agents.find(e=>e.id===M.primaryAgentId)??null:null,_=[...A?.liveFeed??[]].reverse().find(e=>"assistant"===e.kind||"tool"===e.kind||"artifact"===e.kind)??null,D=M?(0,K.VL)(M,{hasLiveActivity:"running"===M.status||"queued"===M.status||M.liveRunCount>0,latestEvidenceAt:_?.timestamp??null}):null,E=M?(0,K.UF)(M):null,L=M?(0,K.kg)(M):null,U=M?(h=M,b="string"==typeof(x=I?.finalResponseText)?x.trim():"",f="string"==typeof h.metadata.finalResponseText?h.metadata.finalResponseText.trim():"",w="string"==typeof h.metadata.resultPreview?h.metadata.resultPreview.trim():"",y=h.subtitle.trim(),b||f||w||y):"",F=M?(g=M,g.mission?.trim()||g.title.trim()||"Untitled task"):"",z=I?.issues.find(e=>"partial-final-response"===e.id)??I?.issues[0]??null,B=I?.status==="verified"&&!z,G=D?(0,K.B4)(D):B?"verified":"needs review",V=D?(0,K.E2)(D):z?.detail||(B?"AgentOS recovered a matching completed response and no review issues remain.":"The captured task evidence needs an operator decision before AgentOS treats the result as handled."),H="light"===r,Y=null!==j,Z=async(e,t)=>{if(!j){C(e);try{await t()}finally{C(null)}}};return(0,s.jsx)(eF.lG,{open:e,onOpenChange:l,children:(0,s.jsxs)(eF.Cf,{className:(0,N.cn)("flex h-[min(780px,calc(100dvh-32px))] w-[calc(100vw-24px)] max-w-[900px] flex-col gap-0 overflow-hidden rounded-[26px] border-white/10 p-0",H?"bg-white/95 text-slate-950 shadow-[0_24px_80px_rgba(15,23,42,0.22)]":"bg-[linear-gradient(180deg,rgba(8,13,24,0.98),rgba(4,7,14,0.98))] text-white"),closeClassName:H?"text-slate-500 hover:bg-slate-950/5 hover:text-slate-900":void 0,children:[(0,s.jsx)("div",{className:(0,N.cn)("border-b px-5 py-4",H?"border-slate-200/80 bg-slate-50/85":"border-white/[0.08] bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3 pr-9",children:[(0,s.jsx)("div",{className:(0,N.cn)("mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-[14px] border","accepted"===D||B?"border-emerald-300/30 bg-emerald-400/12 text-emerald-200":"border-amber-300/30 bg-amber-400/12 text-amber-100"),children:"accepted"===D||B?(0,s.jsx)(eL.A,{className:"h-4 w-4"}):(0,s.jsx)(W.A,{className:"h-4 w-4"})}),(0,s.jsxs)(eF.c7,{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(J.E,{variant:"accepted"===D||B?"success":D?"muted":"warning",children:G}),M?.dispatchId?(0,s.jsxs)(J.E,{variant:"muted",children:["dispatch ",(0,k.m_)(M.dispatchId,8)]}):null]}),(0,s.jsx)(eF.L3,{className:(0,N.cn)("truncate text-lg",H&&"text-slate-950"),children:M?.title.trim()||"Task review"}),(0,s.jsxs)(eF.rr,{className:H?"text-slate-600":void 0,children:[R?.name||"Workspace",P?` \xb7 ${(0,k.CK)(P)}`:""]})]})]})}),(0,s.jsx)(ai.F,{className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"grid gap-4 p-5 lg:grid-cols-[minmax(0,1fr)_290px]",children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(ac,{icon:aa.A,title:"Captured output",tone:"accepted"===D||B?"success":"warning",isLight:H,children:U?(0,s.jsx)(q.G,{text:U,className:(0,N.cn)("text-[12.5px] leading-6",H?"text-slate-800":"text-slate-100")}):(0,s.jsx)("p",{className:(0,N.cn)("text-[12.5px] leading-6",H?"text-slate-500":"text-slate-400"),children:"No captured assistant output is available yet."})}),(0,s.jsxs)(ac,{icon:W.A,title:"Review reason",tone:"warning",isLight:H,children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[12.5px] leading-6",H?"text-slate-700":"text-slate-200"),children:V}),L?(0,s.jsxs)("p",{className:(0,N.cn)("mt-2 text-[11px]","text-slate-500"),children:["Last operator action: ",L]}):null]}),(0,s.jsx)(ac,{icon:as.A,title:"Original prompt",isLight:H,children:(0,s.jsx)(q.G,{text:F||"No original prompt was captured.",className:(0,N.cn)("text-[12.5px] leading-6",H?"text-slate-700":"text-slate-200")})})]}),(0,s.jsxs)("aside",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border p-3",H?"border-slate-200 bg-white":"border-white/[0.08] bg-white/[0.035]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]","text-slate-500"),children:"Evidence"}),(0,s.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[(0,s.jsx)(ad,{label:"Runs",value:String(M?.runtimeCount??0),isLight:H}),(0,s.jsx)(ad,{label:"Turns",value:String(function(e){if(!e)return 0;let t=e.metadata.turnCount;return"number"==typeof t&&Number.isFinite(t)?t:e.runtimeCount}(M)),isLight:H}),(0,s.jsx)(ad,{label:"Files",value:String(M?.artifactCount??0),isLight:H}),(0,s.jsx)(ad,{label:"Issues",value:String(I?.issues.length??M?.warningCount??0),isLight:H})]}),T?(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 flex items-center gap-2 text-[11px]",H?"text-slate-500":"text-slate-400"),children:[(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading live evidence..."]}):null,$?(0,s.jsx)("p",{className:"mt-3 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[11px] leading-5 text-amber-100",children:$}):null]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border p-3",H?"border-slate-200 bg-white":"border-white/[0.08] bg-white/[0.035]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]","text-slate-500"),children:"Task state"}),(0,s.jsxs)("div",{className:"mt-3 space-y-2 text-[12px]",children:[(0,s.jsx)(ap,{label:"Status",value:M?.status??"unknown",isLight:H}),(0,s.jsx)(ap,{label:"Updated",value:M?.updatedAt?(0,k.fw)(M.updatedAt):"unknown",isLight:H}),(0,s.jsx)(ap,{label:"Reviewed",value:E?(0,k.fw)(Date.parse(E)):"not yet",isLight:H})]})]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",className:(0,N.cn)("w-full justify-start gap-2",H&&"border-slate-200 bg-slate-50 text-slate-800 hover:bg-slate-100"),disabled:!M||Y,onClick:()=>{M&&m(M,"output")},children:[(0,s.jsx)(O.A,{className:"h-4 w-4"}),"Open evidence"]})]})]})}),(0,s.jsxs)("div",{className:(0,N.cn)("flex flex-col gap-2 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-end",H?"border-slate-200 bg-slate-50/85":"border-white/[0.08] bg-white/[0.03]"),children:[(0,s.jsxs)(v.$,{type:"button",variant:"ghost",className:(0,N.cn)("gap-2",H&&"text-slate-700 hover:bg-slate-950/5 hover:text-slate-950"),disabled:!M||Y,onClick:()=>void Z("dismiss",()=>{if(M)return u(M)}),children:["dismiss"===j?(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(ar.A,{className:"h-4 w-4"}),"dismiss"===j?"Dismissing...":"Dismiss"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",className:(0,N.cn)("gap-2",H&&"border-slate-200 bg-white text-slate-800 hover:bg-slate-100"),disabled:!M||Y,onClick:()=>void Z("retry",()=>{if(M)return p(M)}),children:["retry"===j?(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(n.A,{className:"h-4 w-4"}),"retry"===j?"Preparing...":"Retry"]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",className:(0,N.cn)("gap-2",H&&"border-slate-200 bg-white text-slate-800 hover:bg-slate-100"),disabled:!M||Y,onClick:()=>void Z("continue",()=>{if(M)return c(M,U)}),children:["continue"===j?(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(an.A,{className:"h-4 w-4"}),"continue"===j?"Continuing...":"Continue task"]}),(0,s.jsxs)(v.$,{type:"button",className:"gap-2 bg-emerald-400 text-slate-950 shadow-emerald-400/20 hover:bg-emerald-300",disabled:!M||Y,onClick:()=>void Z("accept",()=>{if(M)return o(M)}),children:["accept"===j?(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(eL.A,{className:"h-4 w-4"}),"accept"===j?"Accepting...":"Accept result"]})]})]})})}function ac({icon:e,title:t,tone:a="neutral",isLight:r,children:n}){return(0,s.jsxs)("section",{className:(0,N.cn)("rounded-[18px] border p-3.5",r?"border-slate-200 bg-white":"border-white/[0.08] bg-white/[0.035]"),children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center gap-2",children:[(0,s.jsx)("div",{className:(0,N.cn)("flex h-7 w-7 items-center justify-center rounded-[10px] border","success"===a?"border-emerald-300/30 bg-emerald-400/12 text-emerald-200":"warning"===a?"border-amber-300/30 bg-amber-400/12 text-amber-100":r?"border-slate-200 bg-slate-50 text-slate-600":"border-white/[0.08] bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]","text-slate-500"),children:t})]}),n]})}function ad({label:e,value:t,isLight:a}){return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[12px] border px-3 py-2",a?"border-slate-200 bg-slate-50":"border-white/[0.08] bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[9px] uppercase tracking-[0.16em]","text-slate-500"),children:e}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 font-mono text-[13px]",a?"text-slate-900":"text-white"),children:t})]})}function ap({label:e,value:t,isLight:a}){return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("span",{className:"text-slate-500",children:e}),(0,s.jsx)("span",{className:(0,N.cn)("min-w-0 truncate text-right",a?"text-slate-900":"text-slate-100"),children:t})]})}function au(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.kind&&"string"==typeof e.timestamp&&"string"==typeof e.title&&"string"==typeof e.detail}var am=a(85247),ah=a(47322),ax=a(90093),ag=a(71333),ab=a(75800),af=a(96968),aw=a(89266),av=a(99350);function ay({progress:e,className:t}){return(0,s.jsxs)("div",{className:(0,N.cn)("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",n="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:(0,N.cn)("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:(0,N.cn)("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)(eG.A,{className:"h-3.5 w-3.5"}):"active"===e.status?(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):"error"===e.status?(0,s.jsx)(W.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:(0,N.cn)("h-full rounded-full transition-[width] duration-500 ease-out",n),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:(0,N.cn)("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 aj=a(47612);function ak(e){let t=e.policy,a=e.skillIds,s=aS([...e.toolIds??[],...t?.fileAccess==="workspace-only"?["fs.workspaceOnly"]:[]]),r=aS(e.channelIds??[]);return[`### ${e.name} (\`${e.id}\`)`,`- Agent id: \`${e.id}\``,`- Runtime rule: when the current OpenClaw agent id is \`${e.id}\`, use this section as the agent-specific role and persona.`,`- Role: ${e.role||"Agent"}`,`- Primary: ${e.isPrimary?"yes":"no"}`,...t?[`- Preset: ${(0,H._P)(t.preset)}`]:[],...e.modelId?[`- Model: \`${e.modelId}\``]:[],...a.length>0?[`- Skills: ${a.map(e=>`\`${e}\``).join(", ")}`]:[],...s.length>0?[`- Tools: ${s.map(e=>`\`${e}\``).join(", ")}`]:[],...t?[`- File access: ${t.fileAccess}`,`- Network access: ${t.networkAccess}`,`- Install scope: ${t.installScope}`,`- Missing tools: ${t.missingToolBehavior}`]:[],...r.length>0?[`- Channels: ${r.map(e=>`\`${e}\``).join(", ")}`]:[]].join("\n")}function aN(e,t){return[...e].map((e,a)=>{let s=aC(e.id)??aA(aC(e.name)??`agent-${a+1}`),r=t&&!s.startsWith(`${t}-`)?`${t}-${aA(s)||"agent"}`:s,n=aC(e.role),i=aS([...e.skillIds??[],aC(e.skillId)??""]);return{id:r,name:aC(e.name)??n??r,role:n,enabled:!1!==e.enabled,isPrimary:!!e.isPrimary,skillId:i[0]??null,skillIds:i,toolIds:aS(e.toolIds??[]),modelId:aC(e.modelId),policy:e.policy??null,channelIds:aS(e.channelIds??[])}}).sort((e,t)=>e.isPrimary!==t.isPrimary?e.isPrimary?-1:1:e.name.localeCompare(t.name))}function aC(e){return"string"==typeof e&&e.trim().length>0?e.trim():null}function aS(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function aA(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}let aT=["AGENTS.md","SOUL.md","IDENTITY.md","TOOLS.md","HEARTBEAT.md"],a$={software:"Software project",frontend:"Frontend app",backend:"Backend/API",research:"Research",content:"Content/Growth"},aM=["Use repository-local scripts or documented commands for repeatable workflows.","Update this file when the project exposes a cleaner build, test, or release path."];function aI(e){let t=[{id:"agents",label:"AGENTS.md",relativePath:"AGENTS.md",kind:"file",headings:["Workspace","Team","Customize","Safety defaults","Daily memory","Output"]},{id:"soul",label:"SOUL.md",relativePath:"SOUL.md",kind:"file",headings:["My Purpose","How I Operate","My Quirks","Active Focus"]},{id:"identity",label:"IDENTITY.md",relativePath:"IDENTITY.md",kind:"file",headings:["Role"]},{id:"tools",label:"TOOLS.md",relativePath:"TOOLS.md",kind:"file",headings:["Examples","Notes"]},{id:"heartbeat",label:"HEARTBEAT.md",relativePath:"HEARTBEAT.md",kind:"file",headings:[]},{id:"memory-md",label:"MEMORY.md",relativePath:"MEMORY.md",kind:"file",headings:["Current brief","Stable facts"]},{id:"memory-blueprint",label:"memory/blueprint.md",relativePath:"memory/blueprint.md",kind:"file",headings:["Outcome","Constraints","Unknowns"]},{id:"memory-decisions",label:"memory/decisions.md",relativePath:"memory/decisions.md",kind:"file",headings:["Template"]},{id:"docs-brief",label:"docs/brief.md",relativePath:"docs/brief.md",kind:"file",headings:["Objective","Success signals","Open questions"]},{id:"docs-architecture",label:"docs/architecture.md",relativePath:"docs/architecture.md",kind:"file",headings:["Current shape","Dependencies","Risks"]},{id:"deliverables-readme",label:"deliverables/README.md",relativePath:"deliverables/README.md",kind:"file",headings:["Deliverables"]}];return"frontend"===e&&t.push({id:"docs-ux-notes",label:"docs/ux-notes.md",relativePath:"docs/ux-notes.md",kind:"file",headings:["UX Notes"]}),"backend"===e&&t.push({id:"docs-service-map",label:"docs/service-map.md",relativePath:"docs/service-map.md",kind:"file",headings:["Service Map"]}),"research"===e&&t.push({id:"docs-research-plan",label:"docs/research-plan.md",relativePath:"docs/research-plan.md",kind:"file",headings:["Research Plan"]}),"content"===e&&t.push({id:"docs-content-brief",label:"docs/content-brief.md",relativePath:"docs/content-brief.md",kind:"file",headings:["Content Brief"]}),t}function aR(e,t){let a=new Map(aI(e??null).map(e=>[e.relativePath,e])),s=e=>e.map(e=>a.get(e)).filter(Boolean),r=[{id:"core",title:"Core bootstrap",description:"Required for every workspace and shared by all agents.",enabled:!0,resources:s(aT)},{id:"memory",title:"Memory",description:"Durable notes and decisions that survive across sessions.",enabled:t.generateMemory,resources:t.generateMemory?s(["MEMORY.md","memory/blueprint.md","memory/decisions.md"]):[]},{id:"starter",title:"Starter docs",description:"Planning, architecture, and handoff docs used for the first pass.",enabled:t.generateStarterDocs,resources:t.generateStarterDocs?s(["docs/brief.md","docs/architecture.md","deliverables/README.md",..."frontend"===e?["docs/ux-notes.md"]:"backend"===e?["docs/service-map.md"]:"research"===e?["docs/research-plan.md"]:"content"===e?["docs/content-brief.md"]:[]]):[]}];return{template:e??null,rules:t,sections:r,resources:r.flatMap(e=>e.resources)}}function aO(e){let t=aD(e.template,e.rules),a=new Map(a_(e.docOverrides).map(e=>[e.path,e.content]));return t.map(t=>{let s=t.render(e),r=a.has(t.path);return{path:t.path,title:t.title,description:t.description,category:t.category,baseContent:s,content:r?a.get(t.path)??"":s,overridden:r}})}function aP(e){let t=aO(e).map(e=>({...e,generated:!0})),a=new Set(t.map(e=>e.path));return[...t,...a_(e.docOverrides).filter(e=>!a.has(e.path)).map(e=>{var t;return{path:e.path,title:e.path,description:"Existing workspace file.",category:(t=e.path).startsWith("memory/")?"memory":t.startsWith("docs/")?"docs":t.startsWith("deliverables/")?"deliverables":"core",baseContent:e.content,content:e.content,overridden:!1,generated:!1}})]}function a_(e){let t=new Map;for(let a of e??[]){let e=a.path.trim();e&&t.set(e,a.content)}return Array.from(t.entries()).map(([e,t])=>({path:e,content:t}))}function aD(e,t){let a=[{path:"AGENTS.md",title:"AGENTS.md",description:"Shared operating instructions for all agents.",category:"core",render:aE},{path:"SOUL.md",title:"SOUL.md",description:"Purpose, operating style, and active focus.",category:"core",render:({template:e,brief:t,contextSources:a})=>{var s,r,n;return s=e,r=t,n=a,`# SOUL
|
|
5
|
-
|
|
6
|
-
## My Purpose
|
|
7
|
-
Help this ${a$[s].toLowerCase()} workspace turn intent into real outcomes with pragmatic execution, verification, and durable memory.
|
|
8
|
-
|
|
9
|
-
## How I Operate
|
|
10
|
-
- Start from the current workspace reality before proposing large moves.
|
|
11
|
-
- Prefer concrete action, visible artifacts, and clear handoffs.
|
|
12
|
-
- Keep docs, memory, and deliverables aligned with the actual state of the work.
|
|
13
|
-
|
|
14
|
-
## My Quirks
|
|
15
|
-
- Pragmatic
|
|
16
|
-
- Direct
|
|
17
|
-
- Product-aware
|
|
18
|
-
- Quality-minded
|
|
19
|
-
|
|
20
|
-
${r?`## Active Focus
|
|
21
|
-
${r}
|
|
22
|
-
`:""}${aU(n)}`}},{path:"IDENTITY.md",title:"IDENTITY.md",description:"Workspace identity and vibe.",category:"core",render:({template:e})=>{var t;return t=e,`# IDENTITY
|
|
23
|
-
|
|
24
|
-
## Role
|
|
25
|
-
This workspace hosts a ${a$[t].toLowerCase()} team coordinated through OpenClaw.
|
|
26
|
-
|
|
27
|
-
**Vibe:** pragmatic, concise, quality-minded, workspace-grounded
|
|
28
|
-
`}},{path:"TOOLS.md",title:"TOOLS.md",description:"Repository commands and workflow notes.",category:"core",render:({template:e,toolExamples:t})=>{var a,s;return a=e,s=t??aM,`# TOOLS
|
|
29
|
-
|
|
30
|
-
Repository commands and workflow notes for this ${a$[a].toLowerCase()} workspace.
|
|
31
|
-
|
|
32
|
-
## Examples
|
|
33
|
-
${s.map(e=>`- ${e}`).join("\n")}
|
|
34
|
-
|
|
35
|
-
## Notes
|
|
36
|
-
- Replace these examples with sharper project-specific commands when the repo exposes them.
|
|
37
|
-
- Prefer repeatable commands that other agents can run without interpretation drift.
|
|
38
|
-
`}},{path:"HEARTBEAT.md",title:"HEARTBEAT.md",description:"Refresh ritual and coherence checks.",category:"core",render:({template:e})=>{var t;return t=e,`# HEARTBEAT
|
|
39
|
-
|
|
40
|
-
- Start each substantial task by refreshing the brief, docs, and current files.
|
|
41
|
-
- Keep the ${a$[t].toLowerCase()} workspace coherent across code, docs, and memory.
|
|
42
|
-
- Prefer explicit handoffs between implementation, review, testing, and knowledge capture.
|
|
43
|
-
`}}];return t.generateMemory&&a.push({path:"MEMORY.md",title:"MEMORY.md",description:"Durable project memory.",category:"memory",render:({name:e,template:t,brief:a,contextSources:s})=>{var r,n,i,l;return r=e,n=t,i=a,l=s,`# ${r} Memory
|
|
44
|
-
|
|
45
|
-
Durable project facts for this ${a$[n].toLowerCase()} workspace.
|
|
46
|
-
|
|
47
|
-
## Current brief
|
|
48
|
-
${i||"No brief captured yet. Fill this in as soon as the project goal is clarified."}
|
|
49
|
-
|
|
50
|
-
## Stable facts
|
|
51
|
-
- Add durable architecture, product, or workflow facts here.
|
|
52
|
-
- Move longer notes into memory/*.md when they outgrow this file.
|
|
53
|
-
|
|
54
|
-
${aU(l)}`}},{path:"memory/blueprint.md",title:"memory/blueprint.md",description:"Project blueprint and current outcome.",category:"memory",render:({name:e,template:t,brief:a})=>{var s,r,n;return s=e,r=t,n=a,`# ${s} Blueprint
|
|
55
|
-
|
|
56
|
-
## Workspace type
|
|
57
|
-
${a$[r]}
|
|
58
|
-
|
|
59
|
-
## Outcome
|
|
60
|
-
${n||"Define the target outcome, user impact, and quality bar for this workspace."}
|
|
61
|
-
|
|
62
|
-
## Constraints
|
|
63
|
-
- Add technical, product, legal, or operational constraints here.
|
|
64
|
-
|
|
65
|
-
## Unknowns
|
|
66
|
-
- Capture unresolved questions that block confident execution.
|
|
67
|
-
`}},{path:"memory/decisions.md",title:"memory/decisions.md",description:"Decision log.",category:"memory",render:()=>`# Decisions
|
|
68
|
-
|
|
69
|
-
Use this file for durable decisions that should survive across sessions.
|
|
70
|
-
|
|
71
|
-
## Template
|
|
72
|
-
- Date:
|
|
73
|
-
- Decision:
|
|
74
|
-
- Context:
|
|
75
|
-
- Consequence:
|
|
76
|
-
`}),t.generateStarterDocs&&a.push({path:"docs/brief.md",title:"docs/brief.md",description:"Objective, source mode, and success signals.",category:"docs",render:({name:e,template:t,brief:a,sourceMode:s,contextSources:r})=>{var n,i,l,o,c;return n=e,i=t,l=a,o=s,c=r,`# ${n} Brief
|
|
77
|
-
|
|
78
|
-
## Template
|
|
79
|
-
${a$[i]}
|
|
80
|
-
|
|
81
|
-
## Source mode
|
|
82
|
-
${o}
|
|
83
|
-
|
|
84
|
-
## Objective
|
|
85
|
-
${l||"Clarify the main goal, target user, and success definition for this workspace."}
|
|
86
|
-
|
|
87
|
-
## Success signals
|
|
88
|
-
- Define what success looks like in observable terms.
|
|
89
|
-
|
|
90
|
-
## Open questions
|
|
91
|
-
- List the unknowns worth resolving first.
|
|
92
|
-
|
|
93
|
-
${aU(c)}`}},{path:"docs/architecture.md",title:"docs/architecture.md",description:"Current system shape and dependencies.",category:"docs",render:({template:e,contextSources:t})=>{var a,s;return a=e,s=t,`# Architecture
|
|
94
|
-
|
|
95
|
-
## Current shape
|
|
96
|
-
- Describe the main components, systems, or content lanes in this ${a$[a].toLowerCase()} workspace.
|
|
97
|
-
|
|
98
|
-
## Dependencies
|
|
99
|
-
- List critical external services, repos, data sources, or channels.
|
|
100
|
-
|
|
101
|
-
## Risks
|
|
102
|
-
- Capture structural, operational, or delivery risks here.
|
|
103
|
-
|
|
104
|
-
${aU(s)}`}},{path:"deliverables/README.md",title:"deliverables/README.md",description:"Guidance for handoff artifacts.",category:"deliverables",render:()=>`# Deliverables
|
|
105
|
-
|
|
106
|
-
Use this folder for substantial output artifacts that should be easy to hand off or review.
|
|
107
|
-
|
|
108
|
-
- Create one subfolder per task or run, for example \`deliverables/2026-03-07-15-30-00-launch-brief/\`.
|
|
109
|
-
- Put drafts, reports, docs, and publishable assets for that task inside its run folder.
|
|
110
|
-
- Keep filenames descriptive and tied to the task or audience.
|
|
111
|
-
`}),"frontend"===e&&a.push({path:"docs/ux-notes.md",title:"docs/ux-notes.md",description:"Interaction patterns and UI risks.",category:"docs",render:()=>aL("ux")}),"backend"===e&&a.push({path:"docs/service-map.md",title:"docs/service-map.md",description:"Service, queue, and dependency map.",category:"docs",render:()=>aL("backend")}),"research"===e&&a.push({path:"docs/research-plan.md",title:"docs/research-plan.md",description:"Question framing and evidence plan.",category:"docs",render:()=>aL("research")}),"content"===e&&a.push({path:"docs/content-brief.md",title:"docs/content-brief.md",description:"Audience, channel, and campaign brief.",category:"docs",render:()=>aL("content")}),a}function aE({name:e,brief:t,template:a,sourceMode:s,rules:r,agents:n=[]}){var i,l,o,c;let d;return i={name:e,brief:t,templateLabel:a$[a],sourceMode:s,workspaceOnly:r.workspaceOnly,workspaceSlug:e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64),agents:n},`# ${i.name}
|
|
112
|
-
|
|
113
|
-
Shared project context for all agents working in this workspace.
|
|
114
|
-
|
|
115
|
-
## Workspace
|
|
116
|
-
- Template: ${i.templateLabel}
|
|
117
|
-
- Source mode: ${i.sourceMode}
|
|
118
|
-
- Workspace-only access: ${i.workspaceOnly?"enabled":"disabled"}
|
|
119
|
-
|
|
120
|
-
${l=i.agents,d=aN(l,i.workspaceSlug).filter(e=>e.enabled).map(e=>{let t=[e.isPrimary?"primary":null,e.role,e.policy?(0,H._P)(e.policy.preset):null].filter(e=>!!e);return`- ${e.name} (\`${e.id}\`)${t.length>0?` \xb7 ${t.join(" \xb7 ")}`:""}`}),`## Team
|
|
121
|
-
${d.length>0?d.join("\n"):"- No active agents configured yet."}`}
|
|
122
|
-
|
|
123
|
-
${o=i.agents,c=aN(o,i.workspaceSlug).filter(e=>e.enabled).map(ak),`## Agent Roles
|
|
124
|
-
Each agent should use only the subsection matching its current OpenClaw agent id as its personal role/persona. Other subsections describe teammates in the same workspace.
|
|
125
|
-
|
|
126
|
-
${c.length>0?c.join("\n\n"):"- No active agent role sections are configured yet."}`}
|
|
127
|
-
|
|
128
|
-
## Customize
|
|
129
|
-
${i.brief||"Clarify the project goal, definition of done, constraints, and success signals before large changes."}
|
|
130
|
-
|
|
131
|
-
## Safety defaults
|
|
132
|
-
- Stay inside the attached workspace unless the task explicitly requires another location.
|
|
133
|
-
- Prefer direct, reviewable changes over speculative rewrites.
|
|
134
|
-
- Preserve user work and avoid destructive actions without clear approval.
|
|
135
|
-
- Update durable docs when stable architecture, workflow, or product decisions change.
|
|
136
|
-
- Worker and browser agents should not install tooling unless their explicit policy allows it.
|
|
137
|
-
- Route environment preparation to setup-oriented agents when the work depends on new tooling.
|
|
138
|
-
|
|
139
|
-
## Daily memory
|
|
140
|
-
- Capture durable facts in MEMORY.md and memory/*.md.
|
|
141
|
-
- Record stable decisions in memory/decisions.md.
|
|
142
|
-
- Keep temporary chatter and scratch notes in memory/.
|
|
143
|
-
|
|
144
|
-
## Output
|
|
145
|
-
- Be concise in chat and write longer output to files when the artifact matters.
|
|
146
|
-
- Put task-specific deliverables, drafts, reports, and docs inside per-run folders under deliverables/.
|
|
147
|
-
- Avoid writing final artifacts to the workspace root unless explicitly requested.
|
|
148
|
-
`}function aL(e){return"ux"===e?`# UX Notes
|
|
149
|
-
|
|
150
|
-
- Track interaction patterns, responsive edge cases, and visual risk areas here.
|
|
151
|
-
`:"backend"===e?`# Service Map
|
|
152
|
-
|
|
153
|
-
- Document services, jobs, queues, external dependencies, and critical flows here.
|
|
154
|
-
`:"research"===e?`# Research Plan
|
|
155
|
-
|
|
156
|
-
- State the question, method, evidence sources, and expected output before large investigation work.
|
|
157
|
-
`:`# Content Brief
|
|
158
|
-
|
|
159
|
-
- Capture audience, channel, tone, CTA, and distribution assumptions for this content workspace.
|
|
160
|
-
`}function aU(e){let t=(e??[]).filter(e=>"error"!==e.status&&e.summary.trim().length>0).slice(0,4);if(0===t.length)return"";let a=t.filter(e=>(e.confidence??100)>=80),s=t.filter(e=>(e.confidence??100)<80),r=e=>{let t="website"===e.kind?"Website":"repo"===e.kind?"Repo":"folder"===e.kind?"Folder":"Prompt",a="number"==typeof e.confidence?` (${e.confidence}%)`:"";return`- ${t}: ${e.label}${a} - ${e.summary}`},n=[];return a.length>0&&n.push(`## Evidence
|
|
161
|
-
${a.map(r).join("\n")}`),s.length>0&&n.push(`## Assumptions
|
|
162
|
-
${s.map(r).join("\n")}`),n.length>0?`
|
|
163
|
-
${n.join("\n\n")}
|
|
164
|
-
`:""}let aF=[{value:"empty",label:"Empty workspace",description:"Create a fresh project folder and scaffold the shared OpenClaw context."},{value:"clone",label:"Clone repo",description:"Clone a repository first, then layer workspace docs, memory, and agents on top."},{value:"existing",label:"Use existing folder",description:"Attach OpenClaw to a folder that already exists and preserve any current files."}],az=[{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."}],aW=[{value:"solo",label:"Solo",description:"One primary agent with a shared workspace scaffold."},{value:"core",label:"Core team",description:"Multi-agent setup with role-specific specialists and a strong shared context."},{value:"custom",label:"Custom",description:"Start from a recommended team and toggle which specialist agents are enabled."}],aB=[{value:"balanced",label:"Balanced",description:"General-purpose default for daily execution, review, and coordination."},{value:"fast",label:"Fast",description:"Favor speed and iteration for high-throughput tasking and first passes."},{value:"quality",label:"Quality",description:"Favor deeper reasoning and more careful outputs for critical work."}],aG={workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0},aq={software:{label:"Software project",description:"Default project template for engineering delivery.",icon:"\uD83D\uDEE0"},frontend:{label:"Frontend app",description:"UI and experience work with browser-aware support.",icon:"\uD83C\uDFA8"},backend:{label:"Backend/API",description:"Services, infrastructure, and backend-oriented workflows.",icon:"⚙️"},research:{label:"Research",description:"Investigation-heavy workspace with synthesis and memory capture.",icon:"\uD83E\uDDE0"},content:{label:"Content/Growth",description:"Messaging, content production, campaign review, and analysis.",icon:"\uD83D\uDCE3"}},aV={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."}]};function aK(e,t,a){let s=aV[e];if("solo"===t){let e=s.find(e=>e.isPrimary)??s[0];return[{...e,name:aJ(a,e.role,"Builder"===e.role?"Default Agent":e.name),policy:(0,H.g0)("browser"===e.id?"browser":"worker"),enabled:!0}]}return s.map(e=>({id:e.id,role:e.role,name:e.isPrimary?aJ(a,e.role,e.name):e.name,emoji:e.emoji,theme:e.theme,skillId:e.skillId,modelId:e.modelId,isPrimary:!!e.isPrimary,policy:(0,H.g0)("browser"===e.id?"browser":"worker"),enabled:!0}))}function aJ(e,t,a){let s=function(e){let t=e?.trim();if(!t)return"";let a=(!/\s/.test(t)&&t.includes(".")?t.split(".")[0]:t).replace(/[^A-Za-z0-9\u00C0-\u024F]+/g," ").trim();return a?a.split(/\s+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" "):""}(e);if(!s)return a;let r=t.trim();return r?`${s} ${r}`:s}function aH(e){if("raw"===e)return"workspace";let[t]=e.split(".");return t}function aY({open:e,surfaceTheme:t,plan:a,focus:r,busy:n=!1,onClose:l,onSave:o}){var c;let[p,m]=(0,i.useState)(()=>"raw"===r?"raw":"fields"),[h,x]=(0,i.useState)(()=>{var e;return a?{companyName:(e=a).company.name,companyMission:e.company.mission,companyTargetCustomer:e.company.targetCustomer,companyConstraints:aQ(e.company.constraints),companySuccessSignals:aQ(e.company.successSignals),productOffer:e.product.offer,productRevenueModel:e.product.revenueModel,productScopeV1:aQ(e.product.scopeV1),productNonGoals:aQ(e.product.nonGoals),productLaunchPriority:aQ(e.product.launchPriority),workspaceName:e.workspace.name,workspaceDirectory:e.workspace.directory??"",workspaceSourceMode:e.workspace.sourceMode,workspaceRepoUrl:e.workspace.repoUrl??"",workspaceExistingPath:e.workspace.existingPath??"",workspaceTemplate:e.workspace.template,workspaceModelProfile:e.workspace.modelProfile,workspaceModelId:e.workspace.modelId??"",workspaceStackDecisions:aQ(e.workspace.stackDecisions),workspaceDocs:aQ(e.workspace.docs),workspaceRuleGenerateStarterDocs:e.workspace.rules.generateStarterDocs,workspaceRuleGenerateMemory:e.workspace.rules.generateMemory,workspaceRuleKickoffMission:e.workspace.rules.kickoffMission,intakeReviewRequested:e.intake.reviewRequested,intakeAutopilot:e.autopilot,teamAllowEphemeralSubagents:e.team.allowEphemeralSubagents,teamMaxParallelRuns:String(e.team.maxParallelRuns),teamEscalationRules:aQ(e.team.escalationRules),deployBlockers:aQ(e.deploy.blockers),deployWarnings:aQ(e.deploy.warnings),deployFirstMissions:aQ(e.deploy.firstMissions)}:null}),[g,b]=(0,i.useState)(()=>a?JSON.stringify(a,null,2):""),[f,w]=(0,i.useState)(null),j=(0,i.useRef)({}),k=(0,i.useRef)({}),C="light"===t,S=r&&"raw"!==r?aH(r):null,A=r&&"raw"!==r&&(c=r).includes(".")?c:null;(0,i.useEffect)(()=>{if(!e||!a||!r||"raw"===r||"fields"!==p)return;let t=aH(r),s=A?k.current[A]??j.current[t]:j.current[t];s&&globalThis.requestAnimationFrame(()=>{s.scrollIntoView({behavior:"smooth",block:A?"center":"start"}),A&&s===k.current[A]&&"function"==typeof s.focus&&s.focus({preventScroll:!0})})},[r,A,e,a,p]);let T=!!(a&&h);if(!e||!a||!h)return null;let $=(e,t)=>{x(a=>a?{...a,[e]:t}:a)},M=e=>t=>{k.current[e]=t},I=async()=>{var e,t,s,r;let n,i,c,d,p,u,m,x,g=(e=a,t=h,n=structuredClone(e),i=e.company.name.trim(),c=e.workspace.name.trim(),d=t.companyName.trim(),p=t.workspaceName.trim(),u=d!==i,m=p!==c,n.company.name=d,n.company.mission=t.companyMission.trim(),n.company.targetCustomer=t.companyTargetCustomer.trim(),n.company.constraints=aX(t.companyConstraints),n.company.successSignals=aX(t.companySuccessSignals),n.product.offer=t.productOffer.trim(),n.product.revenueModel=t.productRevenueModel.trim(),n.product.scopeV1=aX(t.productScopeV1),n.product.nonGoals=aX(t.productNonGoals),n.product.launchPriority=aX(t.productLaunchPriority),n.workspace.name=p,n.workspace.directory=a0(t.workspaceDirectory),n.workspace.sourceMode=t.workspaceSourceMode,n.workspace.repoUrl=a0(t.workspaceRepoUrl),n.workspace.existingPath=a0(t.workspaceExistingPath),n.workspace.template=t.workspaceTemplate,n.workspace.modelProfile=t.workspaceModelProfile,n.workspace.modelId=a0(t.workspaceModelId),n.workspace.stackDecisions=aX(t.workspaceStackDecisions),n.workspace.docs=aX(t.workspaceDocs),n.workspace.rules={...n.workspace.rules,workspaceOnly:!0,generateStarterDocs:t.workspaceRuleGenerateStarterDocs,generateMemory:t.workspaceRuleGenerateMemory,kickoffMission:t.workspaceRuleKickoffMission},m&&!u?n.company.name=p:u&&!m&&(n.workspace.name=d),n.team.allowEphemeralSubagents=t.teamAllowEphemeralSubagents,n.team.maxParallelRuns=Number.isFinite(Number(t.teamMaxParallelRuns))?Math.max(1,Number(t.teamMaxParallelRuns)):n.team.maxParallelRuns,n.team.escalationRules=aX(t.teamEscalationRules),n.intake.reviewRequested=t.intakeReviewRequested,n.autopilot=t.intakeAutopilot,n.deploy.blockers=aX(t.deployBlockers),n.deploy.warnings=aX(t.deployWarnings),n.deploy.firstMissions=aX(t.deployFirstMissions),n),b=(s=a,r=g,x=[],(aZ(s.company,r.company)&&x.push("company"),aZ(s.product,r.product)&&x.push("product"),aZ(s.workspace,r.workspace)&&x.push("workspace"),aZ(s.team,r.team)&&x.push("team"),aZ({reviewRequested:s.intake.reviewRequested,autopilot:s.autopilot},{reviewRequested:r.intake.reviewRequested,autopilot:r.autopilot})&&x.push("intake"),aZ(s.deploy,r.deploy)&&x.push("deploy"),0===x.length)?"Manual blueprint edit applied.":`Manual blueprint edit applied to ${x.join(", ")}.`);await o(g,b)&&l()},R=async()=>{try{let e=JSON.parse(g);await o(e,"Manual raw blueprint edit applied.")&&l()}catch(e){w(e instanceof Error?e.message:"Raw JSON could not be parsed.")}};return(0,s.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close blueprint editor",onClick:l,className:(0,N.cn)("absolute inset-0 h-full w-full cursor-default",C?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,s.jsxs)("div",{className:(0,N.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[760px]",C?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:(0,N.cn)("flex items-start justify-between gap-4 border-b px-4 py-4 md:px-5",C?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",C?"text-[#9a9085]":"text-slate-500"),children:"Blueprint editor"}),(0,s.jsx)("h2",{className:(0,N.cn)("mt-1 text-[18px] font-semibold tracking-[-0.03em]",C?"text-[#171410]":"text-white"),children:"Edit any detail, then keep chatting with Architect"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",C?"text-[#6f675e]":"text-slate-300"),children:"Structured fields cover the common edits. Raw JSON lets you change anything else in the same plan."})]}),(0,s.jsx)("button",{type:"button",onClick:l,className:(0,N.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",C?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,s.jsx)(u.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center gap-2 border-b px-4 py-3 md:px-5",C?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsx)(a1,{surfaceTheme:t,label:`Stage \xb7 ${a.stage}`}),(0,s.jsx)(a1,{surfaceTheme:t,label:`Status \xb7 ${a.status}`}),(0,s.jsx)(a1,{surfaceTheme:t,label:`Readiness \xb7 ${a.readinessScore}%`})]}),(0,s.jsxs)(aj.tU,{value:p,onValueChange:e=>m(e),className:"flex min-h-0 flex-1 flex-col px-4 py-4 md:px-5",children:[(0,s.jsxs)(aj.j7,{className:(0,N.cn)("w-fit",C?"bg-[#f2ece4] text-[#645b52]":"bg-white/5"),children:[(0,s.jsx)(aj.Xi,{value:"fields",children:"Fields"}),(0,s.jsx)(aj.Xi,{value:"raw",children:"Raw JSON"})]}),(0,s.jsx)(aj.av,{value:"fields",className:"min-h-0 flex-1",children:(0,s.jsx)(ai.F,{className:"h-full pr-1",children:(0,s.jsxs)("div",{className:"space-y-4 pb-4",children:[(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsxs)(a2,{surfaceTheme:t,sectionId:"company",highlighted:"company"===S,title:"Company",description:"Mission and audience details.",register:e=>{j.current.company=e},children:[(0,s.jsx)(a5,{label:"Name",children:(0,s.jsx)(tt.p,{ref:M("company.name"),value:h.companyName,onChange:e=>$("companyName",e.target.value)})}),(0,s.jsx)(a5,{label:"Mission",children:(0,s.jsx)(y.T,{ref:M("company.mission"),value:h.companyMission,onChange:e=>$("companyMission",e.target.value),className:"min-h-[96px]"})}),(0,s.jsx)(a5,{label:"Target customer",children:(0,s.jsx)(tt.p,{ref:M("company.targetCustomer"),value:h.companyTargetCustomer,onChange:e=>$("companyTargetCustomer",e.target.value)})}),(0,s.jsx)(a5,{label:"Constraints",children:(0,s.jsx)(y.T,{ref:M("company.constraints"),value:h.companyConstraints,onChange:e=>$("companyConstraints",e.target.value),placeholder:"One constraint per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"Success signals",children:(0,s.jsx)(y.T,{ref:M("company.successSignals"),value:h.companySuccessSignals,onChange:e=>$("companySuccessSignals",e.target.value),placeholder:"One signal per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(a2,{surfaceTheme:t,sectionId:"product",highlighted:"product"===S,title:"Product",description:"Offer and V1 shape.",register:e=>{j.current.product=e},children:[(0,s.jsx)(a5,{label:"Offer",children:(0,s.jsx)(y.T,{ref:M("product.offer"),value:h.productOffer,onChange:e=>$("productOffer",e.target.value),className:"min-h-[96px]"})}),(0,s.jsx)(a5,{label:"Revenue model",children:(0,s.jsx)(tt.p,{ref:M("product.revenueModel"),value:h.productRevenueModel,onChange:e=>$("productRevenueModel",e.target.value)})}),(0,s.jsx)(a5,{label:"Scope V1",children:(0,s.jsx)(y.T,{ref:M("product.scopeV1"),value:h.productScopeV1,onChange:e=>$("productScopeV1",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"Non-goals",children:(0,s.jsx)(y.T,{ref:M("product.nonGoals"),value:h.productNonGoals,onChange:e=>$("productNonGoals",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"Launch priority",children:(0,s.jsx)(y.T,{ref:M("product.launchPriority"),value:h.productLaunchPriority,onChange:e=>$("productLaunchPriority",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]})]}),(0,s.jsxs)(a2,{surfaceTheme:t,sectionId:"workspace",highlighted:"workspace"===S,title:"Workspace",description:"Provisioning path and bootstrap rules.",register:e=>{j.current.workspace=e},children:[(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsx)(a5,{label:"Workspace name",children:(0,s.jsx)(tt.p,{ref:M("workspace.name"),value:h.workspaceName,onChange:e=>$("workspaceName",e.target.value)})}),(0,s.jsx)(a5,{label:"Workspace directory",children:(0,s.jsx)(tt.p,{ref:M("workspace.directory"),value:h.workspaceDirectory,onChange:e=>$("workspaceDirectory",e.target.value)})}),(0,s.jsx)(a5,{label:"Repository URL",children:(0,s.jsx)(tt.p,{ref:M("workspace.repoUrl"),value:h.workspaceRepoUrl,onChange:e=>$("workspaceRepoUrl",e.target.value)})}),(0,s.jsx)(a5,{label:"Existing folder path",children:(0,s.jsx)(tt.p,{ref:M("workspace.existingPath"),value:h.workspaceExistingPath,onChange:e=>$("workspaceExistingPath",e.target.value)})}),(0,s.jsx)(a5,{label:"Model id",children:(0,s.jsx)(tt.p,{ref:M("workspace.modelId"),value:h.workspaceModelId,onChange:e=>$("workspaceModelId",e.target.value)})})]}),(0,s.jsx)(a3,{surfaceTheme:t,label:"Source mode",value:h.workspaceSourceMode,options:aF,onChange:e=>$("workspaceSourceMode",e),fieldRef:M("workspace.sourceMode"),highlighted:"workspace.sourceMode"===A}),(0,s.jsx)(a3,{surfaceTheme:t,label:"Template",value:h.workspaceTemplate,options:az,onChange:e=>$("workspaceTemplate",e),fieldRef:M("workspace.template"),highlighted:"workspace.template"===A}),(0,s.jsx)(a3,{surfaceTheme:t,label:"Model profile",value:h.workspaceModelProfile,options:aB,onChange:e=>$("workspaceModelProfile",e),fieldRef:M("workspace.modelProfile"),highlighted:"workspace.modelProfile"===A}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsx)(a5,{label:"Stack decisions",children:(0,s.jsx)(y.T,{ref:M("workspace.stackDecisions"),value:h.workspaceStackDecisions,onChange:e=>$("workspaceStackDecisions",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"Docs",children:(0,s.jsx)(y.T,{ref:M("workspace.docs"),value:h.workspaceDocs,onChange:e=>$("workspaceDocs",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]}),(0,s.jsx)(a4,{surfaceTheme:t,label:"Starter docs",description:"Generate the first brief, architecture, and deliverables scaffold.",checked:h.workspaceRuleGenerateStarterDocs,onToggle:()=>$("workspaceRuleGenerateStarterDocs",!h.workspaceRuleGenerateStarterDocs),fieldRef:M("workspace.ruleGenerateStarterDocs"),highlighted:"workspace.ruleGenerateStarterDocs"===A}),(0,s.jsx)(a4,{surfaceTheme:t,label:"Memory",description:"Generate the persistent memory files for blueprint decisions.",checked:h.workspaceRuleGenerateMemory,onToggle:()=>$("workspaceRuleGenerateMemory",!h.workspaceRuleGenerateMemory),fieldRef:M("workspace.ruleGenerateMemory"),highlighted:"workspace.ruleGenerateMemory"===A}),(0,s.jsx)(a4,{surfaceTheme:t,label:"Kickoff mission",description:"Run the first mission immediately after bootstrap.",checked:h.workspaceRuleKickoffMission,onToggle:()=>$("workspaceRuleKickoffMission",!h.workspaceRuleKickoffMission),fieldRef:M("workspace.ruleKickoffMission"),highlighted:"workspace.ruleKickoffMission"===A})]}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsxs)(a2,{surfaceTheme:t,sectionId:"team",highlighted:"team"===S,title:"Team",description:"Planner behavior and coordination rules.",register:e=>{j.current.team=e},children:[(0,s.jsx)(a4,{surfaceTheme:t,label:"Allow ephemeral subagents",description:"Let the planner spin up temporary helpers when useful.",checked:h.teamAllowEphemeralSubagents,onToggle:()=>$("teamAllowEphemeralSubagents",!h.teamAllowEphemeralSubagents),fieldRef:M("team.allowEphemeralSubagents"),highlighted:"team.allowEphemeralSubagents"===A}),(0,s.jsx)(a4,{surfaceTheme:t,label:"Autopilot",description:"Let the planner take a stronger lead when the shape is clear.",checked:h.intakeAutopilot,onToggle:()=>$("intakeAutopilot",!h.intakeAutopilot),fieldRef:M("team.autopilot"),highlighted:"team.autopilot"===A}),(0,s.jsx)(a4,{surfaceTheme:t,label:"Review requested",description:"Keep the planner in a review-heavy shaping mode.",checked:h.intakeReviewRequested,onToggle:()=>$("intakeReviewRequested",!h.intakeReviewRequested),fieldRef:M("team.reviewRequested"),highlighted:"team.reviewRequested"===A}),(0,s.jsx)(a5,{label:"Max parallel runs",children:(0,s.jsx)(tt.p,{ref:M("team.maxParallelRuns"),type:"number",min:1,value:h.teamMaxParallelRuns,onChange:e=>$("teamMaxParallelRuns",e.target.value)})}),(0,s.jsx)(a5,{label:"Escalation rules",children:(0,s.jsx)(y.T,{ref:M("team.escalationRules"),value:h.teamEscalationRules,onChange:e=>$("teamEscalationRules",e.target.value),placeholder:"One rule per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(a2,{surfaceTheme:t,sectionId:"deploy",highlighted:"deploy"===S,title:"Deploy",description:"Review blockers, warnings, and first missions.",register:e=>{j.current.deploy=e},children:[(0,s.jsx)(a5,{label:"Blockers",children:(0,s.jsx)(y.T,{ref:M("deploy.blockers"),value:h.deployBlockers,onChange:e=>$("deployBlockers",e.target.value),placeholder:"One blocker per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"Warnings",children:(0,s.jsx)(y.T,{ref:M("deploy.warnings"),value:h.deployWarnings,onChange:e=>$("deployWarnings",e.target.value),placeholder:"One warning per line",className:"min-h-[84px]"})}),(0,s.jsx)(a5,{label:"First missions",children:(0,s.jsx)(y.T,{ref:M("deploy.firstMissions"),value:h.deployFirstMissions,onChange:e=>$("deployFirstMissions",e.target.value),placeholder:"One mission per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(a2,{surfaceTheme:t,title:"Note",description:"What happens on save?",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] leading-6",C?"text-[#6f675e]":"text-slate-300"),children:"Derived plan fields like readiness score, stage, and recommended missions are recalculated after you save."}),(0,s.jsx)("p",{className:(0,N.cn)("mt-3 text-[13px] leading-6",C?"text-[#6f675e]":"text-slate-300"),children:"If you want to edit something that is not shown here, switch to Raw JSON and change the exact nested field."})]})]})]})})}),(0,s.jsx)(aj.av,{value:"raw",className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[(0,s.jsx)("div",{className:(0,N.cn)("rounded-[18px] border px-4 py-3",C?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] leading-6",C?"text-[#6f675e]":"text-slate-300"),children:"This view edits the full blueprint JSON. It is the fastest way to change nested fields, agents, workflows, and any other detail."})}),(0,s.jsx)(y.T,{value:g,onChange:e=>{b(e.target.value),w(null)},className:(0,N.cn)("min-h-0 flex-1 font-mono text-[12px] leading-5",C?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100")}),f?(0,s.jsx)("p",{className:"rounded-xl border border-rose-300/30 bg-rose-500/10 px-3 py-2 text-[13px] leading-5 text-rose-200",children:f}):null,(0,s.jsx)("p",{className:(0,N.cn)("text-[12px] leading-5",C?"text-[#7b7268]":"text-slate-400"),children:"Current draft JSON snapshot loaded on open. Changes are saved through the same planner draft path as the structured editor."})]})})]}),(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-3 border-t px-4 py-4 md:px-5",C?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsx)(v.$,{type:"button",variant:"secondary",onClick:l,className:C?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Cancel"}),(0,s.jsxs)(v.$,{type:"button",onClick:"raw"===p?R:I,disabled:!T||n,className:C?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[n?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(F.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]})]})]})}function aZ(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function aQ(e){return e.join("\n")}function aX(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}function a0(e){let t=e.trim();return t.length>0?t:void 0}function a1({surfaceTheme:e,label:t}){return(0,s.jsx)("span",{className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","light"===e?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),children:t})}function a2({surfaceTheme:e,sectionId:t,highlighted:a=!1,title:r,description:n,register:i,children:l}){let o="light"===e;return(0,s.jsxs)("section",{ref:i,"data-blueprint-section":t,className:(0,N.cn)("rounded-[22px] border p-4 transition-all duration-300",o?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]",a&&(o?"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:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",o?"text-[#a0978b]":"text-slate-500"),children:r}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",o?"text-[#6f675e]":"text-slate-300"),children:n})]}),(0,s.jsx)("div",{className:"space-y-4",children:l})]})}function a5({label:e,children:t}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(tk.J,{children:e}),t]})}function a3({surfaceTheme:e,label:t,value:a,options:r,onChange:n,fieldRef:i,highlighted:l=!1}){let o="light"===e;return(0,s.jsxs)("div",{ref:i,tabIndex:-1,className:(0,N.cn)("space-y-2 rounded-[18px] border p-3 transition-all",o?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",l&&(o?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),children:[(0,s.jsx)(tk.J,{children:t}),(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:r.map(e=>{let t=e.value===a;return(0,s.jsx)("button",{type:"button",onClick:()=>n(e.value),className:(0,N.cn)("rounded-[16px] border px-3 py-3 text-left transition-colors",t?o?"border-[#161514] bg-[#161514] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":o?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]"),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:"text-[13px] font-medium",children:e.label}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",t?"opacity-80":o?"text-[#70685e]":"text-slate-400"),children:e.description})]}),t?(0,s.jsx)(eG.A,{className:"mt-0.5 h-4 w-4 shrink-0"}):null]})},e.value)})})]})}function a4({surfaceTheme:e,label:t,description:a,checked:r,onToggle:n,fieldRef:i,highlighted:l=!1}){let o="light"===e;return(0,s.jsx)("button",{type:"button",onClick:n,ref:i,className:(0,N.cn)("w-full rounded-[16px] border px-3 py-3 text-left transition-colors",r?o?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":o?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]",l&&(o?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),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:"text-[13px] font-medium",children:t}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",r?"opacity-80":o?"text-[#70685e]":"text-slate-400"),children:a})]}),(0,s.jsx)("span",{className:(0,N.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full border",r?o?"border-white/25 bg-white text-[#171410]":"border-white/20 bg-white text-slate-950":o?"border-[#cfc6ba] bg-transparent text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,s.jsx)(eG.A,{className:"h-3 w-3"})})]})})}function a8({open:e,surfaceTheme:t,plan:a,path:r,busy:n=!1,rewriteBusy:l=!1,onClose:o,onSave:c,onRewriteWithArchitect:p}){let m="light"===t,x=(0,i.useMemo)(()=>e&&a?aP({name:a.workspace.name||"Workspace",brief:a.company.mission||a.product.offer||void 0,template:a.workspace.template,sourceMode:a.workspace.sourceMode,rules:a.workspace.rules,agents:a.team.persistentAgents.filter(e=>e.enabled),docOverrides:a.workspace.docOverrides,toolExamples:[],contextSources:a.intake.sources}).find(e=>e.path===r)??null:null,[e,r,a]),[g,b]=(0,i.useState)(()=>x?.content??""),[f,w]=(0,i.useState)(""),[j,k]=(0,i.useState)(null),C=n||l||!!j;if((0,i.useEffect)(()=>{if(!j)return;if(j.revealedCharCount>=j.changedToCharCount){let e=globalThis.setTimeout(()=>{b(j.nextContent),k(null)},120);return()=>{globalThis.clearTimeout(e)}}let e=globalThis.setTimeout(()=>{k(e=>e?{...e,revealedCharCount:Math.min(e.revealedCharCount+1,e.changedToCharCount)}:e)},Math.max(12,Math.min(24,Math.round(1800/Math.max(j.changedToCharCount,1)))));return()=>{globalThis.clearTimeout(e)}},[j]),!e||!a||!x)return null;let S=async()=>{let e=await p({path:x.path,currentContent:g,instruction:f.trim()||void 0});if(!e)return;let t=function(e,t){if(e===t)return null;let a=e.split(/\r?\n/),s=t.split(/\r?\n/),r=0;for(;r<a.length&&r<s.length&&a[r]===s[r];)r+=1;let n=0;for(;n<a.length-r&&n<s.length-r&&a[a.length-1-n]===s[s.length-1-n];)n+=1;let i=s.slice(0,r),l=a.slice(r,a.length-n),o=s.slice(r,s.length-n),c=s.slice(s.length-n),d=o.join("\n"),p=Array.from(d).length;return{prefixLines:i,changedFromLines:l,changedToLines:o,suffixLines:c,changedToText:d,changedToCharCount:p,revealedCharCount:0,nextContent:t}}(g,e);if(!t){b(e),w("");return}k(t),w("")},A=async()=>{let e=structuredClone(a),t=a_([...e.workspace.docOverrides.filter(e=>e.path!==x.path),...g===x.baseContent?[]:[{path:x.path,content:g}]]);e.workspace.docOverrides=t;let s=g===x.baseContent?x.generated?`Reset ${x.path} to the generated default scaffold.`:`Kept ${x.path} at the loaded workspace content.`:x.generated?`Updated ${x.path} scaffold content.`:`Updated ${x.path} existing file content.`;await c(e,s)&&o()};return(0,s.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close document editor",onClick:o,className:(0,N.cn)("absolute inset-0 h-full w-full cursor-default",m?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,s.jsxs)("div",{className:(0,N.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[860px]",m?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-4 border-b px-4 py-3 md:px-5",m?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#9a9085]":"text-slate-500"),children:"Document editor"}),(0,s.jsx)("span",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#c2b6a5]":"text-slate-600"),children:"/"}),(0,s.jsx)("p",{className:(0,N.cn)("truncate font-mono text-[12px]",m?"text-[#4a433b]":"text-slate-300"),children:x.path}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",x.generated?x.overridden?m?"border-emerald-200 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":m?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400":m?"border-cyan-200 bg-cyan-50 text-cyan-900":"border-cyan-300/25 bg-cyan-300/12 text-cyan-100"),children:x.generated?x.overridden?"Customized":"Generated":"Existing"})]}),(0,s.jsx)("button",{type:"button",onClick:o,className:(0,N.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",m?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,s.jsx)(u.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 py-3 md:px-5",children:[(0,s.jsx)(ai.F,{className:"min-h-0 flex-1",children:j?(0,s.jsx)(a6,{surfaceTheme:t,animation:j}):(0,s.jsx)(y.T,{value:g,onChange:e=>b(e.target.value),className:(0,N.cn)("min-h-[60vh] font-mono text-[12px] leading-5",m?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:C})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t pt-2",style:{borderColor:m?"#e7dfd4":"rgba(255,255,255,0.1)"},children:[(0,s.jsx)(v.$,{type:"button",variant:"secondary",onClick:()=>{b(x.baseContent)},disabled:C,className:m?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:x.generated?"Reset to default":"Reset to loaded content"}),(0,s.jsxs)(v.$,{type:"button",onClick:A,disabled:C,className:m?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[n?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(F.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}),(0,s.jsx)("div",{className:(0,N.cn)("rounded-[18px] border px-4 py-3",m?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr),auto] md:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("label",{htmlFor:"architect-rewrite-prompt",className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#8b8278]":"text-slate-400"),children:"Architect instructions"}),(0,s.jsx)(y.T,{id:"architect-rewrite-prompt",value:f,onChange:e=>w(e.target.value),placeholder:"Tell Architect what to rewrite in this document.",className:(0,N.cn)("mt-2 min-h-[88px] font-sans text-[13px] leading-6",m?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:C}),(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[12px] leading-5",m?"text-[#7b7268]":"text-slate-400"),children:"Leave it blank for a general pass. Architect will rewrite only the changed block and keep the rest intact."})]}),(0,s.jsxs)(v.$,{type:"button",variant:"secondary",onClick:S,disabled:C,className:m?"rounded-full border-[#d8d0c4] bg-[#f8f3eb] text-[#3f3831] hover:bg-[#f1ebe4]":"rounded-full border-cyan-300/20 bg-cyan-300/10 text-cyan-100 hover:bg-cyan-300/16",children:[l?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Rewrite with Architect"]})]})})]})]})]})}function a6({surfaceTheme:e,animation:t}){var a,r;let n="light"===e,i=(0,N.cn)("whitespace-pre-wrap break-words rounded-lg border px-3 py-2",n?"border-[#e4ddd2] bg-white text-[#1a1714]":"border-white/10 bg-[#040810] text-slate-100"),l=(a=t.changedToText,(r=t.revealedCharCount)<=0?"":Array.from(a).slice(0,r).join(""));return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-4 py-3",n?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center justify-between gap-2 whitespace-nowrap text-[9px] uppercase tracking-[0.18em] leading-none",n?"text-[#8b8278]":"text-slate-400"),children:[(0,s.jsx)("span",{className:"min-w-0 truncate",children:"Rewriting"}),(0,s.jsxs)("span",{className:(0,N.cn)("shrink-0 rounded-full border px-2 py-0.5",n?"border-[#dfd7cc] bg-[#faf6f1] text-[#6e6458]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[t.revealedCharCount,"/",t.changedToCharCount||1]})]}),(0,s.jsxs)("div",{className:"mt-2 space-y-2 font-mono text-[12px] leading-5",children:[t.prefixLines.length?(0,s.jsx)("div",{className:(0,N.cn)("space-y-1.5",n?"text-[#27231e]":"text-slate-100"),children:t.prefixLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e||"\xa0"},`prefix-${t}`))}):null,(0,s.jsx)("div",{className:(0,N.cn)("rounded-2xl border px-3 py-2.5",n?"border-[#d8cdbc] bg-[#f9f5ef]":"border-cyan-300/20 bg-cyan-300/6"),children:(0,s.jsxs)("div",{className:"grid gap-2 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",n?"text-[#968a7c]":"text-slate-400"),children:"Old"}),(0,s.jsx)("div",{className:i,children:t.changedFromLines.length?t.changedFromLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words opacity-55 line-through",children:e||"\xa0"},`before-${t}`)):(0,s.jsx)("div",{className:"opacity-45",children:"[empty]"})})]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",n?"text-[#968a7c]":"text-slate-400"),children:"New"}),(0,s.jsx)("div",{className:(0,N.cn)(i,"min-h-[96px]"),children:t.changedToCharCount>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"whitespace-pre-wrap break-words",children:l}),t.revealedCharCount<t.changedToCharCount?(0,s.jsx)(f.P.span,{"aria-hidden":"true",className:(0,N.cn)("ml-0.5 inline-block align-[-0.15em] text-[1.1em] leading-none",n?"text-[#161514]":"text-cyan-100"),animate:{opacity:[0,1,0]},transition:{duration:.8,repeat:1/0,ease:"easeInOut"},children:"|"}):null]}):(0,s.jsx)("span",{className:(0,N.cn)("opacity-45",n?"text-[#7d7266]":"text-slate-400"),children:"[removed]"})})]})]})}),t.suffixLines.length?(0,s.jsx)("div",{className:(0,N.cn)("space-y-1.5",n?"text-[#27231e]":"text-slate-100"),children:t.suffixLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e||"\xa0"},`suffix-${t}`))}):null]})]})}var a7=a(34779),a9=a(97876),se=a(19469),st=a(23960),sa=a(7828),ss=a(12802),sr=a(8482);let sn=[{id:"company",label:"Company",icon:sa.A},{id:"product",label:"Product",icon:ss.A},{id:"workspace",label:"Workspace",icon:st.A},{id:"team",label:"Team",icon:tO.A},{id:"operations",label:"Operations",icon:sr.A},{id:"deploy",label:"Deploy",icon:a7.A}],si=[{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 sl(e){return si.find(t=>t.id===e)?.section??"company"}function so(e){return si.find(t=>t.id===e)?.label??"Draft"}function sc(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 sd(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`${sp(e.workspace.template)} \xb7 ${sp(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 sp(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}let su=Object.fromEntries(az.map(e=>[e.value,e.label])),sm={prompt:{label:"Prompt",icon:h.A},website:{label:"Website",icon:af.A},repo:{label:"Repo",icon:ab.A},folder:{label:"Folder",icon:aw.A}};function sh({surfaceTheme:e,plan:t,variant:a="panel",summaryText:r,className:n,onOpenBlueprintEditor:l,onOpenDocumentEditor:o}){var c;let d,p="light"===e,u=(0,i.useMemo)(()=>aR(t.workspace.template,t.workspace.rules),[t.workspace.rules,t.workspace.template]),m=(0,i.useMemo)(()=>new Set(a_(t.workspace.docOverrides).map(e=>e.path)),[t.workspace.docOverrides]),x=t.company.name||t.workspace.name||"Workspace",g=t.company.mission||t.product.offer||"Mission still being shaped.",b=t.company.targetCustomer||"Audience still being confirmed.",f=sp(t.workspace.sourceMode),w=su[t.workspace.template],y=sp(t.company.type),j=so(t.stage),k="blocked"===t.status?"Blocked":"ready"===t.status?"Ready":"deployed"===t.status?"Live":"deploying"===t.status?"Deploying":"Draft",C=r?.trim()||t.architectSummary,S=t.intake.sources.find(e=>"ready"===e.status)??t.intake.sources[0]??null,A=t.intake.inferences.slice(0,4),T=u.resources.length,$=((d=(c=x).trim().split(/\s+/).filter(Boolean)).length>1?`${d[0][0]??""}${d[1][0]??""}`:c.slice(0,2)).toUpperCase(),M=S?sm[S.kind].icon:"clone"===t.workspace.sourceMode?ab.A:"existing"===t.workspace.sourceMode?aw.A:h.A,I=S?S.label:f,R=S?`${sm[S.kind].label} \xb7 ${sC(S.status)}`:f,O=function(e){switch(e){case"blocked":return"danger";case"ready":case"deployed":return"success";case"review":return"warning";default:return"muted"}}(t.status),P="panel"===a,[_,D]=(0,i.useState)(0),E=P?3:5,L=P?["Collecting context from the prompt and sources…","Shaping the draft with the first signal set…","Writing the scaffold files now…","Draft ready."]:["Collecting context from the prompt and sources…","Pulling evidence from the website and files…","Extracting structured facts…","Grouping the file scaffold…","Checking remaining decisions…","Draft ready."],U=L[Math.min(_,L.length-1)]??L[0],z=_>=1,W=_>=1,B=_>=2,G=_>=(P?3:5),q=!P&&_>=3,V=!P&&_>=4,K=!P&&_>=5,J=P?u.sections.filter(e=>e.enabled):u.sections,H=J.reduce((e,t)=>e+t.resources.length,0),Y=P?H:T;return((0,i.useEffect)(()=>{let e="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,t=globalThis.setTimeout(()=>{D(e?E:0)},0);if(e)return()=>{globalThis.clearTimeout(t)};let a=P?[200,1400,3200]:[200,1400,2600,4300,6200],s=(P?[1,2,3]:[1,2,3,4,5]).map((e,t)=>globalThis.setTimeout(()=>D(e),a[t]??a[a.length-1]??0));return()=>{globalThis.clearTimeout(t),s.forEach(e=>globalThis.clearTimeout(e))}},[P,E]),P)?(0,s.jsxs)("div",{className:(0,N.cn)("workspace-architect-card-enter relative overflow-hidden rounded-[28px] border p-4 md:p-5",p?"border-[#e5ddd2] bg-white shadow-[0_16px_42px_rgba(56,47,38,0.06)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_16px_42px_rgba(0,0,0,0.2)]",n),children:[(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-none absolute inset-0",p?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.14),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.06),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.12),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.12),transparent_42%)]")}),(0,s.jsxs)("div",{className:"relative space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,s.jsx)("div",{className:(0,N.cn)("inline-flex size-11 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",p?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:$}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]",p?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:x,className:(0,N.cn)("text-[18px] font-semibold tracking-[-0.04em]",p?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:95},`hero-title:${P?"panel":"message"}:${x}`),(0,s.jsx)(sk,{surfaceTheme:e,tone:O,label:k})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:z?C:U,className:(0,N.cn)("workspace-architect-card-enter mt-1 line-clamp-2 text-[12px] leading-5",p?"text-[#6f685f]":"text-slate-300",!z&&"italic"),startDelayMs:80,wordDelayMs:115},`hero-status:${P?"panel":"message"}:${z?C:U}`)]})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",p?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-[24px] font-semibold tracking-[-0.05em]",p?"text-[#181612]":"text-white"),children:[t.readinessScore,"%"]}),l?(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>l("workspace.name"),className:p?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] px-3 text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] px-3 text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(F.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),W?(0,s.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:sS(90),children:[(0,s.jsx)(sx,{surfaceTheme:e,label:"Mission",value:g,icon:h.A,revealDelayMs:120}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Audience",value:b,icon:se.A,revealDelayMs:220}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Source",value:I,detail:R,icon:M,revealDelayMs:320})]}):null,B?(0,s.jsxs)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:sS(170),children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Mission",value:sj(g,48),icon:h.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Source",value:sj(I,34),icon:M,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:w,icon:st.A,revealDelayMs:220}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(T),icon:aa.A,revealDelayMs:330})]}):null,G?(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,s.jsx)(sf,{surfaceTheme:e,title:"Files",subtitle:`${J.length} groups in the canonical scaffold.`})}),(0,s.jsx)("div",{className:"space-y-2",children:J.map((t,a)=>(0,s.jsxs)("div",{className:(0,N.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",p?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:sS(72*a),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)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t.title,className:(0,N.cn)("text-[13px] font-semibold",p?"text-[#171410]":"text-white"),startDelayMs:120*a,wordDelayMs:70},`files-section-title:${t.id}:${a}:${t.title}`),(0,s.jsx)(sk,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]}),P?null:(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-5",p?"text-[#7a7168]":"text-slate-400"),children:t.description})]}),(0,s.jsxs)("span",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.16em]",p?"text-[#95897c]":"text-slate-500"),children:[t.resources.length," file",1===t.resources.length?"":"s"]})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map((r,n)=>(0,s.jsx)(sy,{surfaceTheme:e,label:r.label,tone:m.has(r.relativePath)?"success":"core"===t.id?"default":"accent",animated:!0,delayMs:(6*a+n)*88,interactive:!!o,onClick:o?()=>o(r.relativePath):void 0},r.relativePath))}):(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",p?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))})]}):null]})]}):(0,s.jsxs)("div",{className:(0,N.cn)("workspace-architect-card-enter relative overflow-hidden border",P?"rounded-[28px] p-4 md:p-5":"rounded-[26px] p-3.5 md:p-4",p?"border-[#e5ddd2] bg-white shadow-[0_22px_60px_rgba(56,47,38,0.07)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_22px_60px_rgba(0,0,0,0.22)]",n),children:[(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-none absolute inset-0",p?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.16),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.08),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.18),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.16),transparent_42%)]")}),(0,s.jsxs)("div",{className:"relative space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,s.jsx)("div",{className:(0,N.cn)("inline-flex size-12 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",p?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:$}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.24em]",p?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[20px] font-semibold tracking-[-0.04em]",p?"text-[#171410]":"text-white"),children:x}),(0,s.jsx)(sk,{surfaceTheme:e,tone:O,label:k})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:z?C:U,className:(0,N.cn)("workspace-architect-card-enter mt-1 line-clamp-3 text-[13px] leading-6",p?"text-[#6f685f]":"text-slate-300",!z&&"italic"),startDelayMs:80,wordDelayMs:120},`hero-status:${P?"panel":"message"}:${z?C:U}`)]})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",p?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-[28px] font-semibold tracking-[-0.05em]",p?"text-[#181612]":"text-white"),children:[t.readinessScore,"%"]}),P&&l?(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>l("workspace.name"),className:p?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(F.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null]})]}),W?(0,s.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:sS(90),children:[(0,s.jsx)(sx,{surfaceTheme:e,label:"Mission",value:g,icon:h.A,revealDelayMs:120}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Audience",value:b,icon:se.A,revealDelayMs:220}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Source",value:I,detail:R,icon:M,revealDelayMs:320})]}):null,B?(0,s.jsx)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:sS(170),children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:w,icon:st.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Stage",value:j,icon:ag.A,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(Y),icon:aa.A,revealDelayMs:220})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:w,icon:st.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Company",value:y,icon:sa.A,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Stage",value:j,icon:ag.A,revealDelayMs:220}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Sources",value:String(t.intake.sources.length),icon:af.A,revealDelayMs:330}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(T),icon:aa.A,revealDelayMs:440})]})}):null,q?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Evidence",subtitle:"What the architect pulled from the prompt, website, repo, or existing folder.",revealDelayMs:0}),t.intake.sources.length>0?(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:t.intake.sources.map((t,a)=>(0,s.jsx)(sw,{surfaceTheme:e,source:t,delayMs:120*a},t.id))}):(0,s.jsx)(sN,{surfaceTheme:e,title:"No sources yet",description:"Add a website, repo, folder, or short brief and the architect will start grounding the draft."})]}):null,V?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Inferred facts",subtitle:"Structured fields the architect is using to shape the workspace.",revealDelayMs:0}),A.length>0?(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:A.map((t,a)=>(0,s.jsx)(sv,{surfaceTheme:e,inference:t,delayMs:120*a},t.id))}):(0,s.jsx)(sN,{surfaceTheme:e,title:"No inferences yet",description:"Architect will populate structured facts once it has enough source signal."})]}):null,G?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Files to create",subtitle:P?"Canonical scaffold derived from the current workspace rules.":"The same file set the workspace will scaffold on the next pass.",revealDelayMs:0}),(0,s.jsx)(sk,{surfaceTheme:e,tone:"muted",label:`${Y} file${1===Y?"":"s"}`})]}),(0,s.jsx)("div",{className:"space-y-2.5",children:J.map((t,a)=>(0,s.jsxs)("div",{className:(0,N.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",p?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:sS(72*a),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] font-semibold",p?"text-[#171410]":"text-white"),children:t.title}),(0,s.jsx)(sk,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]})}),(0,s.jsxs)("span",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.16em]",p?"text-[#95897c]":"text-slate-500"),children:[t.resources.length," file",1===t.resources.length?"":"s"]})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map((r,n)=>(0,s.jsx)(sy,{surfaceTheme:e,label:r.label,tone:m.has(r.relativePath)?"success":"core"===t.id?"default":"accent",animated:!0,delayMs:(6*a+n)*52,interactive:!!o,onClick:o?()=>o(r.relativePath):void 0},r.relativePath))}):(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",p?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))})]}):null,K&&t.intake.confirmations.length>0?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Open decisions",subtitle:"These are the remaining items the architect still wants to confirm."}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.intake.confirmations.map((e,t)=>(0,s.jsxs)("span",{className:(0,N.cn)("workspace-architect-chip-enter inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] leading-4",p?"border-[#ddd6cb] bg-white text-[#6a6157]":"border-white/10 bg-white/[0.05] text-slate-300"),style:sS(48*t),children:[(0,s.jsx)(ag.A,{className:"mr-1 h-3 w-3 shrink-0"}),(0,s.jsx)("span",{className:"max-w-[28rem] truncate",children:e})]},`decision:${t}:${e}`))})]}):null]})]})}function sx({surfaceTheme:e,label:t,value:a,detail:r,icon:n,revealDelayMs:i=0}){let l="light"===e;return(0,s.jsx)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3",l?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",l?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(n,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",l?"text-[#8f8274]":"text-slate-500"),startDelayMs:i,wordDelayMs:55},`detail-label:${t}:${i}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,N.cn)("mt-1 text-[13px] font-medium leading-5",l?"text-[#171410]":"text-white"),startDelayMs:i+80,wordDelayMs:110},`detail-value:${t}:${i}`),r?(0,s.jsx)(sg,{surfaceTheme:e,text:r,className:(0,N.cn)("mt-1 text-[11px] leading-5",l?"text-[#7a7168]":"text-slate-400"),startDelayMs:i+200,wordDelayMs:95},`detail-extra:${t}:${i}`):null]})]})})}function sg({surfaceTheme:e,text:t,className:a,startDelayMs:r=0,wordDelayMs:n=110}){let l=(0,i.useMemo)(()=>t.trim().split(/\s+/).filter(Boolean),[t]),[o,c]=(0,i.useState)(0);return(0,i.useEffect)(()=>{let e="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(0===l.length)return;let t=e?[globalThis.setTimeout(()=>{c(l.length)},0)]:l.map((e,t)=>globalThis.setTimeout(()=>{c(t+1)},r+t*n));return()=>{t.forEach(e=>globalThis.clearTimeout(e))}},[r,n,l]),(0,s.jsxs)("p",{className:a,children:[l.slice(0,o).map((e,t)=>(0,s.jsxs)("span",{children:[t>0?" ":"",e]},`${t}:${e}`)),o<l.length?(0,s.jsx)("span",{"aria-hidden":"true",className:(0,N.cn)("ml-0.5 inline-block animate-pulse","light"===e?"text-[#6f685f]":"text-slate-300"),children:"▍"}):null]})}function sb({surfaceTheme:e,label:t,value:a,icon:r,revealDelayMs:n=0}){let i="light"===e;return(0,s.jsxs)("div",{className:(0,N.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-[11px]",i?"border-[#e4ddd2] bg-white text-[#5f5851]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,s.jsx)(r,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:"uppercase tracking-[0.16em]",startDelayMs:n,wordDelayMs:55},`stat-label:${t}:${n}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:"font-medium normal-case tracking-normal",startDelayMs:n+80,wordDelayMs:80},`stat-value:${t}:${n}`)]})}function sf({surfaceTheme:e,title:t,subtitle:a,revealDelayMs:r=0}){let n="light"===e;return(0,s.jsxs)("div",{children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8f8274]":"text-slate-500"),startDelayMs:r,wordDelayMs:60},`heading-title:${t}:${r}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,N.cn)("mt-1 text-[12px] leading-5",n?"text-[#70665c]":"text-slate-400"),startDelayMs:r+100,wordDelayMs:90},`heading-subtitle:${t}:${r}`)]})}function sw({surfaceTheme:e,source:t,delayMs:a=0}){var r;let n="light"===e,i=sm[t.kind].icon;return(0,s.jsx)("div",{className:(0,N.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",n?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:sS(a),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",n?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t.label,className:(0,N.cn)("text-[12px] font-semibold",n?"text-[#171410]":"text-white"),startDelayMs:a,wordDelayMs:70},`source-label:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.summary,className:(0,N.cn)("mt-1 text-[11px] leading-5",n?"text-[#7a7168]":"text-slate-400"),startDelayMs:a+90,wordDelayMs:95},`source-summary:${t.id}:${a}`)]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,s.jsx)(sk,{surfaceTheme:e,tone:"ready"===t.status?"success":"danger",label:sC(t.status)}),"number"==typeof t.confidence?(0,s.jsx)("span",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",n?"text-[#8f8274]":"text-slate-500"),children:(r=t.confidence,`${Math.round(100*r)}%`)}):null]})]}),t.details.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.details.slice(0,2).map((e,a)=>(0,s.jsx)("span",{className:(0,N.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",n?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:e},`source-detail:${t.id}:${a}:${e}`))}):null]})]})})}function sv({surfaceTheme:e,inference:t,delayMs:a}){let r="light"===e;return(0,s.jsxs)("div",{className:(0,N.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",r?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:sS(a),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:sp(t.section),className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",r?"text-[#8f8274]":"text-slate-500"),startDelayMs:a,wordDelayMs:55},`inference-section:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.label,className:(0,N.cn)("mt-1 text-[12px] font-semibold leading-5",r?"text-[#171410]":"text-white"),startDelayMs:a+80,wordDelayMs:75},`inference-label:${t.id}:${a}`)]}),(0,s.jsx)(sk,{surfaceTheme:e,tone:function(e){switch(e){case"confirmed":return"success";case"needs-confirmation":return"warning";default:return"muted"}}(t.status),label:"confirmed"===t.status?"Confirmed":"needs-confirmation"===t.status?"Needs check":"Inferred"})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:t.value,className:(0,N.cn)("mt-2 text-[13px] leading-6",r?"text-[#5f564e]":"text-slate-300"),startDelayMs:a+120,wordDelayMs:100},`inference-value:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.rationale,className:(0,N.cn)("mt-2 text-[11px] leading-5",r?"text-[#7a7168]":"text-slate-400"),startDelayMs:a+250,wordDelayMs:90},`inference-rationale:${t.id}:${a}`),t.sourceLabels.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.sourceLabels.slice(0,3).map((e,a)=>(0,s.jsx)("span",{className:(0,N.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",r?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:e},`inference-source:${t.id}:${a}:${e}`))}):null]})}function sy({surfaceTheme:e,label:t,tone:a="default",animated:r=!1,delayMs:n=0,interactive:i=!1,onClick:l}){let o="light"===e,c=(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] leading-4 transition-colors",r&&"workspace-architect-chip-enter","accent"===a?o?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===a?o?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"muted"===a?o?"border-[#e4ddd3] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-400":o?"border-[#e4ddd3] bg-white text-[#6d645b]":"border-white/10 bg-white/[0.05] text-slate-300",i?"success"===a?o?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":o?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":""),d=i?F.A:eG.A;return i?(0,s.jsxs)("button",{type:"button",onClick:l,"aria-label":`Edit ${t}`,className:c,style:sS(n),children:[(0,s.jsx)(d,{className:"mr-1 h-3 w-3"}),t]}):(0,s.jsxs)("span",{className:c,style:sS(n),children:[(0,s.jsx)(d,{className:"mr-1 h-3 w-3"}),t]})}function sj(e,t){let a=e.trim();return a.length<=t?a:`${a.slice(0,Math.max(0,t-1)).trimEnd()}…`}function sk({surfaceTheme:e,tone:t,label:a}){return(0,s.jsx)("span",{className:(0,N.cn)("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 sN({surfaceTheme:e,title:t,description:a}){let r="light"===e;return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border border-dashed px-3 py-3",r?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,N.cn)("text-[12px] font-medium",r?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:65},`empty-title:${t}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,N.cn)("mt-1 text-[12px] leading-5",r?"text-[#70665c]":"text-slate-400"),startDelayMs:90,wordDelayMs:90},`empty-description:${t}`)]})}function sC(e){return"ready"===e?"Ready":"Needs check"}function sS(e){return{animationDelay:`${e}ms`}}let sA=Object.fromEntries(az.map(e=>[e.value,e.label]));function sT({className:e,surfaceTheme:t,workspaceMode:a="create",mode:r,snapshot:n,plan:l,resolvedName:o,resolvedTemplate:c,sourceAnalysis:d,workspacePath:p,notice:u,basicRules:m,basicPreset:h,onOpenBlueprintEditor:x,onOpenDocumentEditor:g,onBasicPresetChange:b,onBasicRuleToggle:f,progress:w}){let y="light"===t,j=(0,i.useRef)({}),k=(0,i.useRef)(null),[C,S]=(0,i.useState)(null),A=(e="workspace.name")=>{x?.(e)},T=(0,i.useMemo)(()=>(function({mode:e,plan:t,notice:a,progress:s,resolvedName:r,resolvedTemplate:n,basicRules:i,basicPreset:l,sourceAnalysis:o,workspacePath:c}){return{mode:e,noticeSignature:a?`${a.tone}:${a.title}:${a.description}`:"",progressSignature:s?JSON.stringify(s):"",basic:{architectSignature:t?[t.architectSummary,t.company.name,t.company.mission,t.company.targetCustomer,t.workspace.template,JSON.stringify(t.workspace.rules),t.intake.sources.map(e=>`${e.kind}:${e.status}:${e.label}:${Math.round((e.confidence??0)*100)}`).join("|"),t.intake.inferences.map(e=>`${e.section}:${e.status}:${e.label}:${e.value}`).join("|"),t.intake.confirmations.join("|")].join(":"):"",summarySignature:[r,n,o.kind,o.label,o.hint,o.repoUrl??"",o.existingPath??"",o.websiteUrl??"",c].join(":"),defaultsSignature:`${l}:${i.generateStarterDocs}:${i.generateMemory}:${i.kickoffMission}`},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(sn.map(e=>[e.id,t?`${sc(t,e.id).label}:${sc(t,e.id).variant}:${sd(t,e.id)}`:""]))}}})({mode:r,plan:l,notice:u,progress:w,resolvedName:o,resolvedTemplate:c,basicRules:m,basicPreset:h,sourceAnalysis:d,workspacePath:p}),[h,m,r,u,l,w,o,c,d,p]),$=(0,i.useMemo)(()=>l?aP({name:l.workspace.name||"Workspace",brief:l.company.mission||l.product.offer||void 0,template:l.workspace.template,sourceMode:l.workspace.sourceMode,rules:l.workspace.rules,agents:l.team.persistentAgents.filter(e=>e.enabled),docOverrides:l.workspace.docOverrides,toolExamples:[],contextSources:l.intake.sources}):[],[l]),M=(0,i.useMemo)(()=>new Map($.map(e=>[e.path,e])),[$]),I=(0,i.useMemo)(()=>aR(l?.workspace.template??c,l?.workspace.rules??m),[m,l?.workspace.rules,l?.workspace.template,c]);return(0,i.useEffect)(()=>{let e=k.current;if(k.current=T,!e)return;let t=function(e,t){if(e.mode!==t.mode)return"basic"===t.mode?t.basic.architectSignature?"architect-readout":"summary":t.advanced.stage?`section-${sl(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.summarySignature!==t.basic.summarySignature?"summary":e.basic.defaultsSignature!==t.basic.defaultsSignature?"defaults":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-${sl(t.advanced.stage)}`;if(e.advanced.readinessSignature!==t.advanced.readinessSignature&&t.advanced.readinessSignature)return"readiness";for(let a of sn)if(e.advanced.sectionSignatures[a.id]!==t.advanced.sectionSignatures[a.id])return`section-${a.id}`;return null}(e,T);t&&S(t)},[T]),(0,i.useEffect)(()=>{if(!C)return;let e=j.current[C];e&&globalThis.requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"center"})});let t=globalThis.setTimeout(()=>{S(e=>e===C?null:e)},2200);return()=>{globalThis.clearTimeout(t)}},[C]),(0,s.jsx)("aside",{className:(0,N.cn)("min-h-0 border-t lg:border-l lg:border-t-0",y?"border-[#ebe5dd] bg-[#f7f2eb]":"border-white/10 bg-[rgba(5,9,18,0.92)]",e),children:(0,s.jsx)(ai.F,{className:"h-full",children:(0,s.jsxs)("div",{className:"space-y-4 p-4 md:p-5",children:[(0,s.jsx)(sM,{surfaceTheme:t,title:"basic"===r?"Workspace draft":"Workspace blueprint",subtitle:"basic"===r?"Live draft view. The fast path stays available while Architect fills in the details.":"Structured blueprint synced with the conversation.",action:l&&x?(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>A("workspace.name"),className:y?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(F.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null}),"create"===a?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(s$,{sectionKey:"setup-speed",activeSection:C,surfaceTheme:t,register:e=>{j.current["setup-speed"]=e},children:(0,s.jsx)(s_,{surfaceTheme:t,mode:r,preset:h,onPresetChange:b,onOpenBlueprintEditor:A})})}):null,u?(0,s.jsx)(s$,{sectionKey:"notice",activeSection:C,surfaceTheme:t,register:e=>{j.current.notice=e},children:(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-4 py-3","warning"===u.tone?y?"border-amber-200 bg-amber-50 text-amber-900":"border-amber-400/25 bg-amber-400/10 text-amber-100":y?"border-[#e3ddd4] bg-white text-[#3f3933]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",y?"text-[#9c9389]":"text-slate-500"),children:u.title}),(0,s.jsx)("p",{className:"mt-1 text-[13px] leading-6",children:u.description})]})}):null,w?(0,s.jsx)(s$,{sectionKey:"progress",activeSection:C,surfaceTheme:t,register:e=>{j.current.progress=e},children:(0,s.jsx)(ay,{progress:w,className:(0,N.cn)(y?"border-[#e5ded3] bg-white text-slate-900 [&_p]:text-inherit":"border-white/10 bg-slate-950/50")})}):null,"basic"===r?(0,s.jsxs)("div",{className:"space-y-3",children:[l?(0,s.jsx)(s$,{sectionKey:"architect-readout",activeSection:C,surfaceTheme:t,register:e=>{j.current["architect-readout"]=e},children:(0,s.jsx)(sh,{surfaceTheme:t,plan:l,variant:"panel",onOpenBlueprintEditor:A,onOpenDocumentEditor:g},l.updatedAt)}):null,(0,s.jsx)(s$,{sectionKey:"summary",activeSection:C,surfaceTheme:t,register:e=>{j.current.summary=e},children:(0,s.jsx)(sI,{surfaceTheme:t,resolvedName:o,resolvedTemplate:c,sourceAnalysis:d,workspacePath:p,workspaceRoot:n.diagnostics.workspaceRoot,summaryLabel:l?"Architect refreshed the draft.":"Resolved from quick setup.",onOpenBlueprintEditor:A})}),(0,s.jsx)(s$,{sectionKey:"defaults",activeSection:C,surfaceTheme:t,register:e=>{j.current.defaults=e},children:(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[22px] border p-4",y?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",y?"text-[#a0978b]":"text-slate-500"),children:"Fast-path defaults"}),(0,s.jsx)(sP,{surfaceTheme:t,plan:l,template:c,rules:m,preset:h,onRuleToggle:f,onOpenBlueprintEditor:A,onOpenDocumentEditor:g})]})})]}):l?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(s$,{sectionKey:"readiness",activeSection:C,surfaceTheme:t,register:e=>{j.current.readiness=e},children:(0,s.jsx)("button",{type:"button",onClick:()=>A("deploy.blockers"),className:(0,N.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",y?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",y?"text-[#a0978b]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,N.cn)("mt-1 text-[28px] font-semibold tracking-[-0.03em]",y?"text-[#181612]":"text-white"),children:[l.readinessScore,"%"]}),(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] leading-6",y?"text-[#6e665d]":"text-slate-300"),children:l.architectSummary})]}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-10 items-center justify-center rounded-full border",y?"border-[#e5ddd2] bg-[#f5f0e8] text-[#6a635b]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(tO.A,{className:"h-4 w-4"})})]})})}),sn.map(e=>{let a=sc(l,e.id),r=e.icon,n=`section-${e.id}`;return(0,s.jsx)(s$,{sectionKey:n,activeSection:C,surfaceTheme:t,register:e=>{j.current[n]=e},children:(0,s.jsx)("button",{type:"button",onClick:()=>A("company"===e.id?"company.mission":"product"===e.id?"product.offer":"workspace"===e.id?"workspace.name":"team"===e.id?"team.maxParallelRuns":"deploy.blockers"),className:(0,N.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",y?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",y?"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:(0,N.cn)("text-[14px] font-semibold",y?"text-[#171410]":"text-white"),children:e.label}),(0,s.jsx)(sO,{surfaceTheme:t,tone:a.variant,label:a.label})]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",y?"text-[#70685f]":"text-slate-300"),children:sd(l,e.id)})]})]})})},e.id)}),(0,s.jsx)(s$,{sectionKey:"documents",activeSection:C,surfaceTheme:t,register:e=>{j.current.documents=e},children:(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[22px] border p-4",y?"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)(aa.A,{className:(0,N.cn)("h-4 w-4",y?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,N.cn)("text-[14px] font-semibold",y?"text-[#171410]":"text-white"),children:"Documents"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-3",children:I.sections.map(e=>{let a=e.resources.map(e=>M.get(e.relativePath)).filter(e=>!!e);return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3",y?"border-[#e8e0d6] bg-[#faf6f1]":"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:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[12px] font-semibold",y?"text-[#171410]":"text-white"),children:e.title}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-5",y?"text-[#7a7168]":"text-slate-400"),children:e.description})]}),(0,s.jsx)(sO,{surfaceTheme:t,tone:e.enabled?"success":"muted",label:e.enabled?"Included":"Skipped"})]}),a.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:a.map(e=>(0,s.jsx)(sE,{surfaceTheme:t,label:e.path,tone:e.generated?e.overridden?"success":"default":"accent",interactive:!!g,onClick:g?()=>g(e.path):void 0},e.path))}):(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",y?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},e.id)})}),g?(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",y?"text-[#7a7168]":"text-slate-400"),children:"edit"===a?"These are the current workspace files grouped by the canonical context manifest.":"These are the scaffold documents that will be written for this workspace."}):null]})}),(0,s.jsx)(s$,{sectionKey:"deploy-review",activeSection:C,surfaceTheme:t,register:e=>{j.current["deploy-review"]=e},children:(0,s.jsxs)("button",{type:"button",onClick:()=>A("deploy.blockers"),className:(0,N.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",y?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(a7.A,{className:(0,N.cn)("h-4 w-4",y?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,N.cn)("text-[14px] font-semibold",y?"text-[#171410]":"text-white"),children:"Deploy review"})]}),l.deploy.blockers.length>0?(0,s.jsx)(sL,{surfaceTheme:t,title:"Blockers",tone:"danger",items:l.deploy.blockers}):null,l.deploy.warnings.length>0?(0,s.jsx)(sL,{surfaceTheme:t,title:"Warnings",tone:"warning",items:l.deploy.warnings}):null,0===l.deploy.blockers.length&&0===l.deploy.warnings.length?(0,s.jsx)("p",{className:(0,N.cn)("mt-3 text-[13px] leading-6",y?"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:(0,N.cn)("rounded-[22px] border border-dashed p-5",y?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[14px] font-medium",y?"text-[#211d19]":"text-white"),children:"Architect is preparing the blueprint."}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",y?"text-[#776f65]":"text-slate-300"),children:"Once the first plan is ready, this pane will start reflecting the structured workspace draft."})]})]})})})}function s$({sectionKey:e,activeSection:t,surfaceTheme:a,register:r,children:n}){return(0,s.jsx)("div",{ref:r,className:(0,N.cn)("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 sM({surfaceTheme:e,title:t,subtitle:a,action:r}){let n="light"===e;return(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:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8b7262]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",n?"text-[#705b4d]":"text-slate-300"),children:a})]}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})}function sI({surfaceTheme:e,resolvedName:t,resolvedTemplate:a,sourceAnalysis:r,workspacePath:n,workspaceRoot:i,summaryLabel:l,onOpenBlueprintEditor:o}){let c="light"===e;return(0,s.jsx)("div",{className:(0,N.cn)("rounded-[22px] border p-4",c?"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:(0,N.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",c?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(h.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",c?"text-[#a0978b]":"text-slate-500"),children:"Fast-path snapshot"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",c?"text-[#776f65]":"text-slate-400"),children:l}),(0,s.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,s.jsx)(sR,{surfaceTheme:e,label:"Name",value:t,icon:h.A,onClick:()=>o?.("workspace.name")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Template",value:sA[a],icon:av.A,onClick:()=>o?.("workspace.template")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Source",value:r.label,icon:"clone"===r.kind?ab.A:"website"===r.kind?af.A:aw.A,onClick:()=>o?.("workspace.sourceMode")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Path",value:n,icon:aw.A,mono:!0,title:`Root: ${i}`,onClick:()=>o?.("workspace.directory")})]})]})]})})}function sR({surfaceTheme:e,label:t,value:a,icon:r,detail:n,mono:i=!1,title:l,onClick:o}){let c="light"===e,d=!!o;return(0,s.jsx)("button",{type:"button",onClick:o,className:(0,N.cn)("w-full rounded-[14px] border px-3 py-2.5 text-left transition-colors",c?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",d&&(c?"cursor-pointer hover:border-[#d9b78b] hover:bg-[#f7efe3] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#d9b78b]/60":"cursor-pointer hover:border-cyan-300/30 hover:bg-white/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/30")),title:l,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",c?"border-[#e0d7cc] bg-white text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(r,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",c?"text-[#8d8276]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,N.cn)("truncate text-[12px] font-medium leading-4",c?"text-[#171410]":"text-white",i&&"font-mono text-[12px]"),title:a,children:a})]}),d?(0,s.jsx)(F.A,{className:(0,N.cn)("h-3.5 w-3.5 shrink-0",c?"text-[#8f8377]":"text-slate-400")}):null,n?(0,s.jsx)("span",{className:(0,N.cn)("shrink-0 text-[10px] leading-4",c?"text-[#776f65]":"text-slate-400"),children:n}):null]})})}function sO({surfaceTheme:e,tone:t,label:a}){return(0,s.jsx)("span",{className:(0,N.cn)("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 sP({surfaceTheme:e,plan:t,template:a,rules:r,preset:n,onRuleToggle:l,onOpenBlueprintEditor:o,onOpenDocumentEditor:c}){var d,p;let u,m,h,x,g,b="light"===e,f=aR(a,r),w=(d=a,p=r,u=aI(d),m=new Set(aT),h=u.filter(e=>m.has(e.relativePath)).map(e=>e.label),x=u.filter(e=>e.relativePath.startsWith("docs/")||e.relativePath.startsWith("deliverables/")).map(e=>e.label),g=u.filter(e=>"MEMORY.md"===e.relativePath||e.relativePath.startsWith("memory/")).map(e=>e.label),[{id:"core",title:"Core agent files",description:"Identity and operating rules.",checked:!0,locked:!0,files:h,rule:void 0},{id:"docs",title:"Starter docs",description:"Brief, architecture, handoff.",checked:p.generateStarterDocs,locked:!1,files:x,rule:"generateStarterDocs"},{id:"memory",title:"Memory files",description:"Durable decisions and context.",checked:p.generateMemory,locked:!1,files:g,rule:"generateMemory"},{id:"kickoff",title:"Kickoff mission",description:"Starts the first mission.",checked:p.kickoffMission,locked:!1,files:[],rule:"kickoffMission"}]),y=(0,i.useMemo)(()=>new Set(a_(t?.workspace.docOverrides).map(e=>e.path)),[t?.workspace.docOverrides]),j=!!t;return(0,s.jsxs)("div",{className:"mt-3 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:["custom"===n?(0,s.jsx)(sO,{surfaceTheme:e,tone:"muted",label:"Custom mix"}):(0,s.jsx)("span",{}),o?(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>o("workspace.ruleGenerateStarterDocs"),className:b?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(F.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit section"]}):null]}),(0,s.jsx)("div",{className:"space-y-2",children:w.map(t=>(0,s.jsx)("button",{type:"button",onClick:t.rule?()=>l(t.rule):void 0,disabled:!t.rule,className:(0,N.cn)("w-full rounded-[18px] border px-3 py-3 text-left transition-colors",b?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",t.rule?b?"hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"hover:border-white/15 hover:bg-white/[0.05]":"cursor-default"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",t.checked?b?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":b?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,s.jsx)(eG.A,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] font-medium",b?"text-[#171410]":"text-white"),children:t.title}),t.locked?(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",b?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400"),children:[(0,s.jsx)(a9.A,{className:"h-3 w-3"}),"Required"]}):null]}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",b?"text-[#776f65]":"text-slate-400"),children:t.description}),t.files.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.files.map(t=>(0,s.jsx)(sE,{surfaceTheme:e,label:t},t))}):null]})]})},t.id))}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-3",b?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(aa.A,{className:(0,N.cn)("h-4 w-4",b?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,N.cn)("text-[12px] uppercase tracking-[0.16em]",b?"text-[#8d8276]":"text-slate-500"),children:"Canonical manifest"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-3",children:f.sections.map(t=>(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[16px] border px-3 py-3",b?"border-[#e2d9cc] bg-white":"border-white/10 bg-white/[0.02]"),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:(0,N.cn)("text-[12px] font-semibold",b?"text-[#171410]":"text-white"),children:t.title}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-5",b?"text-[#7b7269]":"text-slate-400"),children:t.description})]}),(0,s.jsx)(sO,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map(t=>(0,s.jsx)(sE,{surfaceTheme:e,label:t.label,tone:y.has(t.relativePath)?"success":"default",interactive:!!(j&&c),onClick:j&&c?()=>c(t.relativePath):void 0},t.relativePath))}):(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",b?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))}),r.kickoffMission?(0,s.jsx)(sE,{surfaceTheme:e,label:"Kickoff mission",tone:"accent"}):null,j&&c?(0,s.jsx)("p",{className:(0,N.cn)("mt-2 text-[11px] leading-5",b?"text-[#7a7168]":"text-slate-400"),children:"Click a file chip to edit its scaffold or override."}):null]}),(0,s.jsxs)("p",{className:(0,N.cn)("text-[13px] leading-6",b?"text-[#70685f]":"text-slate-300"),children:["fastest"===n?"Core files only.":"custom"===n?"Only the extras you kept.":"Starter docs, memory, kickoff."," Switch to Advanced later if you need more control."]})]})}function s_({surfaceTheme:e,mode:t,preset:a,onPresetChange:r,onOpenBlueprintEditor:n}){let i="light"===e;return(0,s.jsxs)("div",{className:(0,N.cn)("rounded-xl border p-3",i?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",i?"text-[#a0978b]":"text-slate-500"),children:"Setup speed"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[11px] leading-5",i?"text-[#70685f]":"text-slate-300"),children:"basic"===t?"Choose how much scaffold the fast path should write.":"These presets also update the bootstrap rules."})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:["custom"===a?(0,s.jsx)(sO,{surfaceTheme:e,tone:"muted",label:"Custom"}):null,n?(0,s.jsxs)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>n("workspace.ruleGenerateStarterDocs"),className:i?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(F.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,s.jsx)(sD,{surfaceTheme:e,active:"standard"===a,title:"Standard",description:"Docs, memory, kickoff",onClick:()=>r("standard")}),(0,s.jsx)(sD,{surfaceTheme:e,active:"fastest"===a,title:"Fastest setup",description:"Core files only",onClick:()=>r("fastest")})]})]})}function sD({surfaceTheme:e,active:t,title:a,description:r,onClick:n}){let i="light"===e;return(0,s.jsx)("button",{type:"button",onClick:n,className:(0,N.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",t?i?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":i?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]"),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(av.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("p",{className:"truncate text-[12px] font-medium",children:a})]}),(0,s.jsx)("p",{className:(0,N.cn)("truncate text-right text-[11px] leading-4",t?"opacity-80":i?"text-[#776f65]":"text-slate-400"),children:r})]})})}function sE({surfaceTheme:e,label:t,tone:a="default",interactive:r=!1,onClick:n}){let i=(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] transition-colors","accent"===a?"light"===e?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===a?"light"===e?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"light"===e?"border-[#e4ddd3] bg-white text-[#6c645b]":"border-white/10 bg-white/[0.05] text-slate-300",r?"success"===a?"light"===e?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":"light"===e?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":"");return r?(0,s.jsxs)("button",{type:"button",onClick:n,"aria-label":`Edit ${t}`,className:i,children:[(0,s.jsx)(F.A,{className:"mr-1 h-3 w-3"}),t]}):(0,s.jsxs)("span",{className:i,children:[(0,s.jsx)(eG.A,{className:"mr-1 h-3 w-3"}),t]})}function sL({surfaceTheme:e,title:t,tone:a,items:r}){let n="light"===e;return(0,s.jsxs)("div",{className:(0,N.cn)("mt-3 rounded-[18px] border px-4 py-3","danger"===a?n?"border-rose-200 bg-rose-50":"border-rose-400/25 bg-rose-400/10":n?"border-amber-200 bg-amber-50":"border-amber-400/25 bg-amber-400/10"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",n?"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:(0,N.cn)("flex items-start gap-2 text-[13px] leading-6",n?"text-[#403934]":"text-slate-200"),children:[(0,s.jsx)(W.A,{className:"mt-1 h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{children:e})]},e))})]})}var sU=a(73875);function sF({surfaceTheme:e,mode:t,onModeChange:a,onNewDraft:r,badges:n,title:i="Create workspace",showModeToggle:l=!0,showNewDraft:o=!0}){let c="light"===e;return(0,s.jsx)("div",{className:(0,N.cn)("relative z-[1] border-b px-4 py-2 md:px-5",c?"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-col gap-2 md:flex-nowrap md:flex-row md:items-center md:justify-between md:gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border shadow-[0_8px_20px_rgba(56,47,38,0.08)]",c?"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)(tO.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.22em]",c?"text-[#7f6554]":"text-slate-500"),children:"Architect"}),(0,s.jsx)("span",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",c?"text-[#a59a8e]":"text-slate-600"),children:"/"}),(0,s.jsx)("h2",{className:(0,N.cn)("truncate text-[16px] font-semibold tracking-[-0.02em]",c?"text-[#2d2118]":"text-white"),children:i})]})]})}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 md:flex-nowrap md:justify-end",children:[n.length>0?(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 md:flex-nowrap",children:n.map(e=>(0,s.jsx)("span",{className:(0,N.cn)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[9px] 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)&&(c?"border-[#e4ddd3] bg-white text-[#5f5348]":"border-white/10 bg-white/[0.05] text-slate-300")),children:e.label},e.id))}):null,l?(0,s.jsxs)("div",{className:(0,N.cn)("inline-flex rounded-full border p-0.5",c?"border-[#e4ddd3] bg-[#f4efe7]":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)(sz,{surfaceTheme:e,active:"basic"===t,label:"Basic",onClick:()=>a("basic")}),(0,s.jsx)(sz,{surfaceTheme:e,active:"advanced"===t,label:"Advanced",onClick:()=>a("advanced")})]}):null,o&&r?(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,N.cn)("inline-flex h-8 items-center gap-2 rounded-full border px-2.5 text-[11px] transition-colors",c?"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)(sU.A,{className:"h-3.5 w-3.5"}),"New draft"]}):null]})]})})}function sz({surfaceTheme:e,active:t,label:a,onClick:r}){let n="light"===e;return(0,s.jsx)("button",{type:"button",onClick:r,className:(0,N.cn)("inline-flex min-w-[78px] items-center justify-center rounded-full px-2.5 py-1 text-[11px] 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 sW=a(3942);function sB({surfaceTheme:e,value:t,placeholder:a,onChange:r,onSubmit:n,disabled:l=!1,isBusy:o=!1,helperText:c,toolbar:p,className:u}){let m=(0,i.useRef)(null),h=!!t.trim()&&!l;(0,i.useEffect)(()=>{let e=m.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:(0,N.cn)("rounded-[20px] border p-2.5 transition-all duration-200 focus-within:shadow-[0_0_0_1px_rgba(0,0,0,0.02)]",b?"border-[#ddd6cb] bg-white shadow-[0_18px_56px_rgba(56,47,38,0.08)] focus-within:border-[#cfc6ba]":"border-white/10 bg-[rgba(7,12,22,0.92)] shadow-[0_18px_56px_rgba(0,0,0,0.34)] focus-within:border-cyan-300/30",u),children:[(0,s.jsx)("textarea",{ref:m,value:t,onChange:e=>r(e.target.value),onKeyDown:g,placeholder:a,className:(0,N.cn)("min-h-[44px] max-h-[200px] w-full resize-none overflow-y-auto border-0 bg-transparent px-1.5 py-1.5 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-2",children:[(0,s.jsxs)("div",{className:"flex min-h-8 items-center gap-2",children:[p,c?(0,s.jsx)("p",{className:(0,N.cn)("text-[11px]",b?"text-[#8b837a]":"text-slate-400"),children:c}):null]}),(0,s.jsx)("button",{type:"submit",disabled:!h,className:(0,N.cn)("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)(d.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(sW.A,{className:"h-3.5 w-3.5"})})]})]})}function sG({surfaceTheme:e,messages:t,architectMessageId:a=null,architectPlan:r=null,isTyping:n=!1,typingLabel:l="Typing…",emptyState:o,auxiliary:c,className:d}){let p=(0,i.useRef)(null),u=(0,i.useRef)(null);return(0,i.useEffect)(()=>{p.current?.scrollIntoView({block:"end"})},[a,r?.updatedAt,n,t.length]),(0,i.useEffect)(()=>{let e=u.current;if(!e||"u"<typeof ResizeObserver)return;let t=0,a=new ResizeObserver(()=>{globalThis.cancelAnimationFrame(t),t=globalThis.requestAnimationFrame(()=>{p.current?.scrollIntoView({block:"end"})})});return a.observe(e),()=>{a.disconnect(),globalThis.cancelAnimationFrame(t)}},[]),(0,s.jsx)(ai.F,{className:(0,N.cn)("h-full",d),children:(0,s.jsxs)("div",{ref:u,className:"mx-auto flex min-h-full w-full max-w-3xl flex-col gap-4 px-2 py-4 md:gap-5 md:px-4",children:[o,c,t.map(t=>(0,s.jsx)(sq,{message:t,surfaceTheme:e,architectMessageId:a,architectPlan:r},t.id)),n?(0,s.jsx)(sV,{surfaceTheme:e,label:l}):null,(0,s.jsx)("div",{ref:p,className:"h-6 w-full shrink-0"})]})})}function sq({message:e,surfaceTheme:t,architectMessageId:a,architectPlan:r}){let n="light"===t;if("assistant"===e.role&&r&&e.id===a)return(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(sh,{surfaceTheme:t,plan:r,variant:"message",summaryText:e.text},`${e.id}:${r.updatedAt}`)});if("system"===e.role)return(0,s.jsxs)("div",{className:(0,N.cn)("mx-auto w-full max-w-2xl rounded-2xl border px-4 py-3 text-[13px] leading-6",n?"border-[#e3ddd4] bg-[#f5f0e8] text-[#5b544d]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8b8074]":"text-slate-500"),children:e.author||"Workspace Wizard"}),(0,s.jsx)("p",{className:"mt-1",children:e.text})]});let i="user"===e.role,l="pending"===e.status;return(0,s.jsxs)("div",{className:(0,N.cn)("flex w-full items-start gap-2.5",i?"justify-end":"justify-start"),children:[i?null:(0,s.jsx)("div",{className:(0,N.cn)("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",n?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"Architect"===e.author?(0,s.jsx)(tO.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:(0,N.cn)("max-w-[min(100%,680px)]",i?n?"rounded-2xl border border-[#ddd6cb] bg-[#1a1715] px-3 py-2 text-white":"rounded-2xl border border-cyan-200/40 bg-cyan-300 px-3 py-2 text-slate-950":"space-y-1 px-0 py-0",l&&"opacity-75"),children:[!i&&e.author?(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",n?"text-[#8f857a]":"text-slate-500"),children:e.author}):null,(0,s.jsx)("p",{className:(0,N.cn)("whitespace-pre-wrap text-[14px] leading-7",i&&"leading-6"),children:e.text})]})]})}function sV({surfaceTheme:e,label:t}){let a="light"===e;return(0,s.jsxs)("div",{className:"flex w-full items-start gap-2.5",children:[(0,s.jsx)("div",{className:(0,N.cn)("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)(tO.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"max-w-[min(100%,680px)]",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",a?"text-[#8f857a]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2.5",children:[(0,s.jsxs)("div",{className:(0,N.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5",a?"border-[#e6dfd5] bg-white text-[#5a534c]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-1.5 animate-pulse rounded-full",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:120ms]",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:240ms]",a?"bg-[#5a534c]":"bg-slate-300")})]}),(0,s.jsx)("p",{className:(0,N.cn)("text-[12px] leading-5",a?"text-[#6f685f]":"text-slate-400"),children:t})]})]})]})}var sK=a(77402);let sJ={founder:"Founder",product:"Product Lead",architect:"System Architect",ops:"Operations",growth:"Growth",reviewer:"Reviewer"},sH={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 sY(e){return sH[e]??sH.medium}let sZ={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 sQ(){return globalThis.crypto?.randomUUID?.()??`plan-${Date.now()}`}function sX(e,t,a){return{id:sQ(),role:e,author:t,text:a,createdAt:new Date().toISOString()}}function s0(e){return{id:e.id?.trim()||sQ(),kind:e.kind,label:e.label.trim(),summary:e.summary.trim(),details:rp(e.details),status:e.status??"ready",createdAt:e.createdAt??new Date().toISOString(),confidence:"number"==typeof e.confidence?Math.max(0,Math.min(100,Math.round(e.confidence))):void 0,url:rd(e.url),error:rd(e.error)}}function s1(e){return{id:e.id?.trim()||sQ(),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:rc(e.rationale??""),sourceLabels:rp(e.sourceLabels)}}function s2(e){let t=rh(e?.id||e?.name||"operator")||"operator",a=e?.role?.trim()||"Operator",s=e?.name?.trim()||rx(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??(0,H.g0)("worker"),heartbeat:e?.heartbeat??{enabled:!1},responsibilities:rp(e?.responsibilities),outputs:rp(e?.outputs),channelIds:rp(e?.channelIds)}}function s5(e){return{id:rh(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:rp(e?.collaboratorAgentIds),successDefinition:e?.successDefinition?.trim()||"",outputs:rp(e?.outputs),channelIds:rp(e?.channelIds),enabled:e?.enabled!==!1}}function s3(e="internal",t){let a=sZ[e];return{id:rh(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,accountId:t?.accountId?.trim(),primaryAgentId:t?.primaryAgentId?.trim()??null,allowedChatIds:rp(t?.allowedChatIds),groupAssignments:Array.isArray(t?.groupAssignments)?t.groupAssignments.map(e=>({chatId:"string"==typeof e.chatId?e.chatId.trim():"",agentId:"string"==typeof e.agentId?e.agentId.trim():null,title:"string"==typeof e.title?e.title.trim():null,enabled:!1!==e.enabled})).filter(e=>!!e.chatId):[],credentials:t?.credentials?.map(e=>({...e,value:e.value??""}))??a.credentials.map(e=>({...e,value:""}))}}function s4(e){return{id:rh(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 s8(e,t){return aK(e,"core",t).map(t=>{var a,s,r,n,i,l,o;return s2({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??(0,H.g0)("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 s6(e,t){let a=t.find(e=>e.enabled&&e.isPrimary)?.id,s=rl(t,"review"),r=rl(t,"test"),n=rl(t,"learn"),i=rl(t,"browser");if("research"===e)return[s5({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"]}),s5({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[s5({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"]}),s5({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"]}),s5({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[s5({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"]}),s5({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"]}),s5({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 s7(){return[s3("internal",{id:"internal-ops",name:"Internal ops",purpose:"Default internal coordination surface for planner outputs and deploy notes.",announce:!1})]}function s9(e){var t,a,s,r,n,i,l,o,c,d,p,u,m,h,x,g,b,f,w,v,y,j,k,N,C,S,A,T;let $,M,I,R,O,P,_,D,E,L,U,F,z,W,B,G,q,V,K,J,H=rm(e),Y=H.intake.sources.some(e=>"workspace-edit-source"===e.id);if(H.runtime=(t=H.id,a=H.runtime,B=a?.architectSessionId?.trim()||`planner-${t}-architect`,G=Object.fromEntries(Object.entries(a?.advisorAgentIds??{}).filter(([,e])=>"string"==typeof e&&e.trim())),q=Object.fromEntries(Object.entries(sJ).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:rd(a?.workspaceId),workspacePath:rd(a?.workspacePath),architectAgentId:rd(a?.architectAgentId),architectSessionId:B,advisorAgentIds:G,advisorSessionIds:q,lastArchitectRunId:rd(a?.lastArchitectRunId),lastAdvisorRunIds:rp(a?.lastAdvisorRunIds),lastError:rd(a?.lastError)}),H.intake=(s={...H.intake,started:!!H.intake?.started||H.conversation.some(e=>"user"===e.role)},{started:!!s?.started,initialPrompt:rc(s?.initialPrompt??""),latestPrompt:rc(s?.latestPrompt??""),sources:(s?.sources??[]).map(e=>s0(e)),confirmations:rp(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=>s1(e)),suggestedReplies:rp(s?.suggestedReplies).slice(0,4)}),H.company.name=rc(H.company.name),H.company.mission=rc(H.company.mission),H.company.targetCustomer=rc(H.company.targetCustomer),H.company.constraints=rp(H.company.constraints),H.company.successSignals=rp(H.company.successSignals),H.product.offer=rc(H.product.offer),H.product.scopeV1=rp(H.product.scopeV1),H.product.nonGoals=rp(H.product.nonGoals),H.product.revenueModel=rc(H.product.revenueModel),H.product.launchPriority=rp(H.product.launchPriority),H.workspace.name=rc(H.workspace.name),H.workspace.directory=rd(H.workspace.directory),H.workspace.repoUrl=rd(H.workspace.repoUrl),H.workspace.existingPath=rd(H.workspace.existingPath),H.workspace.stackDecisions=rp(H.workspace.stackDecisions),H.workspace.docs=ru(rp(H.workspace.docs).concat((i=H.workspace.template,aD(i,H.workspace.rules).map(e=>e.path)))),H.workspace.docOverrides=a_(H.workspace.docOverrides),H.team.persistentAgents=H.team.persistentAgents.map(e=>s2({...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),Y){if(!H.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)){let e=H.team.persistentAgents.find(e=>e.enabled);e&&(e.isPrimary=!0)}}else{let e,t;if(0===H.team.persistentAgents.length&&(H.team.persistentAgents=s8(H.workspace.template,H.workspace.name)),!H.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)){let e=H.team.persistentAgents.find(e=>e.enabled);e&&(e.isPrimary=!0)}let a=H.team.persistentAgents.find(e=>e.enabled&&e.isPrimary);a&&H.workspace.name&&(l=a.name,o=a.role,e=l.trim().toLowerCase(),t=o.trim().toLowerCase(),!e||"default agent"===e||e===t||"primary agent"===e||"workspace agent"===e)&&(a.name=aJ(H.workspace.name,a.role,a.name))}H.operations.channels=H.operations.channels.map(e=>s3(e.type,e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||0!==H.operations.channels.length||(H.operations.channels=s7()),H.operations.workflows=H.operations.workflows.map(e=>s5(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||0!==H.operations.workflows.length||(H.operations.workflows=s6(H.workspace.template,H.team.persistentAgents)),H.operations.automations=H.operations.automations.map(e=>s4(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||(K=sY((V=rm(H)).intake.size),V.team.persistentAgents=function(e,t,a){var s;let r,n;if(a<=0)return[];return ro((n=(s=[...t,...s8(e),...(r=s2({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?[s2({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)=>s2({...e,enabled:!0,isPrimary:e.isPrimary||0===t}))}(V.workspace.template,V.team.persistentAgents,K.agentCount),V.operations.channels=function(e,t,a){let s=t.find(e=>"internal"===e.type)??s7()[0],r=[...t.filter(e=>"internal"!==e.type),...("content"===e?["telegram","discord","slack"]:["slack","discord","telegram"]).map(t=>s3(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[s3("internal",{...s,enabled:!0}),...r.slice(0,a)]}(V.workspace.template,V.operations.channels,K.externalChannelCount),V.operations.workflows=function(e,t,a,s){let r,n,i,l;return s<=0?[]:ro([...t,...s6(e,a),...(r=a.find(e=>e.enabled&&e.isPrimary)?.id,n=rl(a,"review"),i=rl(a,"learn"),l=rl(a,"ops"),[s5({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"]}),s5({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=rl(s,"review"),l=rl(s,"learn"),o=t.ownerAgentId&&r.has(t.ownerAgentId)?t.ownerAgentId:i??l??n,s5({...t,ownerAgentId:o,collaboratorAgentIds:t.collaboratorAgentIds.filter(e=>r.has(e)&&e!==o),enabled:!0})})}(V.workspace.template,V.operations.workflows,V.team.persistentAgents,K.workflowCount),V.operations.automations=function(e,t,a,s,r){let n,i,l;return r<=0?[]:ro([...t,...(n=rl(a,"review")??a.find(e=>e.enabled)?.id,i=rl(a,"learn")??n,[s4({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}),s4({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,c,d;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,c=rl(r,"review"),d=rl(r,"learn"),s4({...t,agentId:t.agentId&&i.has(t.agentId)?t.agentId:c??d??o,channelId:t.channelId&&l.has(t.channelId)?t.channelId:n[0]?.id,enabled:!0})})}(V.workspace.template,V.operations.automations,V.team.persistentAgents,V.operations.channels,K.automationCount),H=V),H.operations.hooks=H.operations.hooks.map(e=>({id:rh(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),H.operations.sandbox=(r=H.operations.sandbox,{workspaceOnly:r?.workspaceOnly??!0,mode:r?.mode??"default",notes:rp(r?.notes)}),Y||(H.deploy.firstMissions=(J=(n=H).team.persistentAgents.find(e=>e.enabled&&e.isPrimary),ru([J?"Inspect the new workspace, refine docs to match the blueprint, and break the first delivery batch into concrete tasks.":"",n.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.":"",n.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))));let Z=rn(H.company.name),Q=rn(H.workspace.name);if((!H.company.name||Z)&&H.workspace.name&&!Q&&(H.company.name=H.workspace.name),(!H.workspace.name||Q)&&H.company.name&&!Z&&(H.workspace.name=H.company.name),!H.intake.started)return H.deploy.blockers=[],H.deploy.warnings=[],H.intake.confirmations=[],H.intake.inferences=[],H.intake.suggestedReplies=[],H.readinessScore=0,H.architectSummary="Start with one prompt. Paste the project goal, website URL, repo, or existing folder and the architect will draft the workspace for you.",H.stage="intake",H.status="draft",H.updatedAt=new Date().toISOString(),H;let X=function(e){let t=[],a=sY(e.intake.size);for(let a of e.intake.sources.filter(e=>"error"===e.status))t.push("tr"===rt(e)?`${a.label} kaynağını inceleyemedim. Bu kaynak \xf6nemliyse şirket bağlamını manuel olarak doğrula.`:`I could not inspect ${a.label}. Confirm the company context manually if this source matters.`);return ru(t).slice(0,a.confirmationLimit)}(H),ee=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 ru(t)}(H),et=($=[],M=sY((c=H).intake.size),0===c.product.nonGoals.length&&$.push("No non-goals are defined for V1."),0===c.product.launchPriority.length&&$.push("Launch priorities are not ordered yet."),0===c.company.successSignals.length&&$.push("Success signals are still empty."),0===c.workspace.stackDecisions.length&&"content"!==c.workspace.template&&$.push("Critical stack decisions are not captured yet."),M.automationCount>0&&!c.operations.automations.some(e=>e.enabled)&&$.push("No automation loops are enabled."),M.externalChannelCount>0&&!c.operations.channels.some(e=>"internal"!==e.type)&&$.push("Only internal channels are configured."),M.agentCount>=3&&c.team.maxParallelRuns<2&&$.push("Parallel run limit is conservative for a multi-agent workspace."),ru($)),ea=(d=H).intake.reviewRequested||"deploying"===d.status||"deployed"===d.status;return H.intake.confirmations=X,H.intake.inferences=(I=[],R=(p=H).intake.sources.filter(e=>"ready"===e.status).map(e=>e.label),O=p.intake.confirmations.join(" ").toLowerCase(),p.company.name&&I.push(s1({section:"company",label:"Company",value:p.company.name,confidence:rs(p,"company-name"),status:rr(O,"company"),rationale:R.length>0?"Derived from linked context and the current brief.":"Derived from the current brief.",sourceLabels:R})),p.company.mission&&I.push(s1({section:"company",label:"Mission",value:p.company.mission,confidence:rs(p,"mission"),status:rr(O,"outcome"),rationale:"Architect condensed the first business outcome from the request.",sourceLabels:R})),p.company.targetCustomer&&I.push(s1({section:"company",label:"First audience",value:p.company.targetCustomer,confidence:rs(p,"target-customer"),status:rr(O,"audience"),rationale:"This is the current best guess for the first user or buyer segment.",sourceLabels:R})),I.push(s1({section:"workspace",label:"Workspace type",value:rx(p.workspace.template),confidence:rs(p,"template"),status:"inferred",rationale:"Template is inferred from the requested operating model and linked context.",sourceLabels:R})),I.push(s1({section:"workspace",label:"Starting point",value:"clone"===p.workspace.sourceMode?p.workspace.repoUrl||"Clone an existing repository":"existing"===p.workspace.sourceMode?p.workspace.existingPath||"Attach an existing folder":"Start from scratch",confidence:rs(p,"source-mode"),status:rr(O,"start"),rationale:"This is how the workspace will be materialized when you deploy.",sourceLabels:R})),p.product.offer&&I.push(s1({section:"product",label:"Offer",value:p.product.offer,confidence:rs(p,"offer"),status:"inferred",rationale:"Architect turned the brief into a concrete operator-facing offer.",sourceLabels:R})),(P=p.operations.channels.filter(e=>e.enabled&&"internal"!==e.type)).length>0&&I.push(s1({section:"operations",label:"External channels",value:P.map(e=>e.name).join(", "),confidence:rs(p,"channels"),status:"inferred",rationale:"The request implies these operating channels should exist after deploy.",sourceLabels:R})),(_=p.team.persistentAgents.find(e=>e.enabled&&e.isPrimary))&&I.push(s1({section:"team",label:"Primary operator",value:`${_.name} (${_.role})`,confidence:rs(p,"team"),status:"inferred",rationale:"Architect drafted a primary agent to own the first delivery loop.",sourceLabels:R})),(D=p.operations.workflows.find(e=>e.enabled))&&I.push(s1({section:"operations",label:"First workflow",value:D.name,confidence:rs(p,"workflow"),status:"inferred",rationale:"This is the first operational loop the company would run after deploy.",sourceLabels:R})),I.slice(0,8)),H.intake.suggestedReplies=(u=H,m=X,E=rt(u),L=[],U=sY(u.intake.size),F=function(e){let t=e.intake.sources.filter(e=>"ready"===e.status).flatMap(e=>[e.label,e.summary,...e.details]).join(" ").toLowerCase();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}(u),z=re(u),u.company.targetCustomer||(F&&L.push("tr"===E?`İlk hedef kitle ${ri(F)} gibi g\xf6r\xfcn\xfcyor.`:`The first audience looks like ${ri(F)}.`),"content"===u.workspace.template?(L.push("tr"===E?"İlk kullanıcılar topluluk y\xf6neticileri ve moderat\xf6rler.":"The first users are community managers and moderators."),L.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.")):L.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.")),u.company.mission||L.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."),!u.product.scopeV1.length&&u.company.mission&&u.company.targetCustomer&&L.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."),u.workspace.repoUrl||u.workspace.existingPath||ra(u.intake.latestPrompt||u.intake.initialPrompt)||(L.push("tr"===E?"Şimdilik varsayılan bir başlangı\xe7la ilerleyelim; kaynak t\xfcr\xfcn\xfc daha sonra istediğin gibi revize edebiliriz.":"We can proceed with a default starting point and revise the source later if you want."),L.push("tr"===E?"Eğer bir repo ya da mevcut klas\xf6r istiyorsan sonraki mesajda sadece onu s\xf6ylemen yeterli.":"If you want a repo or existing folder, just say so in the next edit.")),0===u.company.successSignals.length&&u.intake.turnCount>=2&&L.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||z||(L.push("tr"===E?"İstersen bu taslağı şimdi daha keskin hale getirebiliriz.":"If you want, we can tighten this draft right now."),L.push("tr"===E?"Gelişmiş edit\xf6r\xfc a\xe7.":"Open the advanced editor.")),ru(L).slice(0,U.suggestedReplyLimit)),H.deploy.blockers=ea?ee:[],H.deploy.warnings=ea?et:[],H.readinessScore=(h=H,x=ee,g=et,b=ea,W=14,h.company.name&&(W+=10),h.company.mission&&(W+=15),h.company.targetCustomer&&(W+=15),h.product.offer&&(W+=10),h.product.scopeV1.length>0&&(W+=10),h.workspace.name&&(W+=10),h.intake.sources.length>0&&(W+=6),h.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)&&(W+=10),h.operations.workflows.some(e=>e.enabled)&&(W+=10),h.operations.automations.some(e=>e.enabled)&&(W+=5),b?(W-=12*x.length,W-=3*g.length):W-=4*Math.max(0,h.intake.confirmations.length-1),Math.max(0,Math.min(100,W))),H.architectSummary=function(e,t,a,s){let r=rt(e),n=re(e),i=e.intake.sources.find(e=>"website"===e.kind&&"ready"===e.status&&"number"==typeof e.confidence&&e.confidence<80&&!!e.label),l=e.team.persistentAgents.filter(e=>e.enabled).length,o=e.operations.workflows.filter(e=>e.enabled).length,c=e.operations.automations.filter(e=>e.enabled).length,d=e.intake.confirmations.length;if(!e.intake.started)return"tr"===r?"Tek mesajla başla.":"Start with one prompt.";if(!s&&n){let t=e.company.mission||e.product.offer||e.company.name||e.workspace.name,a="clone"===e.workspace.sourceMode?"tr"===r?"klon repo":"a cloned repo":"existing"===e.workspace.sourceMode?"tr"===r?"mevcut klas\xf6r":"an existing folder":"tr"===r?"sıfırdan":"scratch",s=!i||e.company.name||e.workspace.name?"":"tr"===r?`Site adı i\xe7in ${i.label} varsayımını kullandım.`:`I used ${i.label} as the site name.`;return"tr"===r?[s,t?`İlk taslak ${t} etrafında hazır.`:`İlk taslak ${a} başlangıcıyla hazır.`].filter(Boolean).join(" "):[s,t?`First pass ready around ${t}.`:`First pass ready from ${a}.`].filter(Boolean).join(" ")}return s?"tr"===r?[e.company.mission?`Odak: ${e.company.mission}.`:"Misyon kısa bir c\xfcmle istiyor.",e.company.targetCustomer?`Kitle: ${e.company.targetCustomer}.`:"Kitle a\xe7ık.",`${l} agent, ${o} g\xf6rev, ${c} automation.`,d>0?`${d} revizyon kaldı.`:t.length>0?`${t.length} blocker kaldı.`:a.length>0?`${a.length} warning var.`:"Deploy'a hazır."].join(" "):[e.company.mission?`Focus: ${e.company.mission}.`:"Mission still needs a short sentence.",e.company.targetCustomer?`Audience: ${e.company.targetCustomer}.`:"Audience open.",`${l} agents, ${o} workflows, ${c} automations.`,d>0?`${d} revision${1===d?"":"s"} left.`:t.length>0?`${t.length} blocker${1===t.length?"":"s"} remain.`:a.length>0?`${a.length} warning${1===a.length?"":"s"} remain.`:"Ready to deploy."].join(" "):"tr"===r?[e.company.mission?`Odak: ${e.company.mission}.`:e.company.name||e.workspace.name?`İlk \xe7ıktı: ${e.company.name||e.workspace.name}.`:"İlk \xe7ıktı netleşiyor.",e.company.targetCustomer?`Kitle: ${e.company.targetCustomer}.`:"Kitle a\xe7ık.",e.intake.sources.length>0?`${e.intake.sources.length} kaynak topladım.`:"URL, repo ya da kısa brief yeterli.",`${l} agent, ${o} g\xf6rev, ${c} automation.`,d>0?`${d} revizyon kaldı.`:"Revizyona hazır."].join(" "):[e.company.mission?`Focus: ${e.company.mission}.`:`First outcome: ${e.company.name||e.workspace.name||"this workspace"}.`,e.company.targetCustomer?`Audience: ${e.company.targetCustomer}.`:"Audience open.",e.intake.sources.length>0?`I have ${e.intake.sources.length} source${1===e.intake.sources.length?"":"s"}.`:"Add a URL, repo, or short brief.",`${l} agents, ${o} workflows, ${c} automations.`,d>0?`${d} revision${1===d?"":"s"} left.`:"Ready to revise."].join(" ")}(H,ee,et,ea),H.stage=(f=H,w=ee,v=et,y=X,j=ea,f.intake.started?!j&&re(f)?f.intake.sources.length>0?"context-harvest":"intake":"deploying"===f.status?"deploying":"deployed"===f.status?"deployed":(k=f).company.mission||k.product.offer||k.workspace.name||k.intake.sources.length>0?((N=f).company.name||N.workspace.name)&&N.company.mission&&N.team.persistentAgents.some(e=>e.enabled)&&N.operations.workflows.some(e=>e.enabled)?j?w.length>0?"pressure-test":v.length>0||f.readinessScore<90?"decision-lock":"ready":y.length>0?"team-synthesis":"decision-lock":"team-synthesis":f.intake.turnCount>1?"context-harvest":"intake":"intake"),H.status=(C=H,S=ee,A=X,T=ea,C.intake.started?"deploying"===C.status||"deployed"===C.status?C.status:T?"blocked"===C.status&&S.length>0||S.length>0?"blocked":C.readinessScore>=90?"ready":"review":re(C)||A.length>0?"draft":"review":"draft"),H.updatedAt=new Date().toISOString(),H}function re(e){return e.intake.turnCount<=1&&!e.intake.reviewRequested}function rt(e,t){for(let s of[t,...e.conversation.slice().reverse().filter(e=>"user"===e.role).map(e=>e.text),e.intake.latestPrompt,e.intake.initialPrompt]){var a;let e=!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=s)?!function(e){let t=e?.trim();if(!t||/[çğıöşüÇĞİÖŞÜ]/.test(t))return!1;let a=t.toLowerCase().match(/\b(let'?s|the|and|for|with|from|this|that|what|how|why|when|where|who|should|could|would|need|want|start|build|create|launch|project|workspace|customer|user|team|goal|mission|review|deploy|product|website|repo|folder)\b/g);return!!(a&&a.length>=2)}(a)?null:"en":"tr";if(e)return e}return"en"}function ra(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 rs(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&&ra(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 rr(e,t){return e.includes(t)?"needs-confirmation":"inferred"}function rn(e){let t=e.toLowerCase();return/\b(yapal[ıi]m|ekleyelim|başlatal[ıi]m|kural[ıi]m|olsun|diyelim|verelim|koyal[ıi]m|kurmak|kurulum|oluşturmak|oluşturma|başlatmak|başlama|yapmak|yapma|istiyorum|istiyoruz|istemek|want|build|create|make|start|launch|setup|set up)\b/.test(t)}function ri(e){return e?e.charAt(0).toLowerCase()+e.slice(1):e}function rl(e,t){return e.find(e=>RegExp(t,"i").test(`${e.id} ${e.role} ${e.name}`))?.id}function ro(e){return e.filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t)}function rc(e){return e.trim()}function rd(e){return e?.trim()||void 0}function rp(e){return ru((e??[]).flatMap(e=>e.split(/\r?\n|,/g).map(e=>e.trim()).filter(Boolean)).map(e=>e.trim()).filter(Boolean))}function ru(e){return Array.from(new Set(e.filter(Boolean)))}function rm(e){return structuredClone(e)}function rh(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function rx(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function rg(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:"AgentOS 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:"AgentOS 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 rb(e){return{title:e.title,description:e.description,percent:0,steps:e.steps.map(e=>({...e,status:"pending",percent:0,activities:[]}))}}let rf=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 rw(){return{name:"",goal:"",source:""}}function rv(e){let t=e.trim();if(!t)return{kind:"empty",createSourceMode:"empty",label:"Fresh workspace",hint:"AgentOS will scaffold a new project folder."};if(rN(t))return{kind:"existing",createSourceMode:"existing",label:"Existing folder",hint:t,existingPath:t};if(rC(t))return{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:t,repoUrl:t};let a=rS(t);return a?rA(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 ry(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 rj(e){return e.name.trim()||function(e,t){let a=function(e){let t=e.trim();if(!t)return;if(rC(t))return rT(t.split(":").at(-1)??"");let a=rS(t);return a?rA(a)?rT(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):rN(t)?rT(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&&!rf.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 rk(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 rN(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}function rC(e){return/^git@[^:]+:[^/].+/.test(e)}function rS(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 rA(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 rT(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 r$="workspace-wizard-basic-source",rM="Imported quick setup assumptions:";function rI(e="standard"){return{...aG,workspaceOnly:!0,generateStarterDocs:"fastest"!==e,generateMemory:"fastest"!==e,kickoffMission:"fastest"!==e}}function rR(e){return{...rI(),...e,workspaceOnly:!0}}function rO(e,t,a,s){let r=structuredClone(e),n=rv(t.source),i=rj(t),l=t.goal.trim();return r.intake.mode=r.intake.mode||"guided",r.intake.started=!!(l||t.source.trim()),l&&(r.intake.initialPrompt||(r.intake.initialPrompt=l),r.intake.latestPrompt=l,r.company.mission=l,r.product.offer.trim()||(r.product.offer=l)),r.workspace.name=i,r.workspace.sourceMode=n.createSourceMode,r.workspace.repoUrl=n.repoUrl,r.workspace.existingPath=n.existingPath,r.workspace.template=s?.template??ry(`${l}
|
|
165
|
-
${t.source}`),r.workspace.modelProfile=s?.modelProfile??r.workspace.modelProfile??"balanced",r.workspace.rules=rR(a??r.workspace.rules),r.intake.sources=r.intake.sources.filter(e=>e.id!==r$),"empty"!==n.kind&&r.intake.sources.unshift(s0({id:r$,kind:"clone"===n.kind?"repo":"existing"===n.kind?"folder":"website"===n.kind?"website":"prompt",label:n.label,summary:n.hint,details:[n.hint],url:n.repoUrl??n.websiteUrl})),s9(r)}function rP(e){return rR(e.workspace.rules)}let r_="mission-control-workspace-plan-id";function rD({open:e,onOpenChange:t,initialMode:a="basic",workspaceEditId:r=null,surfaceTheme:n,snapshot:l,onRefresh:o,onWorkspaceCreated:c,onWorkspaceUpdated:p}){let m=!!r,x=function({open:e,initialMode:t,workspaceEditId:a,onRefresh:s,onWorkspaceCreated:r,onWorkspaceUpdated:n}){let[l,o]=(0,i.useState)(t),[c,d]=(0,i.useState)(null),[p,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,g]=(0,i.useState)(rw),[b,f]=(0,i.useState)(()=>rI("fastest")),[w,v]=(0,i.useState)(!0),[y,k]=(0,i.useState)(()=>ry("")),[N,C]=(0,i.useState)("solo"),[S,A]=(0,i.useState)("balanced"),[T,$]=(0,i.useState)(null),[M,I]=(0,i.useState)(!1),[R,O]=(0,i.useState)(!1),[P,_]=(0,i.useState)(!1),[D,E]=(0,i.useState)(!1),[L,U]=(0,i.useState)(!1),[F,z]=(0,i.useState)(!1),[W,B]=(0,i.useState)(!1),[G,q]=(0,i.useState)(!1),[,V]=(0,i.useState)(null),[K,J]=(0,i.useState)(null),[H,Y]=(0,i.useState)(null),[Z,Q]=(0,i.useState)(0),[X,ee]=(0,i.useState)(null),et=(0,i.useRef)(null),ea=(0,i.useRef)(null),es=(0,i.useRef)(null),er=(0,i.useMemo)(()=>a?`${r_}:${a}`:r_,[a]),en=(0,i.useMemo)(()=>rv(x.source),[x.source]),ei=(0,i.useMemo)(()=>{let e;return(e=rR(b)).generateStarterDocs||e.generateMemory||e.kickoffMission?e.generateStarterDocs&&e.generateMemory&&e.kickoffMission?"standard":"custom":"fastest"},[b]),el=(0,i.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, extracting intent, and narrowing the plan."}:t>=1?{title:"Collecting context",description:"The architect is reading the prompt, extracting intent, and drafting the next clarifying question."}:{title:"Starting planner",description:"The architect is opening the planning session and preparing the first intent pass."}: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:!c?.intake.started,step:R?Z:0,active:R||W||G}),[G,W,R,c?.intake.started,Z]),eo=(0,i.useCallback)(e=>(ea.current=e,d(e),h(!!e),e)?(u(e.id),g(rk(e)),f(rP(e)),globalThis.localStorage?.setItem(er,e.id),e):(u(null),null),[er]);(0,i.useEffect)(()=>{if(!R)return void Q(0);Q(0);let e=globalThis.setTimeout(()=>Q(1),1800),t=globalThis.setTimeout(()=>Q(2),6200);return()=>{globalThis.clearTimeout(e),globalThis.clearTimeout(t)}},[R]);let ec=(0,i.useCallback)(e=>{if(!c)return null;let t=s9(e(structuredClone(c)));return eo(t),t},[eo,c]),ed=(0,i.useCallback)(()=>globalThis.localStorage?.getItem(er)??null,[er]),ep=(0,i.useCallback)(()=>{globalThis.localStorage?.removeItem(er),h(!1)},[er]),eu=(0,i.useCallback)(async({resumeStored:e})=>{if(a){let t=e?globalThis.localStorage?.getItem(er):null;if(t){let e=await fetch(`/api/planner/${t}`,{cache:"no-store"});if(e.ok)return(await e.json()).plan}let s=await fetch(`/api/workspaces/${a}/edit-draft`,{method:"POST"}),r=await s.json();if(!s.ok||!r.plan)throw Error(r.error||"Unable to create workspace edit draft.");return r.seed&&(es.current=r.seed,V(r.seed)),r.plan}let t=e?globalThis.localStorage?.getItem(er):null;if(t){let e=await fetch(`/api/planner/${t}`,{cache:"no-store"});if(e.ok)return(await e.json()).plan}let s=await fetch("/api/planner",{method:"POST"}),r=await s.json();if(!s.ok||!r.plan)throw Error(r.error||"Unable to create planner workspace.");return r.plan},[er,a]),em=(0,i.useCallback)(async({resumeStored:e,draftOverride:t})=>{if(c)return c;if(et.current)return et.current;let a=(async()=>{I(!0);try{let a=await eu({resumeStored:e}),s=t??x,r=s.goal.trim()||s.source.trim()||s.name.trim()?rO(a,s,b,{template:y,modelProfile:S}):a;return eo(r)}catch(e){return j.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{I(!1),et.current=null}})();return et.current=a,a},[x,S,b,y,eo,c,eu]),eh=(0,i.useCallback)(async()=>{if($(null),J(null),Y(null),O(!1),_(!1),E(!1),U(!1),z(!1),B(!1),ee(null),et.current=null,a){ep(),d(null),ea.current=null,u(null),await em({resumeStored:!1,draftOverride:void 0})&&o("advanced");return}if("basic"===l){ep(),d(null),ea.current=null,u(null),g(rw()),f(rI("fastest")),v(!0),k(ry("")),C("solo"),A("balanced");return}ep(),d(null),ea.current=null,u(null);let e=rw();g(e),f(rI("fastest")),v(!0),k(ry("")),C("solo"),A("balanced"),await em({resumeStored:!1,draftOverride:e})&&o("advanced")},[ep,em,l,a]),ex=(0,i.useCallback)(()=>{ep(),$(null)},[ep]),eg=(0,i.useCallback)(async e=>{let t=e??ea.current;if(!t||!p)return!1;_(!0);try{let e=await fetch(`/api/planner/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t})}),a=await e.json();if(!e.ok||!a.plan)throw Error(a.error||"Unable to save planner workspace.");return eo(a.plan),j.o.success("Planner draft saved."),!0}catch(e){return j.o.error("Planner draft could not be saved.",{description:e instanceof Error?e.message:"Unknown planner save error."}),!1}finally{_(!1)}},[eo,p]),eb=(0,i.useCallback)(async e=>{let t=e??ea.current;if(!t||!p)return!1;E(!0);try{let e=await fetch(`/api/planner/${p}/simulate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t})}),a=await e.json();if(!e.ok||!a.plan)throw Error(a.error||"Unable to simulate planner team.");return eo(a.plan),j.o.success("Planner team simulated."),!0}catch(e){return j.o.error("Planner simulation failed.",{description:e instanceof Error?e.message:"Unknown planner simulation error."}),!1}finally{E(!1)}},[eo,p]),ef=(0,i.useCallback)(()=>{ec(e=>(e.intake.mode="advanced",e.intake.reviewRequested=!0,e.advisorNotes=[],e.conversation.push(sX("assistant","Workspace Architect","Deploy review is open now. I am surfacing the real blockers and warnings that matter before launch.")),e))},[ec]),ew=(0,i.useCallback)(async()=>{if(a)return null;let e=await em({resumeStored:!1,draftOverride:x})??ea.current;if(!e)return null;let t=rO(e,x,b,{template:y,modelProfile:S});eo(t),z(!0),Y(rb({...rg({sourceMode:t.workspace.sourceMode,agentCount:aK(t.workspace.template,N,t.workspace.name).filter(e=>e.enabled).length,kickoffMission:t.workspace.rules.kickoffMission??!0})}));try{let e=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...function(e,t={}){var a;return{name:e.workspace.name,brief:[(a=e).company.mission.trim()||a.product.offer.trim(),a.company.name.trim()?`Company: ${a.company.name.trim()}`:null,a.company.targetCustomer.trim()?`Audience: ${a.company.targetCustomer.trim()}`:null,a.product.offer.trim()?`Offer: ${a.product.offer.trim()}`:null,a.company.successSignals.length>0?`Success signals: ${a.company.successSignals.join(", ")}`:null,a.product.scopeV1.length>0?`Scope: ${a.product.scopeV1.join(", ")}`:null,...a.intake.sources.flatMap(e=>{if(e.id!==r$&&"website"!==e.kind)return[];if("repo"===e.kind&&e.url)return[`Bootstrap source: clone ${e.url}`];if("folder"===e.kind)return[`Bootstrap source: existing folder ${e.summary}`];if("website"===e.kind&&e.url){let t="number"==typeof e.confidence?` (${e.confidence}%)`:"";return[`Reference website${t}: ${e.url} - ${e.summary}`]}return"prompt"===e.kind?[`Additional context: ${e.summary}`]:[]})].filter(e=>!!e?.trim()).join("\n"),directory:e.workspace.directory,modelId:e.workspace.modelId,sourceMode:e.workspace.sourceMode,repoUrl:e.workspace.repoUrl,existingPath:e.workspace.existingPath,template:e.workspace.template,teamPreset:t.teamPreset??"solo",modelProfile:e.workspace.modelProfile||"balanced",docOverrides:e.workspace.docOverrides,rules:rR(e.workspace.rules),contextSources:e.intake.sources}}(t,{teamPreset:N}),stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw could not create the workspace.")}let a=null,n=null;if(await (0,sK.z)(e,async e=>{"progress"===e.type?Y(e.progress):(e.progress&&Y(e.progress),e.ok?a=e.result:n=e.error)}),n||!a)throw Error(n||"OpenClaw could not create the workspace.");let i=a;return ep(),await s(),r(i.workspaceId),j.o.success("Workspace created.",{description:`${i.agentIds.length} agent${1===i.agentIds.length?"":"s"} created at ${i.workspacePath}`}),i.warnings?.length&&j.o.message("Workspace created with a sync warning.",{description:i.warnings[0]}),i.kickoffError&&j.o.message("Workspace created, but kickoff needs attention.",{description:i.kickoffError}),i}catch(e){return j.o.error("Workspace creation failed.",{description:e instanceof Error?e.message:"Unknown workspace error."}),null}finally{z(!1)}},[x,S,b,N,y,ep,eo,em,s,r,a]),ev=(0,i.useCallback)(async()=>{let e=ea.current,t=es.current;if(!e||!a)return null;q(!0);try{let r=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:a,name:e.workspace.name,directory:e.workspace.directory,plan:e,baseline:t})}),i=await r.json();if(!r.ok||i.error)throw Error(i.error||"OpenClaw could not update the workspace.");return ep(),await s(),n?.(i.workspaceId??a),j.o.success("Workspace updated.",{description:i.workspacePath||e.workspace.directory||e.workspace.name}),i}catch(e){return j.o.error("Workspace update failed.",{description:e instanceof Error?e.message:"Unknown workspace error."}),null}finally{q(!1)}},[ep,s,n,a]),ey=(0,i.useCallback)(async()=>{var e;let t=ea.current;if(!t||!p)return null;U(!0),J(rb({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."},...rg({sourceMode:(e={sourceMode:t.workspace.sourceMode??"empty",agentCount:t.team.persistentAgents.filter(e=>e.enabled).length,kickoffMission:t.workspace.rules.kickoffMission??!0,hasChannels:!!t.operations.channels.some(e=>e.enabled&&"internal"!==e.type),hasAutomations:!!t.operations.automations.some(e=>e.enabled),hasPlannerKickoffs:!!t.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/${p}/deploy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t,stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Unable to deploy planner workspace.")}let a=null,n=null;if(await (0,sK.z)(e,async e=>{"progress"===e.type?J(e.progress):(e.progress&&J(e.progress),e.ok?a=e.result:n=e.error)}),n||!a)throw Error(n||"Unable to deploy planner workspace.");let i=a;return eo(i.plan),ep(),await s(),r(i.workspaceId),j.o.success("Workspace deployed.",{description:i.workspacePath}),i}catch(e){return j.o.error("Planner deploy failed.",{description:e instanceof Error?e.message:"Unknown deploy error."}),null}finally{U(!1)}},[ep,eo,s,r,p]),ej=(0,i.useCallback)(async e=>{if(!e.trim())return!1;O(!0),ee(e.trim());try{let a="advanced"===t&&!c&&!x.goal.trim()&&!x.source.trim()&&!x.name.trim(),s=await em({resumeStored:a,draftOverride:x})??c;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 eo(n.plan),$(null),!0}catch(e){return j.o.error("Planner turn failed.",{description:e instanceof Error?e.message:"Unknown planner turn error."}),!1}finally{ee(null),O(!1)}},[x,eo,em,t,c]),ek=(0,i.useCallback)(async({path:e,currentContent:t,instruction:a})=>{if(!c||!p)return null;let s=e.trim();if(!s)return null;B(!0);try{let e=await fetch(`/api/planner/${p}/document-rewrite`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:c,path:s,currentContent:t,instruction:a?.trim()||"Rewrite this document to improve clarity, usefulness, and consistency with the workspace context."})}),r=await e.json();if(!e.ok||!r.plan)throw Error(r.error||"Unable to rewrite the document.");eo(r.plan),$(null);let n=aO({name:r.plan.workspace.name||"Workspace",brief:r.plan.company.mission||r.plan.product.offer||void 0,template:r.plan.workspace.template,sourceMode:r.plan.workspace.sourceMode,rules:r.plan.workspace.rules,agents:r.plan.team.persistentAgents.filter(e=>e.enabled),docOverrides:r.plan.workspace.docOverrides,toolExamples:[],contextSources:r.plan.intake.sources}).find(e=>e.path===s);return j.o.success(`Architect rewrote ${s}.`,{description:r.reply||"The document override has been updated."}),n?.content??null}catch(e){return j.o.error("Document rewrite failed.",{description:e instanceof Error?e.message:"Unknown document rewrite error."}),null}finally{B(!1)}},[eo,c,p]),eN=(0,i.useCallback)(async()=>{let e=ed();if(!e)return h(!1),!1;I(!0);try{let t=await fetch(`/api/planner/${e}`,{cache:"no-store"}),s=await t.json();if(!t.ok||!s.plan)throw Error(s.error||"Unable to load the stored planner draft.");return eo(s.plan),k(s.plan.workspace.template),A(s.plan.workspace.modelProfile),C(s.plan.team.persistentAgents.filter(e=>e.enabled).length>1?"core":"solo"),o("advanced"),$({tone:"muted",title:a?"Resumed workspace edit":"Resumed previous draft",description:a?"Architect restored your earlier edit session so you can keep shaping the same workspace.":"Architect restored your earlier blueprint so you can keep shaping the same workspace."}),!0}catch(e){return j.o.error("Stored draft could not be resumed.",{description:e instanceof Error?e.message:"Unknown planner error."}),!1}finally{I(!1),et.current=null}},[eo,ed,a]),eC=(0,i.useCallback)(async e=>{if(e!==l){if(a){if("basic"===e)return;o("advanced");return}if("advanced"===e){let e=await em({resumeStored:!1,draftOverride:x});if(!e)return;let t=rO(e,x,b,{template:y,modelProfile:S}),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(rM))),!s&&!r)return s9(a);let n=[s?`goal: ${s}`:null,r?`source: ${r}`:null,`fast-path name: ${rj(t)}`].filter(Boolean);return a.conversation.push(sX("system","Workspace Wizard",`${rM} ${n.join(" \xb7 ")}`)),s9(a)}(t,x):t;eo(a),$(a.intake.started||x.goal.trim()||x.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),o("advanced");return}if(c)g(rk(c)),f(rP(c)),k(c.workspace.template),A(c.workspace.modelProfile),C(c.team.persistentAgents.filter(e=>e.enabled).length>1?"core":"solo"),$(c&&(c.team.persistentAgents.filter(e=>e.enabled).length>1||c.operations.workflows.some(e=>e.enabled)||c.operations.automations.some(e=>e.enabled)||c.operations.channels.some(e=>e.enabled&&"internal"!==e.type)||c.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 $(null);o("basic")}},[x,S,b,y,eo,em,l,c,a]),eS=(0,i.useCallback)(e=>{g(t=>{let a={...t,goal:e},s=w?ry(`${a.goal}
|
|
166
|
-
${a.source}`):y;return w&&k(s),"basic"===l&&d(e=>{let t=e?rO(e,a,b,{template:s,modelProfile:S}):e;return ea.current=t,t}),a})},[S,b,y,w,l]),eA=(0,i.useCallback)(e=>{g(t=>{let a={...t,source:e},s=w?ry(`${a.goal}
|
|
167
|
-
${a.source}`):y;return w&&k(s),"basic"===l&&d(e=>{let t=e?rO(e,a,b,{template:s,modelProfile:S}):e;return ea.current=t,t}),a})},[S,b,y,w,l]),eT=(0,i.useCallback)(e=>{g(t=>{let a={...t,name:e};return"basic"===l&&d(e=>{let t=e?rO(e,a,b,{template:y,modelProfile:S}):e;return ea.current=t,t}),a})},[S,b,y,l]),e$=(0,i.useCallback)(e=>{v(!1),k(e),d(t=>{let a=t?rO(t,x,b,{template:e,modelProfile:S}):t;return ea.current=a,a})},[x,S,b]),eM=(0,i.useCallback)(e=>{C(e)},[]),eI=(0,i.useCallback)(e=>{A(e),d(t=>{let a=t?rO(t,x,b,{template:y,modelProfile:e}):t;return ea.current=a,a})},[x,b,y]),eR=(0,i.useCallback)(e=>{let t=rI(e);f(t),d(e=>{let a=e?rO(e,x,t,{template:y,modelProfile:S}):e;return ea.current=a,a})},[x,S,y]),eO=(0,i.useCallback)(e=>{f(t=>{let a={...t,[e]:!t[e],workspaceOnly:!0};return d(e=>{let t=e?rO(e,x,a,{template:y,modelProfile:S}):e;return ea.current=t,t}),a})},[x,S,y]);return(0,i.useEffect)(()=>{if(!e){o(t),d(null),ea.current=null,u(null),h(!1),g(rw()),f(rI("fastest")),v(!0),k(ry("")),C("solo"),A("balanced"),$(null),Y(null),J(null),B(!1),q(!1),ee(null),V(null),es.current=null,et.current=null;return}let s=ed();if(o(a?"advanced":t),h(!a&&!!s),g(rw()),f(rI("fastest")),v(!0),k(ry("")),C("solo"),A("balanced"),$(null),Y(null),J(null),B(!1),q(!1),ee(null),V(null),es.current=null,et.current=null,!a&&"advanced"!==t){d(null),ea.current=null,u(null);return}if(a||"advanced"===t){let e=(async()=>{I(!0);try{let e=await eu({resumeStored:!a}),t=eo(e);return!a&&s&&t&&$({tone:"muted",title:"Resumed previous draft",description:"Architect restored the last saved blueprint. Start a new draft if you want a clean slate."}),t}catch(e){return j.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{I(!1),et.current=null}})();et.current=e}else d(null),ea.current=null,u(null)},[eo,ed,t,e,eu,a]),{mode:l,plan:c,planId:p,hasStoredDraft:m,notice:T,sourceAnalysis:en,basicDraft:x,basicRules:b,basicPreset:ei,basicTemplate:y,basicTeamPreset:N,basicModelProfile:S,isPlanLoading:M,isSending:R,isSaving:P,isSimulating:D,isDeploying:L,isCreating:F,isApplyingWorkspaceChanges:G,isDocumentRewriting:W,createProgress:H,deployProgress:K,architectBusyStatus:el,pendingUserMessage:X,setBasicGoal:eS,setBasicSource:eA,setBasicName:eT,setBasicTemplate:e$,setBasicTeamPreset:eM,setBasicModelProfile:eI,setBasicPreset:eR,toggleBasicRule:eO,setNotice:$,updatePlan:ec,switchMode:eC,startFreshDraft:eh,discardStoredDraft:ex,resumeStoredDraft:eN,savePlan:eg,simulatePlan:eb,requestReview:ef,createWorkspace:ew,deployPlan:ey,applyWorkspaceChanges:ev,submitArchitectTurn:ej,rewriteDocumentWithArchitect:ek}}({open:e,initialMode:a,workspaceEditId:r,onRefresh:o,onWorkspaceCreated:c,onWorkspaceUpdated:p}),[g,b]=(0,i.useState)(""),[f,w]=(0,i.useState)(!1),[y,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[A,T]=(0,i.useState)("intake"),[$,M]=(0,i.useState)("workspace.name"),[I,R]=(0,i.useState)("AGENTS.md"),O="light"===n,P=m?l.workspaces.find(e=>e.id===r)??null:null,_=e=>{e||(b(""),w(!1),N(!1),S(!1),T("intake"),M("workspace.name"),R("AGENTS.md")),t(e)},D=m?x.plan?.workspace.name??P?.name??rj(x.basicDraft):rj(x.basicDraft),E=m?x.plan?.workspace.template??P?.bootstrap.template??x.basicTemplate:x.plan?.workspace.template??x.basicTemplate,L=m?x.plan?.workspace.directory??P?.path??l.diagnostics.workspaceRoot:function(e,t,a=rv(t.source)){if("existing"===a.kind&&a.existingPath)return a.existingPath;let s=rj(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return`${(0,k.$7)(e)}/${s||"workspace"}`}(l.diagnostics.workspaceRoot,x.basicDraft,x.sourceAnalysis),U=(0,i.useMemo)(()=>(function(e,t,a,s){let r=[{id:"surface",label:a?"Editing workspace":"basic"===e?"Architect-assisted fast path":"Architect co-design",tone:"muted"}];return!a&&"basic"===e&&s&&r.push({id:"step",label:`Step ${rB.findIndex(e=>e.id===s)+1} / 3 \xb7 ${rB.find(e=>e.id===s)?.label??"Intake"}`,tone:"muted"}),t&&("basic"===e?t.intake.confirmations.length>0?r.push({id:"confirmations",label:`${t.intake.confirmations.length} decision${1===t.intake.confirmations.length?"":"s"} needed`,tone:t.intake.confirmations.length>1?"warning":"muted"}):t.intake.started&&r.push({id:"draft",label:"Draft synced live",tone:"muted"}):(t.intake.confirmations.length>0&&r.push({id:"confirmations",label:`${t.intake.confirmations.length} decision${1===t.intake.confirmations.length?"":"s"} needed`,tone:t.intake.confirmations.length>1?"warning":"muted"}),r.push({id:"stage",label:`Stage \xb7 ${so(t.stage)}`,tone:"muted"}),r.push({id:"readiness",label:`${t.readinessScore}% drafted`,tone:t.readinessScore>=85?"success":t.readinessScore>=45?"warning":"muted"}),r.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"}))),r})(x.mode,x.plan,m,A),[A,m,x.mode,x.plan]),F=(0,i.useMemo)(()=>{var e,t;let a;return e=x.plan,t=x.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},[x.pendingUserMessage,x.plan]),z=(0,i.useMemo)(()=>{for(let e=F.length-1;e>=0;e-=1){let t=F[e];if("assistant"===t.role&&"Architect"===t.author)return t.id}return null},[F]),W=x.isCreating?x.createProgress:x.isDeploying?x.deployProgress:null,B=x.isSending||x.isPlanLoading||x.isDeploying||x.isCreating||x.isDocumentRewriting||x.isApplyingWorkspaceChanges,G="basic"===x.mode&&x.hasStoredDraft&&!x.plan&&!x.isPlanLoading,q=m?!!(x.plan||g.trim()):!!(x.plan?.intake.started||x.basicDraft.goal.trim()||g.trim()),V=!!(x.plan?.intake.started||x.basicDraft.name.trim()||x.basicDraft.goal.trim()||x.basicDraft.source.trim()||g.trim()),K=async e=>{let t=(e??g).trim();if(!t)return!1;let a=void 0===e;a&&b("");let s=await x.submitArchitectTurn(t);return!s&&a&&b(g),s},J=async()=>{if(m){if(!(!g.trim()||await K()))return;await x.applyWorkspaceChanges()&&_(!1);return}(!g.trim()||await K())&&await x.createWorkspace()&&_(!1)},H=async()=>{m||await x.deployPlan()&&_(!1)},Y=async(e,t)=>{let a=t.trim()?{...e,conversation:[...e.conversation,sX("system","Workspace Wizard",t)]}:e;return x.savePlan(a)},Z=async(e,t)=>{let a=t.trim()?{...e,conversation:[...e.conversation,sX("system","Workspace Wizard",t)]}:e;return x.savePlan(a)},Q=(e="workspace.name")=>{M(e),w(!1),N(!0),S(!1)},X=e=>{R(e),w(!1),N(!1),S(!0)};return(0,s.jsx)(eF.lG,{open:e,onOpenChange:_,children:(0,s.jsxs)(eF.Cf,{className:O?"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)(eF.L3,{className:"sr-only",children:m?"Edit workspace":"Create workspace"}),(0,s.jsx)(eF.rr,{className:"sr-only",children:m?"Edit the existing workspace blueprint, documents, and agents using Architect.":"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:O?"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)(sF,{surfaceTheme:n,mode:x.mode,onModeChange:e=>{x.switchMode(e)},onNewDraft:m?void 0:()=>{b(""),w(!1),N(!1),S(!1),T("intake"),x.startFreshDraft()},title:m?"Edit workspace":"Create workspace",showModeToggle:!m,showNewDraft:!m,badges:U}),(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.jsx)("div",{className:O?"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:"basic"!==x.mode||m?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[x.architectBusyStatus?(0,s.jsx)("div",{className:O?"border-b border-[#ece5db] px-4 py-2.5 md:px-5":"border-b border-white/10 px-4 py-2.5 md:px-5",children:(0,s.jsxs)("div",{className:O?"rounded-2xl border border-[#e6dfd5] bg-white px-3 py-2":"rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2",children:[(0,s.jsx)("p",{className:O?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:x.architectBusyStatus.title}),(0,s.jsx)("p",{className:O?"mt-1 text-[12px] leading-5 text-[#6d665e]":"mt-1 text-[12px] leading-5 text-slate-300",children:x.architectBusyStatus.description})]})}):null,(0,s.jsx)("div",{className:"min-h-0 flex-1",children:(0,s.jsx)(sG,{surfaceTheme:n,messages:F,architectMessageId:z,architectPlan:x.plan,isTyping:x.isSending,typingLabel:"Architect is shaping the next pass...",emptyState:x.isPlanLoading&&0===F.length?(0,s.jsx)(rU,{surfaceTheme:n}):0===F.length&&"basic"===x.mode?(0,s.jsx)(rE,{surfaceTheme:n}):0===F.length?(0,s.jsx)(rL,{surfaceTheme:n}):null,auxiliary:(0,s.jsxs)(s.Fragment,{children:[G?(0,s.jsx)(rz,{surfaceTheme:n,isBusy:B,onResume:()=>{x.resumeStoredDraft()},onStartFresh:x.discardStoredDraft}):null,W?(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(ay,{progress:W,className:O?"border-[#e6dfd5] bg-white":"border-white/10 bg-slate-950/50"})}):null]})})}),(0,s.jsx)("div",{className:O?"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.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(sB,{surfaceTheme:n,value:g,onChange:b,onSubmit:async()=>{await K()},placeholder:m?"Tell Architect what to change in this workspace...":"basic"===x.mode?"Describe what this workspace should do...":"Refine the blueprint with Architect...",disabled:B,isBusy:x.isSending,helperText:m?"Architect updates the existing workspace draft as you chat.":"basic"===x.mode?"Architect keeps the fast-path draft synced as you chat.":"Architect updates the shared blueprint on every turn.",toolbar:m?(0,s.jsx)("span",{className:O?"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:"Editing draft"}):"basic"!==x.mode||x.plan?x.plan?(0,s.jsxs)("span",{className:O?"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 ",so(x.plan.stage)]}):null:(0,s.jsx)("span",{className:O?"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:"Live draft"})})})})]}):(0,s.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 md:px-5",children:(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4",children:[G?(0,s.jsx)(rz,{surfaceTheme:n,isBusy:B,onResume:()=>{x.resumeStoredDraft()},onStartFresh:x.discardStoredDraft}):null,x.isPlanLoading?(0,s.jsx)(rU,{surfaceTheme:n}):(0,s.jsx)(rE,{surfaceTheme:n}),(0,s.jsx)(rG,{surfaceTheme:n,step:A,isBusy:B,basicDraft:x.basicDraft,basicTemplate:x.basicTemplate,basicTeamPreset:x.basicTeamPreset,basicModelProfile:x.basicModelProfile,basicRules:x.basicRules,basicPreset:x.basicPreset,resolvedName:D,resolvedTemplate:E,sourceAnalysis:x.sourceAnalysis,workspacePath:L,onStepChange:T,onBasicNameChange:x.setBasicName,onBasicGoalChange:x.setBasicGoal,onBasicSourceChange:x.setBasicSource,onBasicTemplateChange:x.setBasicTemplate,onBasicTeamPresetChange:x.setBasicTeamPreset,onBasicModelProfileChange:x.setBasicModelProfile,onBasicPresetChange:x.setBasicPreset,onBasicRuleToggle:x.toggleBasicRule})]})})})}),(0,s.jsx)(sT,{className:"hidden lg:block",surfaceTheme:n,workspaceMode:m?"edit":"create",mode:x.mode,snapshot:l,plan:x.plan,resolvedName:D,resolvedTemplate:E,sourceAnalysis:x.sourceAnalysis,workspacePath:L,notice:x.notice,basicRules:x.basicRules,basicPreset:x.basicPreset,onOpenBlueprintEditor:Q,onOpenDocumentEditor:X,onBasicPresetChange:x.setBasicPreset,onBasicRuleToggle:x.toggleBasicRule,progress:m?null:"basic"===x.mode?x.createProgress:x.isDeploying?x.deployProgress:null})]}),f?(0,s.jsxs)("div",{className:O?"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:O?"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:O?"text-[11px] uppercase tracking-[0.18em] text-[#9f958a]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"basic"===x.mode?"Workspace draft":"Workspace blueprint"}),(0,s.jsx)("p",{className:O?"text-[13px] text-[#6f675e]":"text-[13px] text-slate-300",children:"Review the structured side of the same wizard."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[x.plan?(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>Q(),className:O?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit details"}):null,(0,s.jsx)("button",{type:"button",onClick:()=>w(!1),className:O?"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)(u.A,{className:"h-4 w-4"})})]})]}),(0,s.jsx)(sT,{className:"min-h-0 flex-1 border-t-0 lg:hidden",surfaceTheme:n,workspaceMode:m?"edit":"create",mode:x.mode,snapshot:l,plan:x.plan,resolvedName:D,resolvedTemplate:E,sourceAnalysis:x.sourceAnalysis,workspacePath:L,notice:x.notice,basicRules:x.basicRules,basicPreset:x.basicPreset,onOpenBlueprintEditor:Q,onOpenDocumentEditor:X,onBasicPresetChange:x.setBasicPreset,onBasicRuleToggle:x.toggleBasicRule,progress:m?null:"basic"===x.mode?x.createProgress:x.isDeploying?x.deployProgress:null})]}):null,y&&x.plan?(0,s.jsx)(aY,{open:y,surfaceTheme:n,plan:x.plan,busy:x.isSaving,focus:$,onClose:()=>N(!1),onSave:Y},`${x.plan.id}:${$}`):null,C&&x.plan?(0,s.jsx)(a8,{open:C,surfaceTheme:n,plan:x.plan,path:I,busy:x.isSaving,rewriteBusy:x.isDocumentRewriting,onClose:()=>S(!1),onSave:Z,onRewriteWithArchitect:x.rewriteDocumentWithArchitect},`${x.plan.id}:${I}`):null,(0,s.jsx)("div",{className:O?"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:O?"text-[13px] text-[#776f65]":"text-[13px] text-slate-300",children:"basic"===x.mode?"intake"===A?"Step 1 of 3. Capture the mission and source first.":"shape"===A?"Step 2 of 3. Pick the template and default shape.":"Step 3 of 3. Review the draft before creating.":"Chat and blueprint stay synced as you refine the plan."}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(v.$,{variant:"secondary",size:"sm",className:O?"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:()=>w(!0),children:[(0,s.jsx)(ax.A,{className:"mr-2 h-4 w-4"}),"View blueprint"]}),m?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(v.$,{variant:"secondary",size:"sm",className:O?"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 x.savePlan(),disabled:!x.plan||x.isSaving||x.isPlanLoading,children:[x.isSaving?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),(0,s.jsxs)(v.$,{size:"sm",className:O?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void J(),disabled:!q||x.isPlanLoading||x.isSending||x.isSaving||x.isApplyingWorkspaceChanges,children:[x.isApplyingWorkspaceChanges?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}):"basic"===x.mode?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(v.$,{variant:"secondary",size:"sm",className:O?"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:"intake"===A?()=>{x.switchMode("advanced")}:()=>{"shape"===A?T("intake"):"review"===A&&T("shape")},disabled:x.isCreating||x.isSending||x.isPlanLoading,children:"intake"===A?"Advanced details":"Back"}),(0,s.jsxs)(v.$,{size:"sm",className:O?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>{"intake"===A?T("shape"):"shape"===A?T("review"):J()},disabled:x.isCreating||x.isSending||x.isPlanLoading||"review"===A&&!V,children:["review"===A?x.isCreating?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}):(0,s.jsx)(ag.A,{className:"mr-2 h-4 w-4"}),"intake"===A?"Continue":"shape"===A?"Review draft":"Create workspace"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(v.$,{variant:"secondary",size:"sm",className:O?"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 x.savePlan(),disabled:!x.plan||x.isSaving||x.isPlanLoading,children:[x.isSaving?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),x.plan?.intake.reviewRequested?(0,s.jsxs)(v.$,{size:"sm",className:O?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void H(),disabled:!x.plan||x.plan.deploy.blockers.length>0||x.isDeploying||x.isPlanLoading,children:[x.isDeploying?(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(tO.A,{className:"mr-2 h-4 w-4"}),"Deploy workspace"]}):(0,s.jsx)(v.$,{size:"sm",className:O?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>x.requestReview(),disabled:!x.plan||x.isSending||x.isDeploying,children:"Review blueprint"})]})]})]})})]})]})})}function rE({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.22em]",t?"text-[#8b7262]":"text-slate-500"),children:"Fast path"}),(0,s.jsx)("p",{className:t?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Start with one prompt."}),(0,s.jsx)("p",{className:t?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Tell Architect what this workspace should do. It will reflect the intent back and ask the next critical question."})]})}function rL({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.22em]",t?"text-[#8b7262]":"text-slate-500"),children:"Blueprint mode"}),(0,s.jsx)("p",{className:t?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Shape the workspace with Architect."}),(0,s.jsx)("p",{className:t?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Describe the operating model, and the structured draft updates as you chat."})]})}function rU({surfaceTheme:e}){return(0,s.jsxs)("div",{className:"light"===e?"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-[#e6dfd5] bg-white px-4 py-3 text-[13px] text-[#6d665e]":"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.04] px-4 py-3 text-[13px] text-slate-300",children:[(0,s.jsx)(d.A,{className:"h-4 w-4 animate-spin"}),"Architect is opening the planning session and extracting intent from the latest brief."]})}function rF({surfaceTheme:e,name:t,goal:a,source:r,resolvedName:n,resolvedTemplate:i,workspacePath:l,sourceAnalysis:o,disabled:c,onNameChange:d,onGoalChange:p,onSourceChange:u}){let m="light"===e,x="clone"===o.kind?ab.A:"website"===o.kind?af.A:aw.A;return(0,s.jsxs)("div",{className:(0,N.cn)("mx-auto w-full rounded-[24px] border p-4 shadow-[0_18px_56px_rgba(56,47,38,0.06)] md:p-5",m?"border-[#e4ddd3] 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:(0,N.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",m?"border-[#e4ddd3] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(h.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:m?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Step 1 \xb7 Intake"}),(0,s.jsx)("p",{className:m?"mt-1 text-[12px] leading-5 text-[#70685f]":"mt-1 text-[12px] leading-5 text-slate-300",children:"Give Architect the mission and source. The name can stay optional."})]})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3",children:[(0,s.jsx)(rW,{surfaceTheme:e,label:"Workspace name",children:(0,s.jsx)(tt.p,{value:t,onChange:e=>d(e.target.value),placeholder:"Optional. Architect can infer it.",disabled:c,className:m?"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)(rW,{surfaceTheme:e,label:"Goal",children:(0,s.jsx)(y.T,{value:a,onChange:e=>p(e.target.value),placeholder:"What should this workspace help you accomplish?",disabled:c,className:m?"min-h-[100px] border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"min-h-[100px] 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)(rW,{surfaceTheme:e,label:"Source",children:(0,s.jsx)(tt.p,{value:r,onChange:e=>u(e.target.value),placeholder:"Repo URL, website URL, or existing folder path",disabled:c,className:m?"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.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[20px] border px-3 py-3",m?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(h.A,{className:(0,N.cn)("h-4 w-4",m?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#a0978b]":"text-slate-500"),children:"Live preview"})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[(0,s.jsx)(rQ,{surfaceTheme:e,label:"Name",value:n,icon:h.A}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Template",value:aq[i].label,icon:av.A}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Source",value:o.label,icon:x}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Path",value:l,icon:aw.A,mono:!0})]})]})]})}function rz({surfaceTheme:e,isBusy:t,onResume:a,onStartFresh:r}){let n="light"===e;return(0,s.jsx)("div",{className:n?"mx-auto w-full max-w-3xl rounded-[22px] border border-[#e4ddd3] bg-[#fffaf3] px-4 py-4 shadow-[0_18px_48px_rgba(56,47,38,0.05)]":"mx-auto w-full max-w-3xl rounded-[22px] border border-white/10 bg-white/[0.05] px-4 py-4",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:n?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Previous draft found"}),(0,s.jsx)("p",{className:n?"mt-1 text-[14px] leading-6 text-[#30261d]":"mt-1 text-[14px] leading-6 text-white",children:"Architect still has an earlier workspace blueprint. Resume it or start fresh before creating a new one."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(v.$,{variant:"secondary",size:"sm",className:n?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:r,disabled:t,children:"Start fresh"}),(0,s.jsx)(v.$,{size:"sm",className:n?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:a,disabled:t,children:"Resume blueprint"})]})]})})}function rW({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 rB=[{id:"intake",label:"Intake",hint:"Mission, name, source"},{id:"shape",label:"Shape",hint:"Template and defaults"},{id:"review",label:"Review",hint:"Confirm and launch"}];function rG({surfaceTheme:e,step:t,isBusy:a,basicDraft:r,basicTemplate:n,basicTeamPreset:i,basicModelProfile:l,basicRules:o,basicPreset:c,resolvedName:d,resolvedTemplate:p,sourceAnalysis:u,workspacePath:m,onStepChange:h,onBasicNameChange:x,onBasicGoalChange:g,onBasicSourceChange:b,onBasicTemplateChange:f,onBasicTeamPresetChange:w,onBasicModelProfileChange:v,onBasicPresetChange:y,onBasicRuleToggle:j}){return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(rq,{surfaceTheme:e,step:t,onStepChange:h}),"intake"===t?(0,s.jsx)(rF,{surfaceTheme:e,name:r.name,goal:r.goal,source:r.source,resolvedName:d,resolvedTemplate:p,workspacePath:m,sourceAnalysis:u,onNameChange:x,onGoalChange:g,onSourceChange:b}):"shape"===t?(0,s.jsx)(rV,{surfaceTheme:e,basicTemplate:n,basicTeamPreset:i,basicModelProfile:l,basicRules:o,basicPreset:c,onBasicTemplateChange:f,onBasicTeamPresetChange:w,onBasicModelProfileChange:v,onBasicPresetChange:y,onBasicRuleToggle:j,isBusy:a}):(0,s.jsx)(rK,{surfaceTheme:e,basicDraft:r,basicTeamPreset:i,basicModelProfile:l,basicRules:o,basicPreset:c,resolvedName:d,resolvedTemplate:p,sourceAnalysis:u,workspacePath:m,onStepChange:h})]})}function rq({surfaceTheme:e,step:t,onStepChange:a}){let r="light"===e,n=rB.findIndex(e=>e.id===t);return(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:rB.map((e,i)=>{let l=e.id===t,o=i<n;return(0,s.jsxs)("button",{type:"button",onClick:()=>a(e.id),className:(0,N.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-left transition-colors",l?r?"border-[#c89e73]/35 bg-[#f8efe4] text-[#5d4331]":"border-cyan-300/30 bg-cyan-400/10 text-cyan-50":o?r?"border-[#dccfc3] bg-white text-[#7e6757]":"border-emerald-300/20 bg-emerald-400/10 text-emerald-50":r?"border-[#e6dbd0] bg-white/80 text-[#8b7563]":"border-white/10 bg-white/[0.04] text-slate-400"),children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-medium",l?r?"bg-[#c89e73]/15 text-[#5d4331]":"bg-cyan-300/20 text-cyan-50":o?r?"bg-[#f0e7de] text-[#7a6556]":"bg-emerald-300/20 text-emerald-50":r?"bg-[#f2ece6] text-[#917866]":"bg-white/10 text-slate-400"),children:i+1}),(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block text-[10px] font-medium uppercase tracking-[0.16em]",children:e.label}),(0,s.jsx)("span",{className:"block text-[10px] leading-4 opacity-75",children:e.hint})]})]},e.id)})})}function rV({surfaceTheme:e,basicTemplate:t,basicTeamPreset:a,basicModelProfile:r,basicRules:n,basicPreset:i,onBasicTemplateChange:l,onBasicTeamPresetChange:o,onBasicModelProfileChange:c,onBasicPresetChange:d,onBasicRuleToggle:p,isBusy:u}){let m="light"===e,h=aq[t];return(0,s.jsxs)("section",{className:(0,N.cn)("rounded-[24px] border p-4 md:p-5",m?"border-[#e4ddd3] 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",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",m?"text-[#8b7262]":"text-slate-500"),children:"Step 2 \xb7 Shape"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",m?"text-[#70685f]":"text-slate-300"),children:"Pick the template and defaults that best match the workspace."})]}),(0,s.jsx)(J.E,{variant:"muted",className:(0,N.cn)("shrink-0",m?"border-[#ddd6cb] bg-[#f7f2eb] text-[#574a40]":""),children:h.label})]}),(0,s.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,s.jsx)(rJ,{surfaceTheme:e,title:"Template",summary:"This sets the scaffold, documents, and default capabilities.",children:(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2 xl:grid-cols-3",children:az.map(a=>{let r=aq[a.value];return(0,s.jsx)(rH,{surfaceTheme:e,selected:t===a.value,title:a.label,description:a.description,icon:(0,s.jsx)("span",{className:"text-[14px] leading-none","aria-hidden":"true",children:r.icon}),onClick:()=>l(a.value),disabled:u},a.value)})})}),(0,s.jsx)(rJ,{surfaceTheme:e,title:"Team preset",summary:"Choose how many permanent agents the workspace should start with.",children:(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:aW.map(t=>(0,s.jsx)(rH,{surfaceTheme:e,selected:a===t.value,title:t.label,description:t.description,icon:(0,s.jsx)(tO.A,{className:"h-4 w-4"}),onClick:()=>o(t.value),disabled:u},t.value))})}),(0,s.jsx)(rJ,{surfaceTheme:e,title:"Model profile",summary:"Favor speed, balance, or quality for the default workspace runs.",children:(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:aB.map(t=>(0,s.jsx)(rH,{surfaceTheme:e,selected:r===t.value,title:t.label,description:t.description,icon:(0,s.jsx)(av.A,{className:"h-4 w-4"}),onClick:()=>c(t.value),disabled:u},t.value))})}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border p-3",m?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#8d8276]":"text-slate-500"),children:"Bootstrap speed"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",m?"text-[#766e64]":"text-slate-400"),children:"Use a preset or tune the bootstrap rules manually."})]}),(0,s.jsx)(J.E,{variant:"muted",children:i})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-3",children:[(0,s.jsx)(rZ,{surfaceTheme:e,active:"standard"===i,title:"Standard",description:"Docs, memory, kickoff",disabled:u,onClick:()=>d("standard")}),(0,s.jsx)(rZ,{surfaceTheme:e,active:"fastest"===i,title:"Fastest",description:"Core files only",disabled:u,onClick:()=>d("fastest")}),(0,s.jsx)(rZ,{surfaceTheme:e,active:"custom"===i,title:"Custom",description:"Manually choose rules",disabled:u,onClick:()=>d("custom")})]})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border p-3",m?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",m?"text-[#8d8276]":"text-slate-500"),children:"Workspace rules"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",m?"text-[#766e64]":"text-slate-400"),children:"Toggle the bootstrap steps that should ship with the workspace."})]}),(0,s.jsxs)(J.E,{variant:"muted",children:[[n.generateStarterDocs,n.generateMemory,n.kickoffMission].filter(Boolean).length,"/3"]})]}),(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,s.jsx)(rY,{surfaceTheme:e,title:"Starter docs",description:"Generate the brief, scaffolding notes, and handoff docs.",checked:n.generateStarterDocs,disabled:u,onToggle:()=>p("generateStarterDocs")}),(0,s.jsx)(rY,{surfaceTheme:e,title:"Memory",description:"Write durable context and decisions into memory files.",checked:n.generateMemory,disabled:u,onToggle:()=>p("generateMemory")}),(0,s.jsx)(rY,{surfaceTheme:e,title:"Kickoff mission",description:"Launch the first mission right after bootstrap.",checked:n.kickoffMission,disabled:u,onToggle:()=>p("kickoffMission")})]})]})]})]})}function rK({surfaceTheme:e,basicDraft:t,basicTeamPreset:a,basicModelProfile:r,basicRules:n,basicPreset:i,resolvedName:l,resolvedTemplate:o,sourceAnalysis:c,workspacePath:d,onStepChange:p}){let u="light"===e,m="clone"===c.kind?ab.A:"website"===c.kind?af.A:aw.A,x=[n.generateStarterDocs,n.generateMemory,n.kickoffMission].filter(Boolean).length;return(0,s.jsxs)("section",{className:(0,N.cn)("rounded-[24px] border p-4 md:p-5",u?"border-[#e4ddd3] 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",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.2em]",u?"text-[#8b7262]":"text-slate-500"),children:"Step 3 \xb7 Review"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",u?"text-[#70685f]":"text-slate-300"),children:"Check the final draft before creating the workspace."})]}),(0,s.jsx)(J.E,{variant:"success",children:"Ready"})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2",children:[(0,s.jsx)(rQ,{surfaceTheme:e,label:"Name",value:l,icon:h.A}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Template",value:aq[o].label,icon:av.A}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Source",value:c.label,icon:m}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Path",value:d,icon:aw.A,mono:!0}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Team",value:aW.find(e=>e.value===a)?.label??a,icon:tO.A}),(0,s.jsx)(rQ,{surfaceTheme:e,label:"Model",value:aB.find(e=>e.value===r)?.label??r,icon:av.A})]}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-4 rounded-[20px] border p-3",u?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",u?"text-[#8d8276]":"text-slate-500"),children:"Launch summary"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",u?"text-[#766e64]":"text-slate-400"),children:"fastest"===i?"Fast path will keep the scaffold lean.":"custom"===i?"Custom bootstrap rules are active.":"Starter docs, memory, and kickoff are enabled."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(J.E,{variant:"muted",children:[x,"/3 rules"]}),(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>p("intake"),className:u?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit intake"}),(0,s.jsx)(v.$,{type:"button",variant:"secondary",size:"sm",onClick:()=>p("shape"),className:u?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit shape"})]})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-2.5",u?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",u?"text-[#8d8276]":"text-slate-500"),children:"Goal"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",u?"text-[#34281f]":"text-slate-200"),children:t.goal.trim()||"No goal provided yet."})]}),(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[18px] border px-3 py-2.5",u?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",u?"text-[#8d8276]":"text-slate-500"),children:"Source kind"}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[13px] leading-6",u?"text-[#34281f]":"text-slate-200"),children:"empty"===c.kind?"Fresh workspace":c.label})]})]})]})]})}function rJ({surfaceTheme:e,title:t,summary:a,children:r}){let n="light"===e;return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8d8276]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",n?"text-[#766e64]":"text-slate-400"),children:a})]}),r]})}function rH({surfaceTheme:e,selected:t,title:a,description:r,icon:n,onClick:i,disabled:l=!1}){let o="light"===e;return(0,s.jsxs)("button",{type:"button",onClick:i,disabled:l,className:(0,N.cn)("group flex h-full min-h-[90px] flex-col justify-between rounded-[18px] border p-3 text-left transition-colors",t?o?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/10 text-white":o?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d7c8ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",l&&"cursor-not-allowed opacity-70"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",t?"border-white/15 bg-white/10 text-white":o?"border-[#ddd3c5] bg-white text-[#5f564b]":"border-white/10 bg-white/[0.04] text-slate-200"),children:n}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] font-medium",children:a}),(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5 text-[11px] leading-4",t?"text-current/80":o?"text-[#766e64]":"text-slate-400"),children:r})]})]}),t?(0,s.jsx)(J.E,{variant:o?"muted":"default",className:o?"bg-white text-[#3d342b]":"",children:"Selected"}):null]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",t?"text-current/70":o?"text-[#8d8276]":"text-slate-500"),children:t?"Active choice":"Select"}),(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-5 items-center justify-center rounded-full border",t?"border-white/15 bg-white/10 text-white":o?"border-[#d9cec2] bg-white text-transparent":"border-white/10 bg-transparent text-transparent"),children:(0,s.jsx)(eG.A,{className:"h-3 w-3"})})]})]})}function rY({surfaceTheme:e,title:t,description:a,checked:r,onToggle:n,disabled:i=!1}){let l="light"===e;return(0,s.jsxs)("button",{type:"button",onClick:n,disabled:i,className:(0,N.cn)("flex w-full items-start gap-3 rounded-[18px] border px-3 py-3 text-left transition-colors",l?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]",i?"cursor-not-allowed opacity-70":l?"hover:border-[#d7c8ba] hover:bg-[#f7f0e6]":"hover:border-white/15 hover:bg-white/[0.05]"),children:[(0,s.jsx)("span",{className:(0,N.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",r?l?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":l?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,s.jsx)(eG.A,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[13px] font-medium",l?"text-[#171410]":"text-white"),children:t}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-[12px] leading-5",l?"text-[#766e64]":"text-slate-400"),children:a})]})]})}function rZ({surfaceTheme:e,active:t,title:a,description:r,disabled:n=!1,onClick:i}){let l="light"===e;return(0,s.jsx)("button",{type:"button",onClick:i,disabled:n,className:(0,N.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",t?l?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":l?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]",n&&"cursor-not-allowed opacity-70"),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(av.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("p",{className:"truncate text-[12px] font-medium",children:a})]}),(0,s.jsx)("p",{className:(0,N.cn)("truncate text-right text-[11px] leading-4",t?"opacity-80":l?"text-[#776f65]":"text-slate-400"),children:r})]})})}function rQ({surfaceTheme:e,label:t,value:a,icon:r,mono:n=!1}){let i="light"===e;return(0,s.jsx)("div",{className:(0,N.cn)("rounded-[16px] border px-3 py-2.5",i?"border-[#e8e0d6] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:(0,N.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",i?"border-[#e0d7cc] bg-[#faf6f1] text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(r,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.16em]",i?"text-[#8d8276]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,N.cn)("truncate text-[12px] font-medium leading-4",n&&"font-mono text-[12px]",i?"text-[#171410]":"text-white"),title:a,children:a})]})]})})}var rX=a(58434),r0=a(16611),r1=a(47936),r2=a(33899),r5=a(99261),r3=a(94837),r4=a(38641);function r8({snapshot:e,surfaceTheme:t,connectionState:a,isCheckingForUpdates:r,updateRunState:l,lastCheckedAt:o,onCheckForUpdates:c,onOpenSetupWizard:p,onOpenUpdateDialog:u}){let[m,h]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[f,w]=(0,i.useState)(!1),[y,j]=(0,i.useState)(!1),k="running"===l,C=(0,eK.X2)(e),S=!!(e.diagnostics.updateAvailable&&e.diagnostics.latestVersion),A=!!(e.diagnostics.version&&!e.diagnostics.latestVersion&&!e.diagnostics.updateError),T=r?"Checking update registry...":S?`Latest v${e.diagnostics.latestVersion}`:e.diagnostics.updateError?"Check failed":A?e.diagnostics.updateInfo?.trim()||"Registry status is still loading.":"Up to date",$=e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||"Not selected",M=function(e){let{diagnostics:t}=e,a="remote"===t.bindMode||t.configuredGatewayUrl?"Remote":"Local",s=t.rpcOk||t.loaded?"Online":"Offline";return`${a} / ${s}`}(e),I=tU(e.diagnostics.transport,a),R=!!(m&&!m.native.ok&&("auth"===m.native.kind||"scope-limited"===m.native.kind)),O=(0,i.useCallback)(async()=>{w(!0),b(null);try{h(await r9())}catch(e){b(e instanceof Error?e.message:"Unable to check Gateway auth status.")}finally{w(!1)}},[]);(0,i.useEffect)(()=>{O()},[O]);let P=async()=>{j(!0),b(null);try{let e=await fetch("/api/settings/gateway",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"repairDeviceAccess"})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Gateway access could not be repaired.")}let t=await e.json();h(t.authStatus)}catch(e){b(e instanceof Error?e.message:"Unable to repair Gateway access.")}finally{j(!1)}};return(0,s.jsxs)("div",{role:"menu","aria-label":"System menu",className:(0,N.cn)("absolute right-0 top-14 z-50 w-[336px] overflow-hidden rounded-[24px] border p-3 shadow-[0_24px_68px_rgba(40,28,20,0.22)] backdrop-blur-2xl","light"===t?"border-[#dfcfc2] bg-[#fffaf3]/96 text-[#2b211c]":"border-white/[0.10] bg-[#08101c]/98 text-slate-100 shadow-[0_28px_80px_rgba(0,0,0,0.48)]"),children:[(0,s.jsxs)("div",{className:(0,N.cn)("rounded-[20px] border p-3.5",nt(t)),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[9px] uppercase tracking-[0.22em]",na(t)),children:"OpenClaw"}),(0,s.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"font-display text-[1rem]",children:ne(e.diagnostics.health)}),(0,s.jsx)(r6,{health:e.diagnostics.health,surfaceTheme:t})]})]}),(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[9px] uppercase tracking-[0.2em]",na(t)),children:"Version"}),(0,s.jsxs)("p",{className:"mt-0.5 font-mono text-[11px]",children:["v",e.diagnostics.version||"unknown"]})]})]}),(0,s.jsx)("div",{className:(0,N.cn)("mt-3 rounded-[18px] border p-3","light"===t?"border-[#eadbcf] bg-[#f9f1e8]/80":"border-white/[0.08] bg-[#101a2a]/92"),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[9px] uppercase tracking-[0.18em]",na(t)),children:"Updates"}),(0,s.jsx)("p",{className:"mt-0.5 text-[13px]",children:T})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"secondary",onClick:()=>void c(),disabled:r||k,className:ns(t),children:[r?(0,s.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(n.A,{className:"h-3 w-3"}),r?"Checking...":"Check"]}),S?(0,s.jsxs)(v.$,{type:"button",size:"sm",onClick:u,disabled:k,className:"rounded-full bg-emerald-600 px-2.5 text-[11px] text-white shadow-[0_12px_24px_rgba(16,185,129,0.24)] hover:bg-emerald-500",children:[(0,s.jsx)(r4.A,{className:"h-3 w-3"}),"Update"]}):null]})]})})]}),(0,s.jsxs)("div",{className:(0,N.cn)("mt-2 rounded-[16px] border px-3 py-2","light"===t?"border-[#e6d7c9] bg-white text-[#6b5546]":"border-white/[0.08] bg-[#0f1826] text-slate-300"),children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em]",children:r?"Checking":"Registry"}),(0,s.jsx)("p",{className:"mt-1 text-[11px] leading-4",children:r?"Refreshing OpenClaw update registry...":e.diagnostics.updateInfo?.trim()||(o?`Last checked ${new Date(o).toLocaleTimeString()}.`:"No registry check run yet.")})]}),(0,s.jsxs)("div",{className:"mt-2.5 grid gap-1.5",children:[(0,s.jsx)(r7,{surfaceTheme:t,icon:(0,s.jsx)(tD.A,{className:"h-3.5 w-3.5"}),label:"Gateway",value:I.statusLabel,detail:`${M} / ${I.gatewayModeLabel}`}),(0,s.jsx)(r7,{surfaceTheme:t,icon:(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"}),label:"Default model",value:$,wrapValue:!0,action:(0,s.jsx)(v.$,{asChild:!0,size:"sm",variant:"secondary",className:ns(t),children:(0,s.jsxs)(tT(),{href:"/settings#models",children:[(0,s.jsx)(sU.A,{className:"h-3 w-3"}),"Models"]})})}),(0,s.jsx)(r7,{surfaceTheme:t,icon:C?(0,s.jsx)(eL.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(W.A,{className:"h-3.5 w-3.5"}),label:"Setup",value:C?"Ready":"Needs setup",action:(0,s.jsx)(v.$,{type:"button",size:"sm",variant:"secondary",onClick:()=>p(C?"system":void 0),className:ns(t),children:"Open"})})]}),R||g?(0,s.jsxs)("div",{className:(0,N.cn)("mt-2.5 rounded-[18px] border p-2.5","light"===t?"border-amber-300/70 bg-amber-50/80 text-amber-950":"border-amber-300/20 bg-amber-300/10 text-amber-100"),children:[(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)(tL.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-[13px] font-medium",children:"Gateway auth needs attention"}),(0,s.jsx)("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-4 opacity-80",children:g||m?.native.issue||"Native Gateway auth is not ready. Open Settings to repair access."})]})]}),(0,s.jsxs)("div",{className:"mt-2.5 flex items-center gap-1.5",children:[(0,s.jsxs)(v.$,{type:"button",size:"sm",variant:"secondary",onClick:()=>void O(),disabled:f||y,className:ns(t),children:[f?(0,s.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):null,"Test"]}),m?.native.kind==="scope-limited"?(0,s.jsxs)(v.$,{type:"button",size:"sm",onClick:()=>void P(),disabled:f||y,className:"rounded-full bg-emerald-600 px-2.5 text-[11px] text-white hover:bg-emerald-500",children:[y?(0,s.jsx)(d.A,{className:"h-3 w-3 animate-spin"}):null,"Repair"]}):null,(0,s.jsx)(v.$,{asChild:!0,size:"sm",variant:"secondary",className:ns(t),children:(0,s.jsx)(tT(),{href:"/settings#gateway",children:"Open settings"})})]})]}):null,(0,s.jsxs)("div",{className:(0,N.cn)("mt-2.5 grid grid-cols-2 gap-1.5 border-t pt-2.5","light"===t?"border-[#e6d7c9]":"border-white/[0.08]"),children:[(0,s.jsx)(v.$,{asChild:!0,variant:"secondary",className:nr(t),children:(0,s.jsxs)(tT(),{href:"/settings",children:[(0,s.jsx)(tP.A,{className:"h-3.5 w-3.5"}),"Control Center"]})}),(0,s.jsx)(v.$,{asChild:!0,variant:"secondary",className:nr(t),children:(0,s.jsxs)(tT(),{href:"/settings#diagnostics",children:[(0,s.jsx)(W.A,{className:"h-3.5 w-3.5"}),"Diagnostics"]})})]})]})}function r6({health:e,surfaceTheme:t}){return(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] uppercase tracking-[0.18em]","healthy"===e?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-400/30 bg-emerald-400/10 text-emerald-200":"degraded"===e?"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-100":"light"===t?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-100"),children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),ne(e)]})}function r7({surfaceTheme:e,icon:t,label:a,value:r,detail:n,action:i,wrapValue:l=!1}){return(0,s.jsxs)("div",{className:(0,N.cn)("flex items-center gap-3 rounded-[20px] border p-3",nt(e)),children:[(0,s.jsx)("span",{className:(0,N.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-full border","light"===e?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-cyan-300/15 bg-cyan-300/10 text-cyan-200"),children:t}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,N.cn)("text-[10px] uppercase tracking-[0.18em]",na(e)),children:a}),(0,s.jsx)("p",{className:(0,N.cn)("mt-1 text-sm font-medium",l?"break-words leading-4":"truncate"),title:r,children:r}),n?(0,s.jsx)("p",{className:(0,N.cn)("mt-0.5",l?"break-words text-[11px] leading-4":"truncate text-xs",na(e)),children:n}):null]}),i?(0,s.jsx)("div",{className:"shrink-0",children:i}):null]})}async function r9(){let e=await fetch("/api/settings/gateway",{method:"GET",cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Unable to check Gateway auth status.")}return(await e.json()).authStatus}function ne(e){switch(e){case"healthy":return"Online";case"degraded":return"Degraded";default:return"Offline"}}function nt(e){return"light"===e?"border-[#e5d7c9] bg-[#fffaf4]/86 shadow-[0_18px_48px_rgba(119,91,70,0.08)]":"border-white/[0.08] bg-[#0d1624]/96"}function na(e){return"light"===e?"text-[#8c7564]":"text-slate-400"}function ns(e){return(0,N.cn)("h-8 rounded-full px-3 text-xs","light"===e?"border-[#dcc9bb] bg-[#fffaf3] text-[#5d493b] hover:bg-[#f3e7dc]":"border-white/10 bg-[#121d2d] text-slate-200 hover:bg-[#182538]")}function nr(e){return(0,N.cn)("h-10 rounded-full text-xs","light"===e?"border-[#dcc9bb] bg-[#fffaf3] text-[#4d3c32] hover:bg-[#f3e7dc]":"border-white/10 bg-[#121d2d] text-slate-200 hover:bg-[#182538]")}function nn(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"}}function ni(e){switch(e){case"healthy":return"bg-emerald-400";case"degraded":return"bg-amber-300";default:return"bg-rose-300"}}function nl({surfaceTheme:e}){return(0,s.jsxs)("div",{className:(0,N.cn)("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:(0,N.cn)("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:(0,N.cn)("text-[10px] tracking-[0.18em]","light"===e?"text-[#8a7261]":"text-slate-500"),children:"AgentOS"})]}),(0,s.jsx)("span",{"aria-hidden":"true",className:(0,N.cn)("h-4 w-px","light"===e?"bg-[#cdb7a8]/80":"bg-white/[0.08]")}),(0,s.jsx)("h2",{className:(0,N.cn)("font-display text-[0.88rem]","light"===e?"text-[#816958]/80":"text-slate-400/75"),children:"Control Plane"})]})}function no({settingsRef:e,isSettingsOpen:t,onToggleTheme:a,onToggleSettings:r,...n}){var i,l,o,c;let{snapshot:d,surfaceTheme:p}=n,{onOpenSetupWizard:u}=n,m=d.diagnostics.health,h="offline"===m,x=function(e){switch(e){case"healthy":return"Online";case"degraded":return"Degraded";default:return"Offline"}}(m),g=tU(d.diagnostics.transport,n.connectionState),b=(l=p,(0,N.cn)("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"===l?"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]")),w=(o=p,(0,N.cn)("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"===o?"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=(c=p,(0,N.cn)("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"===c?"translate-x-7 bg-[#c8946f] text-white":"translate-x-0 bg-cyan-300 text-slate-950"));return(0,s.jsx)("div",{className:"flex w-full items-center px-0 pt-6",children:(0,s.jsxs)("div",{ref:e,className:"pointer-events-auto relative ml-auto",children:[(0,s.jsxs)("div",{className:(0,N.cn)("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"===p?"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:(0,N.cn)("text-[10px] uppercase tracking-[0.3em]","light"===p?"text-[#8a7261]":"text-slate-500"),children:"OPENCLAW"}),(0,s.jsxs)("span",{className:(0,N.cn)("font-mono text-[8px] tracking-[0.04em]","light"===p?"text-[#6f5a4b]/85":"text-slate-300/80"),children:["v",d.diagnostics.version||"unknown"]})]}),h?(0,s.jsxs)(f.P.button,{type:"button",onClick:()=>u(),title:"System is offline. Open the setup wizard.","aria-label":"System is offline. Open the setup wizard.",whileHover:{scale:1.03,y:-1},whileTap:{scale:.98},transition:{type:"spring",stiffness:420,damping:28},className:(0,N.cn)("group relative inline-flex cursor-pointer select-none items-center gap-2 overflow-hidden rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.22em] transition-[background-color,border-color,color,box-shadow,transform] duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/40 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent",nn(m,p),"light"===p?"shadow-[0_10px_24px_rgba(244,63,94,0.12)] hover:border-rose-300 hover:bg-rose-100 hover:text-rose-800":"shadow-[0_10px_24px_rgba(244,63,94,0.18)] hover:border-rose-300/40 hover:bg-rose-300/15 hover:text-rose-100"),children:[(0,s.jsx)(f.P.span,{"aria-hidden":"true",className:(0,N.cn)("pointer-events-none absolute inset-0 rounded-full","light"===p?"bg-[radial-gradient(circle_at_top,rgba(244,63,94,0.18),rgba(244,63,94,0))]":"bg-[radial-gradient(circle_at_top,rgba(251,113,133,0.18),rgba(251,113,133,0))]"),animate:{opacity:[.35,.65,.35],scale:[.98,1.02,.98]},transition:{duration:2.8,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("span",{"aria-hidden":"true",className:(0,N.cn)("relative z-10 h-2 w-2 rounded-full shadow-[0_0_12px_currentColor]",ni(m))}),(0,s.jsxs)("span",{className:"relative z-10 inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{children:x}),(0,s.jsx)("span",{className:(0,N.cn)("rounded-full border px-1.5 py-0.5 text-[7px] uppercase tracking-[0.18em]","light"===p?"border-rose-300/40 bg-rose-100/70 text-rose-800":"border-rose-300/25 bg-rose-300/10 text-rose-100/90"),children:"Setup"}),(0,s.jsx)(r2.A,{className:"h-3 w-3 opacity-80 transition-transform duration-200 group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]})]}):(0,s.jsxs)("span",{className:(0,N.cn)("inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.22em]",nn(m,p)),children:[(0,s.jsx)("span",{"aria-hidden":"true",className:(0,N.cn)("h-2 w-2 rounded-full shadow-[0_0_12px_currentColor]",ni(m))}),x]}),(0,s.jsxs)("span",{className:(0,N.cn)("hidden items-center gap-1.5 rounded-full border px-2 py-1 text-[9px] font-medium uppercase tracking-[0.18em] sm:inline-flex",(i=g.statusTone,"success"===i?"light"===p?"border-emerald-300/80 bg-emerald-50 text-emerald-700":"border-emerald-400/25 bg-emerald-400/10 text-emerald-200":"danger"===i?"light"===p?"border-rose-300/80 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200":"warning"===i?"light"===p?"border-amber-300/80 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200":"light"===p?"border-[#d0bcae] bg-[#efe5dc] text-[#7f6554]":"border-white/12 bg-white/[0.08] text-slate-300")),title:g.recovery||g.lastNativeError||g.statusLabel,children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),g.gatewayModeLabel]}),(0,s.jsx)("button",{type:"button",role:"switch","aria-label":"light"===p?"Switch to dark theme":"Switch to light theme","aria-checked":"light"===p,onClick:a,className:w,children:(0,s.jsx)("span",{className:v,children:"light"===p?(0,s.jsx)(r5.A,{className:"h-3 w-3"}):(0,s.jsx)(r3.A,{className:"h-3 w-3"})})}),(0,s.jsx)("button",{type:"button","aria-label":"Open settings","aria-expanded":t,"aria-haspopup":"menu",onClick:r,className:b,children:(0,s.jsx)(tP.A,{className:"h-3.5 w-3.5"})})]}),t?(0,s.jsx)(r8,{...n}):null]})})}let nc=(0,r0.default)(()=>Promise.all([a.e(5751),a.e(9708),a.e(2842),a.e(1994)]).then(a.bind(a,81994)).then(e=>e.MissionCanvas),{loadableGenerated:{webpack:()=>[81994]},ssr:!1,loading:()=>(0,s.jsx)("div",{className:"h-full w-full"})}),nd="mission-control-surface-theme",np="mission-control-hidden-runtime-ids",nu="mission-control-hidden-task-keys",nm="mission-control-locked-task-keys",nh=[4e3,8e3,15e3,3e4,45e3,6e4],nx=void 0===globalThis.window?i.useEffect:i.useLayoutEffect,ng={phase:"idle",previousModelId:null,nextModelId:null,message:null};function nb(e,t){let a=e.trim();return a.length<=t?a:`${a.slice(0,t).trimEnd()}
|
|
168
|
-
|
|
169
|
-
[truncated for task continuation]`}function nf({initialSnapshot:e,mode:t="mission"}){let{snapshot:a,connectionState:d,refresh:p,refreshSnapshot:u,setSnapshot:m}=(0,r1.v)(e),[h,x]=(0,i.useState)(e.workspaces[0]?.id??null),[g,b]=(0,i.useState)(e.workspaces[0]?.id??null),[f,w]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[C,A]=(0,i.useState)(null),[T,$]=(0,i.useState)(!1),[M,I]=(0,i.useState)(0),[R,O]=(0,i.useState)("overview"),[P,_]=(0,i.useState)(null),[D,E]=(0,i.useState)(null),[L,U]=(0,i.useState)([]),[F,z]=(0,i.useState)(null),[W,B]=(0,i.useState)([]),[G,q]=(0,i.useState)([]),[V,J]=(0,i.useState)([]),[H,Y]=(0,i.useState)(null),[Z,X]=(0,i.useState)(null),[ee,et]=(0,i.useState)(null),[ea,es]=(0,i.useState)("idle"),[er,en]=(0,i.useState)(null),[ei,el]=(0,i.useState)(null),[eo,ec]=(0,i.useState)({}),[ed,ep]=(0,i.useState)(!1),eu=(0,i.useRef)(new Map),[em,eh]=(0,i.useState)(null),[ex,eg]=(0,i.useState)(!1),[eb,ef]=(0,i.useState)(!1),[ew,ev]=(0,i.useState)(!1),[ey,ej]=(0,i.useState)(!1),[ek,eN]=(0,i.useState)(null),[eC,eS]=(0,i.useState)("idle"),[eA,eT]=(0,i.useState)(null),[e$,eM]=(0,i.useState)(null),[eI,eR]=(0,i.useState)("idle"),[eO,eP]=(0,i.useState)(null),[e_,eD]=(0,i.useState)(null),[eE,eL]=(0,i.useState)(null),[eU,eF]=(0,i.useState)(""),[eW,eG]=(0,i.useState)(""),[eq,eV]=(0,i.useState)("idle"),[eY,eZ]=(0,i.useState)(null),eQ=(0,i.useRef)(null),[eX,e0]=(0,i.useState)(()=>(0,ez.QO)(e)),[e1,e2]=(0,i.useState)(()=>(0,ez.hZ)(e)),[e5,e4]=(0,i.useState)(()=>e.diagnostics.openClawBinarySelection),[e8,e6]=(0,i.useState)(!1),[e7,e9]=(0,i.useState)(!1),[te,tt]=(0,i.useState)(!1),[ta,ts]=(0,i.useState)(!1),[tr,tn]=(0,i.useState)("idle"),[ti,tl]=(0,i.useState)(null),[to,tc]=(0,i.useState)(null),[td,tp]=(0,i.useState)(""),[tu,tm]=(0,i.useState)(null),[th,tx]=(0,i.useState)("idle"),[tg,tb]=(0,i.useState)(null),[tf,tv]=(0,i.useState)(null),[ty,tj]=(0,i.useState)(null),[tk,tC]=(0,i.useState)(""),[tS,tA]=(0,i.useState)(null),[tT,t$]=(0,i.useState)(null),[tM,tI]=(0,i.useState)("system"),[tR,tO]=(0,i.useState)(""),[tP,t_]=(0,i.useState)([]),[tD,tE]=(0,i.useState)("idle"),[tL,tU]=(0,i.useState)(null),[tF,tz]=(0,i.useState)(null),[tW,tB]=(0,i.useState)(null),[tG,tV]=(0,i.useState)(""),[tK,tJ]=(0,i.useState)(null),[tH,tY]=(0,i.useState)(null),[tZ,tQ]=(0,i.useState)(ng),[tX,t0]=(0,i.useState)(!1),[t1,t2]=(0,i.useState)(!1),[t5,t3]=(0,i.useState)(!1),[t4,t8]=(0,i.useState)(!1),[t6,t7]=(0,i.useState)(!1),[t9,ae]=(0,i.useState)(null),[aa,as]=(0,i.useState)(null),[ar,an]=(0,i.useState)("dark"),[ai,al]=(0,i.useState)(!1),[ac,ad]=(0,i.useState)("basic"),[ap,au]=(0,i.useState)(null),[ax,ag]=(0,i.useState)(!1),[ab,af]=(0,i.useState)(null),[aw,av]=(0,i.useState)(!1),[ay,aj]=(0,i.useState)(null),[ak,aN]=(0,i.useState)(null),[aC,aS]=(0,i.useState)(null),[aA,aT]=(0,i.useState)(null),a$=(0,i.useRef)(null),aM=(0,i.useRef)(null),aI=(0,i.useRef)(null),aR=(0,i.useRef)(null),aO=(0,i.useRef)(0),aP=(0,i.useRef)(null),a_=eb&&"chat"===R?g:null,aD=(0,i.useMemo)(()=>{let e=(0,ez.Uh)(a,L);return(0,K.wg)(e,eo)},[a,L,eo]),aE=(0,i.useMemo)(()=>ei?aD.tasks.find(e=>e.id===ei.taskId||(0,K.HR)(e)===ei.taskKey)??ei.fallbackTask:null,[ei,aD.tasks]),aL=(0,i.useMemo)(()=>Array.isArray(W)?W:[],[W]),aU=(0,i.useMemo)(()=>Array.isArray(G)?G:[],[G]),aF=(0,i.useMemo)(()=>Array.isArray(V)?V:[],[V]),az=(0,i.useCallback)((e,t="overview",a=null)=>{b(e),O(t),w(a)},[]),aW=(0,i.useCallback)((e,t={})=>{t.markPending&&e&&aS(e),y(null),A(null),x(e),az(e)},[az]),aB=(0,i.useRef)(null),aG=(0,i.useRef)(!1),aq=(0,i.useRef)(!1),aV=a.runtimes.filter(e=>("running"===e.status||"queued"===e.status)&&!(0,ez.MG)(e)).length,aK=!t4&&(0,eK.h6)(a),aJ=!t4&&(0,eK.X2)(a),aH=eH(tM,aK||"success"===th),aY=(0,ez.Id)(a),aZ=(0,ez.R)(a),aQ=(0,ez.iy)(a),aX=aV>0||L.length>0,a0=(0,ez.EE)(a,{hasSeenMissionReady:t6,modelSwitchSucceeded:"success"===tZ.phase}),a1=aK&&aJ&&!aY,a2=!aX&&(!tX||a1)&&(!aJ||a1)&&!a0||t5||t1,a5=aD.tasks.filter(e=>!h||e.workspaceId===h).filter(e=>(0,ez.Zc)(e,aL,aU,aF)).length,a3=(0,i.useCallback)(e=>{let t=aD.tasks.filter(t=>t.workspaceId===e).filter(e=>!aF.includes(e.key));if(0===t.length)return;let a=t.every(e=>(0,ez.Zc)(e,aL,aU,aF)),s=new Set(t.map(e=>e.key)),r=new Set(t.flatMap(e=>e.runtimeIds));if(a){q(e=>e.filter(e=>!s.has(e))),B(e=>e.filter(e=>!r.has(e)));return}q(e=>Array.from(new Set([...e,...s]))),B(e=>Array.from(new Set([...e,...r])))},[aD.tasks,aL,aU,aF]),a4=(0,i.useCallback)(e=>{let t=aD.agents.find(t=>t.id===e);t&&(y(t=>t===e?null:e),x(t.workspaceId),az(e))},[az,aD.agents]),a8=(0,i.useCallback)((e,t)=>{let a=aD.agents.find(t=>t.id===e);a&&(x(a.workspaceId),ef(!0),az(a.id,"overview",t))},[az,aD.agents]),a6=(0,i.useCallback)((e,t)=>{let a=aD.agents.find(t=>t.id===e);a&&(x(a.workspaceId),az(a.id),X({requestId:`capabilities:${e}:${t}:${Date.now()}`,agentId:e,focus:t}))},[az,aD.agents]),a7=(0,i.useCallback)(e=>{let t=aD.agents.find(t=>t.id===e);t&&(x(t.workspaceId),az(t.id),aN({requestId:`model:${e}:${Date.now()}`,agentId:e}))},[az,aD.agents]),a9=(0,i.useCallback)(e=>{eh(e),eQ.current&&clearTimeout(eQ.current),eQ.current=setTimeout(()=>{eQ.current=null,eh(null)},2400)},[]),se=(0,i.useCallback)(e=>{e||aN(null)},[]),st=(0,i.useCallback)(e=>{e||X(null)},[]),sa=(0,i.useCallback)(e=>{if(!v)return;let t=aD.agents.find(t=>t.id===e);t&&(v!==e||h!==t.workspaceId||g!==e)&&(y(e),x(t.workspaceId),az(e))},[h,v,az,g,aD.agents]),ss=(0,i.useCallback)(()=>{aG.current=!0},[]),sr=(0,i.useCallback)(e=>{if(e){aq.current=!1,$(!0);return}if(aG.current){aq.current=!0;return}aq.current=!1,$(!1)},[]),sn=(0,i.useCallback)(()=>{y(null),az(h??aD.workspaces[0]?.id??null)},[h,az,aD.workspaces]);(0,i.useEffect)(()=>{let e=()=>{!aG.current||(aG.current=!1,aq.current&&(aq.current=!1,$(!1),I(e=>e+1)))};return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[]),(0,i.useEffect)(()=>()=>{aO.current+=1,eQ.current&&(clearTimeout(eQ.current),eQ.current=null)},[]);let si=(0,i.useCallback)((e="basic")=>{au(null),ad(e),al(!0)},[]),sl=(0,i.useCallback)(e=>{au(e),ad("advanced"),al(!0)},[]),so=(0,i.useCallback)(e=>{al(e),e||(au(null),ad("basic"))},[]),sc=(0,i.useCallback)(e=>{e&&aW(e),ag(!0)},[aW]),sd=(0,i.useCallback)(e=>{aW(e),af(e)},[aW]),sp=(0,i.useCallback)(e=>{e||af(null)},[]);(0,i.useEffect)(()=>{if(h){if(a.workspaces.some(e=>e.id===h)){aC===h&&aS(null);return}aC===h||(0,ez.DK)(a)||x(a.workspaces[0]?.id??null)}},[h,aC,a]),(0,i.useEffect)(()=>{if(0===L.length)return;let e=L.map(e=>({entry:e,replacement:(0,ez.oc)(a.tasks,e)})).filter(e=>!!e.replacement);if(0===e.length)return;let t=new Map(e.map(({entry:e,replacement:t})=>[e.requestId,t]));U(e=>e.filter(e=>!t.has(e.requestId)));let s=L.find(e=>e.task.id===g),r=s?t.get(s.requestId)??null:null;r&&(b(r.id),r.workspaceId&&x(r.workspaceId))},[L,g,a.tasks]),(0,i.useEffect)(()=>{if(g){if(aD.workspaces.some(e=>e.id===g)||aD.agents.some(e=>e.id===g)||aD.tasks.some(e=>e.id===g)||aD.runtimes.some(e=>e.id===g)||aD.models.some(e=>e.id===g)){aC===g&&aS(null);return}aC!==g&&az(h||aD.workspaces[0]?.id||null)}},[aD,g,h,aC,az]),nx(()=>{let e=a.diagnostics.workspaceRoot;if(aA===e||(0,ez.DK)(a))return;let t=(0,ez.cY)(e),s=globalThis.localStorage?.getItem(t)??null,r=(0,ez.mr)(a.workspaces.map(e=>e.id),s,h);r!==h&&(x(r),b(r??null)),aT(e)},[h,aA,a.diagnostics.loaded,a.diagnostics.rpcOk,a.diagnostics.workspaceRoot,a.mode,a.workspaces]),(0,i.useEffect)(()=>{let e=a.diagnostics.workspaceRoot;if(aA!==e)return;let t=(0,ez.cY)(e),s=globalThis.localStorage;void 0!==s&&s.setItem(t,(0,ez.SW)(h))},[h,aA,a.diagnostics.workspaceRoot]),(0,i.useEffect)(()=>{let e=aD.tasks.find(e=>e.id===g),t=e&&(0,ez.Zc)(e,aL,aU,aF);if(g){if(v&&!T){g!==v&&e?.primaryAgentId!==v&&az(v);return}(aL.includes(g)||t)&&az(h||aD.workspaces[0]?.id||null)}},[g,v,T,aL,aU,aF,h,aD.workspaces,aD.tasks,az]),(0,i.useEffect)(()=>{!v||aD.agents.some(e=>e.id===v)||y(null)},[v,aD.agents]),(0,i.useEffect)(()=>{let e=globalThis.localStorage?.getItem(nd),t=globalThis.localStorage?.getItem(np),a=globalThis.localStorage?.getItem(nu),s=globalThis.localStorage?.getItem(nm),r=globalThis.localStorage?.getItem(K.hy);if(("dark"===e||"light"===e)&&an(e),t)try{let e=JSON.parse(t);Array.isArray(e)&&B(e.filter(e=>"string"==typeof e))}catch{}if(a)try{let e=JSON.parse(a);Array.isArray(e)&&q(e.filter(e=>"string"==typeof e))}catch{}if(s)try{let e=JSON.parse(s);Array.isArray(e)&&J(e.filter(e=>"string"==typeof e))}catch{}ec((0,K.Kf)(r??null)),ep(!0)},[]),(0,i.useEffect)(()=>{globalThis.localStorage?.setItem(nd,ar)},[ar]),(0,i.useEffect)(()=>{globalThis.localStorage?.setItem(np,JSON.stringify(W))},[W]),(0,i.useEffect)(()=>{globalThis.localStorage?.setItem(nu,JSON.stringify(G))},[G]),(0,i.useEffect)(()=>{globalThis.localStorage?.setItem(nm,JSON.stringify(V))},[V]),(0,i.useEffect)(()=>{ed&&globalThis.localStorage?.setItem(K.hy,JSON.stringify(eo))},[ed,eo]),(0,i.useEffect)(()=>{if(!D)return;let e=a.tasks.find(e=>e.dispatchId===D);e&&(az(e.id,"overview"),ef(!0),E(null))},[D,a.tasks,az]),(0,i.useEffect)(()=>{U(e=>e.filter(e=>{let t="string"==typeof e.task.metadata.dispatchSubmittedAt?Date.parse(e.task.metadata.dispatchSubmittedAt):e.task.updatedAt??NaN,s=!Number.isNaN(t)&&Date.now()-t>18e5;if(!e.dispatchId)return!s;let r=a.tasks.find(t=>t.dispatchId===e.dispatchId);return r?"running"===r.status||"queued"===r.status:!s}))},[a.tasks]),(0,i.useEffect)(()=>{ew||e8||e7||(e0((0,ez.QO)(a)),e2((0,ez.hZ)(a)))},[a,ew,e8,e7]),(0,i.useEffect)(()=>{ew||te||e4(e=>{var t;return(t=a.diagnostics.openClawBinarySelection,e.mode===t.mode&&e.path===t.path&&e.resolvedPath===t.resolvedPath&&e.label===t.label&&e.detail===t.detail)?e:a.diagnostics.openClawBinarySelection})},[ew,te,a.diagnostics.openClawBinarySelection]),(0,i.useEffect)(()=>{let e=e3(a)||"";e&&(tR.trim()||aM.current===e||(aM.current=e,tO(e)))},[a,tR]),(0,i.useEffect)(()=>{if("fallback"!==a.mode||a.diagnostics.installed)return;let e=`${a.mode}:${a.diagnostics.installed?"installed":"missing"}:${a.diagnostics.issues.join("|")}`;a$.current!==e&&(a$.current=e,u({force:!0}).catch(()=>{}))},[u,a.diagnostics.installed,a.diagnostics.issues,a.mode]),(0,i.useEffect)(()=>{"models"!==tM||aK||"success"===th?("success"===th||aK)&&tI("models"):tI("system")},[aK,tD,th,tM]),(0,i.useEffect)(()=>{if(tX)return void t3(!1);if("success"===tZ.phase){t7(!0),tI(aK?"models":"system"),t3(aK);return}t3(!1)},[tX,aK,tZ.phase]);let su=()=>{"running"!==tr&&(tn("idle"),tl(null),tc(null),tp(""),tm(null))},sm=()=>{tx("idle"),tb(null),tv(null),tj(null),tC(""),tA(null),t$(null),tE("idle"),tU(null),tz(null),tB(null),tJ(null),tY(null),tV(""),t_([]),tO(""),tQ(ng),t3(!1),t7(!1),eV("idle"),eZ(null),aM.current=null},sh=()=>{sm(),t8(!0),tI("system"),t0(!1),t2(!0)},sx=e=>{tp(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},sg=e=>{tC(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},sb=e=>{tV(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},sf=e=>{eF(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},sw=(0,i.useCallback)(e=>{let t=e3(e);t&&(aM.current=t,tO(e=>e.trim()?e:t))},[]),sv=(0,i.useCallback)(async e=>{let t=e??null;try{t=await u({force:!0})}catch{}return t&&(m(t),sw(t)),t},[sw,u,m]),sy=(0,i.useCallback)(async()=>{if(!ee||"running"===ea)return;let e="string"==typeof ee.metadata.optimisticRequestId?ee.metadata.optimisticRequestId:null,t=e?L.find(t=>t.requestId===e):L.find(e=>e.task.id===ee.id),a="string"==typeof ee.dispatchId?ee.dispatchId:t?.dispatchId??null;if(e&&!a){eu.current.get(e)?.abort(),eu.current.delete(e),U(t=>t.map(t=>t.requestId===e?{...t,task:(0,ez.GU)(t.task,{status:"cancelled",subtitle:"Mission submission cancelled before dispatch.",bootstrapStage:"cancelled",feedEvent:{id:`${t.task.id}:cancelled:${Date.now()}`,kind:"warning",timestamp:new Date().toISOString(),title:"Dispatch cancelled",detail:"Mission submission cancelled before dispatch.",isError:!1}})}:t)),j.o.success("Mission submission cancelled.",{description:ee.title}),et(null),es("idle"),en(null);return}es("running"),en(null);try{let e=await fetch(`/api/tasks/${encodeURIComponent(ee.id)}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Aborted from AgentOS.",dispatchId:a})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||t?.message||t?.summary||"Unable to abort task.");j.o.success("Task abort requested.",{description:ee.title}),et(null),es("idle"),await p()}catch(t){let e=t instanceof Error?t.message:"Unknown abort error.";es("error"),en(e),j.o.error("Task abort failed.",{description:e})}},[L,p,ee,ea]),sj=e=>{e&&t_(e)};(0,i.useEffect)(()=>{if(!ew)return;let e=e=>{aB.current?.contains(e.target)||ev(!1)},t=e=>{"Escape"===e.key&&ev(!1)};return window.addEventListener("pointerdown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",t)}},[ew]);let sk=async()=>{if("running"===tr)return void ts(!0);let e=e=>{aP.current=j.o.loading("Updating OpenClaw...",{id:aP.current??void 0,description:e,duration:1/0,action:{label:"View",onClick:()=>ts(!0)}})},t=(e,t)=>{let a={id:aP.current??void 0,description:t,duration:e?6e3:1e4,action:{label:"View details",onClick:()=>ts(!0)}};e?j.o.success("OpenClaw updated.",a):j.o.error("OpenClaw update failed.",a),aP.current=null},a=!1,s=e=>{if(sx(`
|
|
170
|
-
> ${e.message}
|
|
171
|
-
`),a)return;let t=e.stdout.trimEnd(),s=e.stderr.trimEnd();t&&sx(`
|
|
172
|
-
[stdout]
|
|
173
|
-
${t}
|
|
174
|
-
`),s&&sx(`
|
|
175
|
-
[stderr]
|
|
176
|
-
${s}
|
|
177
|
-
`)};ts(!0),tn("running"),tl("Starting OpenClaw update..."),tc(null),tp(""),tm(null),e("Starting OpenClaw update...");try{let r=await fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmed:!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||"OpenClaw update request failed.")}if(!r.body)throw Error("OpenClaw update did not return a readable stream.");let n=r.body.getReader(),i=new TextDecoder,l="",o=!1;for(;;){let{value:r,done:c}=await n.read();if(c)break;let d=(l+=i.decode(r,{stream:!0})).indexOf("\n");for(;d>=0;){let r=l.slice(0,d).trim();if(l=l.slice(d+1),r){let n=JSON.parse(r);"status"===n.type?(tl(n.message),sx(`
|
|
178
|
-
> ${n.message}
|
|
179
|
-
`),e(n.message)):"log"===n.type?(a=!0,sx(n.text)):(o=!0,s(n),tl(null),tc(n.message),tn(n.ok?"success":"error"),tm(n.manualCommand??null),n.snapshot&&m(n.snapshot),n.ok?t(!0,n.message):t(!1,n.message))}d=l.indexOf("\n")}}let c=l.trim();if(c){let e=JSON.parse(c);"done"===e.type&&(o=!0,s(e),tl(null),tc(e.message),tn(e.ok?"success":"error"),tm(e.manualCommand??null),e.snapshot&&m(e.snapshot),t(e.ok,e.message))}if(!o)throw Error("OpenClaw update stream ended unexpectedly.")}catch(e){tn("error"),tl(null),tc(e instanceof Error?e.message:"OpenClaw update failed."),t(!1,e instanceof Error?e.message:"Unknown update error.")}},sN=async()=>{t0(!1),sm(),tI("system"),tx("running"),tb("detecting"),tv("Checking local OpenClaw status..."),tj(null),tA(null),t$(null),tC("");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?(tb(t.phase),tv(t.message),sg(`
|
|
180
|
-
> ${t.message}
|
|
181
|
-
`)):"log"===t.type?sg(t.text):(r=!0,tb(t.phase),tj(t.message),tA(t.manualCommand??null),t$(t.docsUrl??null),t.ok?(tv("Refreshing model status..."),await sv(t.snapshot??null),t8(!1)):(tv(null),t.snapshot&&m(t.snapshot)),tv(null),tx(t.ok?"success":"error"),t.ok?j.o.success("System setup ready.",{description:t.message}):j.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,tb(e.phase),tj(e.message),tA(e.manualCommand??null),t$(e.docsUrl??null),e.ok?(tv("Refreshing model status..."),await sv(e.snapshot??null),t8(!1)):(tv(null),e.snapshot&&m(e.snapshot)),tv(null),tx(e.ok?"success":"error"))}if(!r)throw Error("OpenClaw onboarding stream ended unexpectedly.")}catch(e){tx("error"),tv(null),tj(e instanceof Error?e.message:"OpenClaw onboarding failed."),j.o.error("OpenClaw onboarding failed.",{description:e instanceof Error?e.message:"Unknown onboarding error."})}},sC=async(e,t={})=>{let a=t.timeoutMs?new AbortController:null,s=t.timeoutMs?globalThis.setTimeout(()=>a?.abort(),t.timeoutMs):null;try{let s=await fetch("/api/models/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"status",provider:e,includeSnapshot:t.includeSnapshot}),signal:a?.signal}),r=await s.json().catch(()=>null);if(!s.ok||!r)throw Error(r?.error||r?.message||"Provider status could not be loaded.");return r}finally{s&&globalThis.clearTimeout(s)}},sS=(e,t,a)=>{let s=(0,eJ.W2)(e);aO.current+=1,tI("models"),t2(!0),t0(!1),tU("ready"),tz("Refreshing OpenClaw model status..."),tJ(null),tY(null),a?(m(a),sw(a)):sv(null),tz(null),tE("success"),tB(`${s.shortLabel} is connected. You can discover or add models now.`),sb(`
|
|
182
|
-
> ${s.shortLabel} connected. AgentOS refreshed OpenClaw model status.
|
|
183
|
-
`),j.o.success(`${s.shortLabel} connected.`,{description:t||"AgentOS refreshed OpenClaw model status."})},sA=async e=>{let t=e.trim();if(!t)return!1;let a=aR.current;if(a?.command===t&&Date.now()-a.openedAt<12e4)return!1;try{let e=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:t})}),a=await e.json().catch(()=>null);if(!e.ok||a?.error)throw Error(a?.error||"Unable to open Terminal.");return aR.current={command:t,openedAt:Date.now()},j.o.success("Terminal opened.",{description:"Finish provider auth there, then refresh models."}),!0}catch(e){return j.o.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command."}),!1}},sT=async(e,t={})=>{let s=(0,ez.YI)(e.intent),r=a.diagnostics.modelReadiness.resolvedDefaultModel||a.diagnostics.modelReadiness.defaultModel||null,n=t=>{"set-default"===e.intent&&(aI.current=j.o.loading("Setting default model...",{id:aI.current??void 0,description:t,duration:1/0}))},i=(t,a,s)=>{if("set-default"!==e.intent)return!1;let r={id:aI.current??void 0,description:s,duration:"message"===t?1/0:6e3};return"success"===t?j.o.success(a,r):"message"===t?j.o.message(a,r):j.o.error(a,r),aI.current=null,!0},l=!1,o=a=>{let s=t.verifyProvider??("login-provider"===e.intent?(0,eJ.d4)(e.provider):null);t.autoOpenTerminal&&!l&&"done"===a.type&&"authenticating"===a.phase&&a.manualCommand&&(l=!0,sA(a.manualCommand).finally(()=>{s&&(e=>{let t=(0,eJ.W2)(e),a=aO.current+1;for(let[s,r]of(aO.current=a,nh.entries()))globalThis.setTimeout(()=>{aO.current===a&&(async()=>{try{let r=await sC(e);if(aO.current!==a)return;if(r.connection.connected){aO.current+=1,sS(e,r.connection.detail,r.snapshot);return}s===nh.length-1&&(tz(null),tB(`Still waiting for ${t.shortLabel} auth. Finish the browser sign-in, then refresh models.`))}catch{s===nh.length-1&&tz(null)}})()},r)})(s)}))};t.forceOpen&&t2(!0),t0(!1),tI("models"),tE("running"),tU((0,ez.oA)(e.intent)),tz(s.statusMessage),tB(null),tJ(null),tY(null),tV(""),tQ("set-default"===e.intent?{phase:"saving",previousModelId:r,nextModelId:e.modelId,message:s.statusMessage}:ng),n(s.statusMessage);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(),l=new TextDecoder,c="",d=!1;for(;;){let{value:t,done:p}=await a.read();if(p)break;let u=(c+=l.decode(t,{stream:!0})).indexOf("\n");for(;u>=0;){let t=c.slice(0,u).trim();if(c=c.slice(u+1),t){let a=JSON.parse(t);"status"===a.type?(tU(a.phase),tz(a.message),sb(`
|
|
184
|
-
> ${a.message}
|
|
185
|
-
`),"set-default"===e.intent&&(n(a.message),tQ({phase:"saving",previousModelId:r,nextModelId:e.modelId,message:a.message}))):"log"===a.type?sb(a.text):(d=!0,tU(a.phase),tz(null),tB(a.message),tJ(a.manualCommand??null),tY(a.docsUrl??null),tE(a.ok?"success":"error"),o(a),sj(a.discoveredModels),"set-default"===e.intent&&tQ({phase:a.ok?"success":"error",previousModelId:r,nextModelId:e.modelId,message:a.message}),a.snapshot&&m(a.snapshot),a.ok?(i("success",s.successTitle,a.message)||j.o.success(s.successTitle,{description:a.message}),"set-default"===e.intent&&t3(!0)):"authenticating"===a.phase&&a.manualCommand?i("message","Continue in terminal.",a.message)||j.o.message("Continue in terminal.",{description:a.message}):i("error",s.errorTitle,a.message)||j.o.error(s.errorTitle,{description:a.message}))}u=c.indexOf("\n")}}let p=c.trim();if(p){let t=JSON.parse(p);"done"===t.type&&(d=!0,tU(t.phase),tz(null),tB(t.message),tJ(t.manualCommand??null),tY(t.docsUrl??null),tE(t.ok?"success":"error"),o(t),sj(t.discoveredModels),"set-default"===e.intent&&tQ({phase:t.ok?"success":"error",previousModelId:r,nextModelId:e.modelId,message:t.message}),t.snapshot&&m(t.snapshot),t.ok?i("success",s.successTitle,t.message):"authenticating"===t.phase&&t.manualCommand?i("message","Continue in terminal.",t.message):i("error",s.errorTitle,t.message),t.ok&&"set-default"===e.intent&&t3(!0))}if(!d)throw Error("Model onboarding stream ended unexpectedly.")}catch(a){"set-default"===e.intent&&tQ({phase:"error",previousModelId:r,nextModelId:e.modelId,message:a instanceof Error?a.message:"Default model save failed."});let t=a instanceof Error?a.message:"Unknown model onboarding error.";tE("error"),tz(null),tB(a instanceof Error?a.message:"Model onboarding failed."),i("error",s.errorTitle,t)||j.o.error(s.errorTitle,{description:t})}},s$=async()=>{await sT({intent:"refresh"})},sM=async()=>{await sT({intent:"discover"})},sI=async(e,t={})=>{let s=(0,eJ.d4)(e);if(!s)return void j.o.error("Unknown model provider.",{description:"AgentOS could not match this auth request to a supported provider."});t2(!0);let r=a.diagnostics.modelReadiness.authProviders.find(e=>e.provider===s);if(r?.connected)return void sS(s,r.detail,a);try{let e=await sC(s,{timeoutMs:2500});if(e.connection.connected)return void sS(s,e.connection.detail,e.snapshot)}catch{}await sT({intent:"login-provider",provider:s},{forceOpen:!0,verifyProvider:s,...t})},sR=async e=>{let t=e||tR,s=a.diagnostics.modelReadiness.resolvedDefaultModel||a.diagnostics.modelReadiness.defaultModel||null;!t||s&&t.trim()===s.trim()||await sT({intent:"set-default",modelId:t})},sO=(0,i.useCallback)(()=>{t2(!1),t3(!1),t0(!0),eV("idle"),eZ(null)},[]),sP=(0,i.useCallback)(async()=>{if("running"===eq)return null;let e=tR.trim()||(0,rX.nd)(a,h)||null;if(!e)return j.o.error("Choose a model first.",{description:"OpenClaw needs a usable default model before it can create the first workspace."}),null;eV("running"),eZ(rb(rg({sourceMode:"empty",agentCount:1,kickoffMission:!0})));try{let t=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"AgentOS Workspace",brief:"First workspace created from the AgentOS launchpad.",modelId:e,sourceMode:"empty",template:"software",teamPreset:"solo",modelProfile:"balanced",rules:{workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0},stream:!0})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"OpenClaw could not create the workspace.")}let a=null,s=null;if(await (0,sK.z)(t,async e=>{"progress"===e.type?eZ(e.progress):(e.progress&&eZ(e.progress),e.ok?a=e.result:s=e.error)}),s||!a)throw Error(s||"OpenClaw could not create the workspace.");let r=a;eV("success");let n=await u({force:!0}).catch(()=>null),i=n?.workspaces.some(e=>e.id===r.workspaceId)?r.workspaceId:n?.workspaces[0]?.id??r.workspaceId;return aW(i,{markPending:!0}),n?m(n):await p().catch(()=>{}),sO(),j.o.success("Workspace created.",{description:`${r.agentIds.length} agent${1===r.agentIds.length?"":"s"} created at ${r.workspacePath}`}),r.warnings?.length&&j.o.message("Workspace created with a sync warning.",{description:r.warnings[0]}),r.kickoffError&&j.o.message("Workspace created, but kickoff needs attention.",{description:r.kickoffError}),r}catch(t){eV("error");let e=t instanceof Error?t.message:"Unknown workspace error.";return j.o.error("Workspace creation failed.",{description:e}),null}},[sO,eq,aW,p,u,h,tR,a,m]),s_=e=>{let t=eH(e??(aK?"models":"system"),aK);ev(!1),tI(t),t0(!1),t3(void 0===e&&a0),t2(!0)},sD=()=>{if(t2(!1),t3(!1),t0(!0),"settings"===t){window.location.hash="gateway";return}ev(!0)},sE=(0,i.useCallback)(()=>{if(!(0,ez.Id)(a))return void sP();let e=(h&&a.workspaces.some(e=>e.id===h)?h:a.workspaces[0]?.id)??null;e&&(aS(null),aW(e)),sO()},[h,sO,aW,sP,a]),sL=async e=>{ae(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.");m(a.snapshot),j.o.success("Gateway updated.",{description:a.message||"Gateway state changed."})}catch(e){j.o.error("Gateway action failed.",{description:e instanceof Error?e.message:"Unknown gateway control error."})}finally{ae(null)}},sU=e=>{aj((0,eJ.d4)(e)),av(!0)},sF=async()=>{ej(!0);try{let e=await u({force:!0}),t=Date.now(),a=e.diagnostics.updateInfo?.trim(),s=!!e.diagnostics.version&&!e.diagnostics.latestVersion&&!e.diagnostics.updateError;if(as(t),!e.diagnostics.installed)return void j.o.message("OpenClaw is unavailable.",{description:e.diagnostics.issues[0]||"AgentOS is running in fallback mode."});if(e.diagnostics.updateAvailable)return void j.o.message("Update available.",{description:a||`v${e.diagnostics.latestVersion} is available. Current version: v${e.diagnostics.version||"unknown"}.`});if(s)return void j.o.message("Update registry is still loading.",{description:a||`Running v${e.diagnostics.version||"unknown"}. OpenClaw has not reported a latest release yet.`});if(e.diagnostics.latestVersion&&!e.diagnostics.version)return void j.o.message("Update status refreshed.",{description:a||`Latest available version: v${e.diagnostics.latestVersion}.`});if(e.diagnostics.updateError)return void j.o.error("Update check could not reach the registry.",{description:a||e.diagnostics.updateError});j.o.success("OpenClaw is up to date.",{description:a||`Current version: v${e.diagnostics.version||"unknown"}. No newer release was reported.`})}catch(e){j.o.error("Update check failed.",{description:e instanceof Error?e.message:"Unable to refresh OpenClaw status."})}finally{ej(!1)}},sz=async e=>{e6(!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();m(a.snapshot),e0((0,ez.QO)(a.snapshot)),j.o.success("Gateway updated.",{description:e?.trim()?`AgentOS now targets ${a.snapshot.diagnostics.configuredGatewayUrl||a.snapshot.diagnostics.gatewayUrl}.`:"AgentOS reverted to the local default gateway."})}catch(e){j.o.error("Gateway update failed.",{description:e instanceof Error?e.message:"Unable to update the OpenClaw gateway."})}finally{e6(!1)}},sW=async e=>{e9(!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();m(a.snapshot),e2((0,ez.hZ)(a.snapshot)),j.o.success("Workspace root updated.",{description:e?.trim()?`New workspaces will default to ${(0,k.$7)(a.snapshot.diagnostics.workspaceRoot)}. Existing workspaces stay where they are.`:"AgentOS reverted to the default workspace root. Existing workspaces were not moved."})}catch(e){j.o.error("Workspace root update failed.",{description:e instanceof Error?e.message:"Unable to update the default workspace root."})}finally{e9(!1)}},sB=(0,i.useCallback)((e,t)=>{switch(e){case"auto":return{mode:"auto",path:null,resolvedPath:null,label:"Auto",detail:"Use the managed resolution order."};case"local-prefix":return{mode:"local-prefix",path:null,resolvedPath:null,label:"Local prefix",detail:"Use the managed local prefix install."};case"global-path":return{mode:"global-path",path:null,resolvedPath:null,label:"Global PATH",detail:"Resolve the first executable named openclaw on PATH when saved."};default:{let e="string"==typeof t?t.trim():"";return{mode:"custom",path:e||null,resolvedPath:e||null,label:"Custom path",detail:e||"Enter an absolute path to an executable OpenClaw binary."}}}},[]),sG=(0,i.useCallback)(e=>{e4(t=>e===t.mode?"custom"===e?sB(e,t.path):t:"custom"===e?sB(e,t.path):sB(e))},[sB]),sq=(0,i.useCallback)(e=>{e4(sB("custom",e))},[sB]),sV=async e=>{tt(!0);try{let t=await fetch("/api/settings/openclaw-binary",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"OpenClaw binary selection could not be updated.")}let a=await t.json();m(a.snapshot),e4(a.selection);let s=a.selection.label||"OpenClaw binary";j.o.success("OpenClaw binary updated.",{description:"auto"===a.selection.mode?"AgentOS will use the managed resolution order.":`${s} is now the active choice.`})}catch(e){j.o.error("OpenClaw binary update failed.",{description:e instanceof Error?e.message:"Unable to update the OpenClaw binary."})}finally{tt(!1)}},sJ=()=>{if(void 0===globalThis.localStorage)return;let e=["mission-control-surface-theme","mission-control-hidden-runtime-ids","mission-control-hidden-task-keys","mission-control-locked-task-keys","mission-control-workspace-plan-id","mission-control-recent-prompts","mission-control-node-positions",K.hy],t=["mission-control-active-workspace-id:","mission-control-node-positions:v2:","mission-control-composer-draft:","mission-control-agent-chat:v1:","mission-control-agent-chat-seen:v1:"];for(let t of e)globalThis.localStorage.removeItem(t);for(let e=globalThis.localStorage.length-1;e>=0;e-=1){let a=globalThis.localStorage.key(e);a&&t.some(e=>a.startsWith(e))&&globalThis.localStorage.removeItem(a)}B([]),q([]),J([]),ec({})},sH=()=>{eS("idle"),eT(null),eM(null),eR("idle"),eP(null),eD(null),eL(null),eF(""),eG("")},sY=async e=>{eS("loading"),eT(null),eM(null);try{let t=await fetch("/api/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"preview",target:e})}),a=await t.json().catch(()=>null);if(!t.ok||!a?.preview)throw Error(a?.error||"Reset preview could not be loaded.");eT(a.preview),eS("ready")}catch(e){eS("error"),eM(e instanceof Error?e.message:"Reset preview failed.")}},sZ=async e=>{ev(!1),eN(e),sH(),await sY(e)},sQ=async()=>{if(ek){eR("running"),eP("full-uninstall"===ek?"Starting full uninstall...":"Starting AgentOS reset..."),eD(null),eL(null),eF("");try{let e=await fetch("/api/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"execute",target:ek,confirmed:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Reset request failed.")}if(!e.body)throw Error("Reset request 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?(eP(t.message),sf(`
|
|
186
|
-
> ${t.message}
|
|
187
|
-
`)):"log"===t.type?sf(`${t.text}
|
|
188
|
-
`):(r=!0,eP(null),eD(t.message),eL(t.backgroundLogPath??null),eR(t.ok?"success":"error"),t.snapshot&&m(t.snapshot),t.ok?("full-uninstall"===ek&&sh(),sJ(),j.o.success("full-uninstall"===ek?"Full uninstall started.":"AgentOS reset completed.",{description:t.message})):j.o.error("full-uninstall"===ek?"Full uninstall failed.":"AgentOS reset failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,eP(null),eD(e.message),eL(e.backgroundLogPath??null),eR(e.ok?"success":"error"),e.snapshot&&m(e.snapshot),e.ok&&("full-uninstall"===ek&&sh(),sJ()))}if(!r)throw Error("Reset stream ended unexpectedly.")}catch(e){eR("error"),eP(null),eD(e instanceof Error?e.message:"Reset failed."),j.o.error("full-uninstall"===ek?"Full uninstall failed.":"AgentOS reset failed.",{description:e instanceof Error?e.message:"Unknown reset error."})}}},sX=e=>{e||"running"!==eI&&(eN(null),sH())},s0=()=>{eN(null),sH(),s_("system")},s1=()=>{let e=aK;tv("Refreshing model status..."),sv(a).then(t=>{t&&(0,eK.h6)(t)&&(e=!0,t8(!1))}).catch(()=>{}).finally(()=>{tv(null),tI(eH("models",e))})},s2=(0,i.useCallback)(e=>{az(e.id,"output"),el({requestId:`task-review:${e.id}:${Date.now()}`,taskId:e.id,taskKey:(0,K.HR)(e),fallbackTask:e})},[az]),s5=(0,i.useCallback)((e,t,a)=>{let s=(0,K.ss)(e,t,a);return ec(e=>({...e,[s.taskKey]:s})),s},[]),s3=(0,i.useCallback)(()=>{el(null)},[]),s4=(0,i.useCallback)(e=>{s5(e,"accepted","Accepted result"),s3(),j.o.success("Task result accepted.",{description:"The review warning is marked as handled for this workspace."})},[s3,s5]),s8=(0,i.useCallback)(e=>{s5(e,"dismissed","Dismissed review"),s3(),j.o.message("Task review dismissed.",{description:"The warning remains available in the task evidence."})},[s3,s5]),s6=(0,i.useCallback)(async(e,t)=>{let a,s,r=(a=nb((0,ez.sL)(e),3200),["Continue this task from the last captured output. Finish the remaining work and verify the result.","","Original mission:",a,(s=nb(t,7600))?"":null,s?"Last captured output:":null,s||null].filter(e=>"string"==typeof e).join("\n"));try{let t=await fetch(`/api/tasks/${encodeURIComponent(e.id)}/control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"continue",message:r,dispatchId:e.dispatchId??null})}),a=await t.json().catch(()=>null);if(!t.ok)throw Error(a?.error||"Unable to continue this task.");s5(e,"continued","Sent continuation"),az(e.id,"output"),ef(!0),s3(),u({force:!0}),j.o.success("Task continuation sent.",{description:"AgentOS will keep the follow-up attached to the existing task card."})}catch(e){j.o.error("Task continuation failed.",{description:e instanceof Error?e.message:"Unable to continue this task."})}},[s3,s5,u,az]),s7=(0,i.useCallback)(e=>{s5(e,"retried","Drafted retry"),z({id:`review-retry:${e.id}:${Date.now()}`,mission:["Retry this task from the original mission. Do not assume the previous stalled runtime completed.\n\nOriginal mission:",(0,ez.sL)(e)].join("\n"),agentId:e.primaryAgentId,sourceKind:"reply",sourceLabel:e.title.trim()||"Task review"}),A(e.primaryAgentId??null),$(!0),s3(),j.o.success("Retry draft prepared.",{description:"Review the mission input, then send it when ready."})},[s3,s5]),s9=(0,i.useCallback)((e,t)=>{az(e.id,t),ef(!0),s3()},[s3,az]),re={snapshot:a,surfaceTheme:ar,connectionState:d,gatewayDraft:eX,workspaceRootDraft:e1,isSavingGateway:e8,isSavingWorkspaceRoot:e7,isCheckingForUpdates:ey,updateRunState:tr,selectedModelId:tR,modelOnboardingRunState:tD,gatewayControlAction:t9,lastCheckedAt:aa,onGatewayDraftChange:e0,onWorkspaceRootDraftChange:e2,onSelectedModelIdChange:tO,onSaveGatewaySettings:sz,onSaveWorkspaceRootSettings:sW,onCheckForUpdates:sF,onControlGateway:sL,onOpenSetupWizard:s_,onRunModelRefresh:s$,onRunModelSetDefault:sR,onOpenAddModels:sU,onOpenUpdateDialog:()=>{"idle"===tr&&su(),ts(!0)},onOpenResetDialog:e=>{sZ(e)},openClawBinarySelection:e5,isSavingOpenClawBinary:te,onOpenClawBinarySelectionModeChange:sG,onOpenClawBinarySelectionPathChange:sq,onSaveOpenClawBinarySettings:sV,installSummary:aZ},rt=(0,s.jsxs)(s.Fragment,{children:[a2?(0,s.jsx)(tw,{snapshot:a,surfaceTheme:ar,stage:aH,systemReady:"success"===th||aK,modelReady:"success"===tZ.phase||t5||aJ,systemSetupRequired:t4,showReadyState:t5,systemActionLabel:aQ.label,systemActionDescription:aQ.description,systemPhase:tg,modelPhase:tL,systemRun:{runState:th,statusMessage:tf,resultMessage:ty,log:tk,manualCommand:tS,docsUrl:tT},modelRun:{runState:tD,statusMessage:tF,resultMessage:tW,log:tG,manualCommand:tK,docsUrl:tH},modelSwitchFeedback:tZ,selectedModelId:tR,discoveredModels:tP,onSelectedModelIdChange:tO,onClearModelSwitchFeedback:()=>tQ(ng),onRunSystemSetup:sN,onRunModelSetDefault:sR,onOpenAddModels:sU,onOpenGatewayAuthSettings:sD,onEnterAgentOS:sE,onCreateWorkspace:sP,onContinueToModels:s1,onBackToSystem:()=>tI("system"),onSelectStage:e=>{t3(!1),tI(eH(e,aK))},launchpadCreateProgress:eY,launchpadCreateRunState:eq}):null,(0,s.jsx)(rD,{open:ai,onOpenChange:so,initialMode:ac,workspaceEditId:ap,surfaceTheme:ar,snapshot:a,onRefresh:p,onWorkspaceCreated:e=>{aW(e,{markPending:!0})},onWorkspaceUpdated:e=>{aW(e,{markPending:!0})}},ap?`workspace-edit:${ap}`:"workspace-create"),(0,s.jsx)(l.o,{open:aw,onOpenChange:av,snapshot:a,initialProvider:ay,onSnapshotChange:m}),(0,s.jsx)(tN,{open:null!==ek,target:ek,surfaceTheme:ar,previewState:eC,preview:eA,previewError:e$,runState:eI,statusMessage:eO,resultMessage:e_,backgroundLogPath:eE,log:eU,confirmText:eW,onConfirmTextChange:eG,onRefreshPreview:()=>{ek&&sY(ek)},onExecute:()=>{sQ()},onBackToSetup:s0,onOpenChange:sX}),(0,s.jsx)(eB,{snapshot:a,surfaceTheme:ar,isInspectorOpen:!1,taskAbortRequest:ee,taskAbortRunState:ea,taskAbortMessage:er,onTaskAbortOpenChange:e=>{"running"!==ea&&(e||(et(null),es("idle"),en(null)))},onTaskAbortConfirm:()=>{sy()},updateDialogOpen:ta,updateRunState:tr,updateStatusMessage:ti,updateResultMessage:to,updateLog:td,updateManualCommand:tu,activeRuntimeCount:aV,updateInstallSummary:aZ,onUpdateDialogOpenChange:e=>{"running"===tr?ts(e):(ts(e),e||su())},onRunOpenClawUpdate:()=>{sk()}})]});return"settings"===t?(0,s.jsxs)("div",{className:(0,N.cn)("mission-shell relative min-h-screen overflow-hidden","light"===ar&&"mission-shell--light"),children:[(0,s.jsx)("div",{className:"mission-canvas-backdrop fixed 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:(0,N.cn)("pointer-events-auto fixed left-0 top-0 z-30 hidden h-[100dvh] overflow-visible mission-ease-smooth transition-[width] duration-500 lg:block",ex?"w-[calc(100vw-96px)] max-w-[292px] lg:w-[292px] lg:max-w-none":"w-[56px]"),onMouseEnter:()=>eg(!0),onMouseLeave:()=>eg(!1),onFocusCapture:()=>eg(!0),onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||eg(!1)},children:(0,s.jsx)(at.z,{snapshot:aD,surfaceTheme:ar,activeWorkspaceId:h,requestedAgentAction:H,connectionState:d,collapsed:!ex,settingsMode:!0,modelManager:{runState:tD,statusMessage:tF,resultMessage:tW,log:tG,manualCommand:tK,docsUrl:tH,discoveredModels:tP,systemReady:aK},onExpandCollapsed:()=>eg(!0),onToggleCollapsed:()=>eg(e=>!e),onSelectWorkspace:e=>{aW(e)},onRefresh:p,onRunModelRefresh:s$,onRunModelDiscover:sM,onRunModelSetDefault:sR,onConnectModelProvider:sI,onOpenModelSetup:()=>s_(),onOpenAddModels:sU,onOpenWorkspaceCreate:()=>si("basic"),onEditWorkspace:sl,onSnapshotChange:m,onAgentCreatedVisible:a9})}),ex?(0,s.jsx)("button",{type:"button","aria-label":"Close navigation",className:"fixed inset-0 z-40 bg-black/62 backdrop-blur-[2px] lg:hidden",onClick:()=>eg(!1)}):null,(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-auto fixed left-0 top-0 z-50 h-[100dvh] overflow-hidden mission-ease-smooth bg-[#050a12] shadow-[18px_0_60px_rgba(0,0,0,0.42)] transition-[width] duration-300 lg:hidden",ex?"w-[min(86vw,292px)]":"w-[56px]"),onClickCapture:e=>{ex&&e.target instanceof Element&&e.target.closest("a")&&eg(!1)},children:(0,s.jsx)(at.z,{snapshot:aD,surfaceTheme:ar,activeWorkspaceId:h,requestedAgentAction:H,connectionState:d,collapsed:!ex,settingsMode:!0,modelManager:{runState:tD,statusMessage:tF,resultMessage:tW,log:tG,manualCommand:tK,docsUrl:tH,discoveredModels:tP,systemReady:aK},onExpandCollapsed:()=>eg(!0),onToggleCollapsed:()=>eg(e=>!e),onSelectWorkspace:e=>{aW(e)},onRefresh:p,onRunModelRefresh:s$,onRunModelDiscover:sM,onRunModelSetDefault:sR,onConnectModelProvider:sI,onOpenModelSetup:()=>s_(),onOpenAddModels:sU,onOpenWorkspaceCreate:()=>si("basic"),onEditWorkspace:sl,onSnapshotChange:m,onAgentCreatedVisible:a9})}),(0,s.jsx)(tq,{...re,sidebarOpen:ex}),(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-none fixed top-0 z-40 hidden lg:block",ex?"lg:left-[316px]":"lg:left-[80px]","lg:right-[84px]"),children:(0,s.jsx)(no,{settingsRef:aB,isSettingsOpen:ew,onToggleTheme:()=>an(e=>"light"===e?"dark":"light"),onToggleSettings:()=>ev(e=>!e),...re})}),rt]}):(0,s.jsxs)("div",{className:(0,N.cn)("mission-shell relative min-h-screen overflow-hidden","light"===ar&&"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)(nc,{snapshot:aD,activeWorkspaceId:h,selectedNodeId:g,focusedAgentId:v,recentCreatedAgentId:em,composerTargetAgentId:C,activeChatAgentId:a_,isComposerActive:T,composerViewportResetNonce:M,recentDispatchId:D,hiddenRuntimeIds:W,hiddenTaskKeys:G,lockedTaskKeys:V,onToggleWorkspaceTaskCards:a3,className:"rounded-none",onEditAgent:e=>{az(e),Y({requestId:`edit:${e}:${Date.now()}`,kind:"edit",agentId:e})},onDeleteAgent:e=>{az(e),Y({requestId:`delete:${e}:${Date.now()}`,kind:"delete",agentId:e})},onFocusAgent:a4,onConfigureAgentModel:a7,onConfigureAgentCapabilities:a6,onInspectAgentDetail:a8,onOpenWorkspaceChannels:sc,onOpenWorkspaceFiles:sd,onMessageAgent:e=>{let t=aD.agents.find(t=>t.id===e);t&&(Y(null),x(t.workspaceId),az(e,"chat"),ef(!0))},onReplyTask:e=>{let t=(0,ez.sL)(e);z({id:`reply:${e.id}:${Date.now()}`,mission:t,agentId:e.primaryAgentId,sourceKind:"reply",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id})},onCopyTaskPrompt:async e=>{let t=(0,ez.sL)(e);z({id:`copy:${e.id}:${Date.now()}`,mission:t,agentId:e.primaryAgentId,sourceKind:"copy",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id});try{await navigator.clipboard.writeText(t),j.o.success("Prompt copied to clipboard.",{description:"The mission input was also populated."})}catch{j.o.message("Prompt moved into mission input.",{description:"Clipboard access was not available."})}},onHideTask:e=>{aF.includes(e.key)||(q(t=>t.includes(e.key)?t:[...t,e.key]),B(t=>{let a=new Set(t);return e.runtimeIds.forEach(e=>a.add(e)),Array.from(a)}))},onToggleTaskLock:e=>{J(t=>{let a=Array.isArray(t)?t:[];return a.includes(e.key)?a.filter(t=>t!==e.key):[...a,e.key]})},onAbortTask:e=>{(0,ez.ss)(e)&&(et(e),es("idle"),en(null))},onInspectTask:(e,t)=>{az(e.id,t),ef(!0)},onReviewTask:s2,onSelectNode:e=>{az(e)},onCanvasNodePointerDownCapture:ss})})]}),(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-none absolute top-0 z-40 hidden lg:block",ex?"lg:left-[316px]":"lg:left-[80px]",eb?"lg:right-[426px]":"lg:right-[84px]"),children:(0,s.jsx)(no,{settingsRef:aB,isSettingsOpen:ew,onToggleTheme:()=>an(e=>"light"===e?"dark":"light"),onToggleSettings:()=>ev(e=>!e),...re})}),(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)(nl,{surfaceTheme:ar})}),(0,s.jsx)("div",{className:"pointer-events-none absolute left-[80px] top-6 z-10 hidden lg:block",children:(0,s.jsx)(nl,{surfaceTheme:ar})}),(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-auto absolute left-0 top-0 z-30 h-[100dvh] overflow-visible mission-ease-smooth transition-[width] duration-500",ex?"w-[calc(100vw-96px)] max-w-[292px] lg:w-[292px] lg:max-w-none":"w-[56px]"),onMouseEnter:()=>eg(!0),onMouseLeave:()=>eg(!1),onFocusCapture:()=>eg(!0),onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||eg(!1)},children:(0,s.jsx)(at.z,{snapshot:aD,surfaceTheme:ar,activeWorkspaceId:h,requestedAgentAction:H,connectionState:d,collapsed:!ex,modelManager:{runState:tD,statusMessage:tF,resultMessage:tW,log:tG,manualCommand:tK,docsUrl:tH,discoveredModels:tP,systemReady:aK},onExpandCollapsed:()=>eg(!0),onToggleCollapsed:()=>eg(e=>!e),onSelectWorkspace:e=>{aW(e)},onRefresh:p,onRunModelRefresh:s$,onRunModelDiscover:sM,onRunModelSetDefault:sR,onConnectModelProvider:sI,onOpenModelSetup:()=>s_(),onOpenAddModels:sU,onOpenWorkspaceCreate:()=>si("basic"),onEditWorkspace:sl,onSnapshotChange:m,onAgentCreatedVisible:a9})}),(0,s.jsx)("div",{className:(0,N.cn)("pointer-events-auto absolute right-0 top-0 z-30 h-[100dvh] overflow-visible mission-ease-smooth transition-[width] duration-500",eb?"w-[calc(100vw-112px)] max-w-[300px] lg:w-[394px] lg:max-w-none":"w-[60px]"),children:(0,s.jsx)(Q,{snapshot:aD,surfaceTheme:ar,selectedNodeId:g,agentDetailFocus:f,lastMission:P,onRefresh:p,onSnapshotChange:m,onConfigureAgentCapabilities:a6,onConnectModelProvider:e=>{sI(e,{autoOpenTerminal:!0})},collapsed:!eb,onToggleCollapsed:()=>ef(e=>!e),activeTab:R,onActiveTabChange:O,onAbortTask:e=>{(0,ez.ss)(e)&&(et(e),es("idle"),en(null))}})}),(0,s.jsx)(c.z,{open:!!Z,agentId:Z?.agentId??null,initialFocus:Z?.focus??"skills",snapshot:aD,onOpenChange:st,onSnapshotChange:e=>m(e),onRefresh:async()=>{await u({force:!0})}}),(0,s.jsx)(o.r,{open:!!ak,agentId:ak?.agentId??null,snapshot:aD,onOpenChange:se,onSnapshotChange:e=>m(e),onRefresh:p,onOpenAddModels:()=>{aN(null),sU(null)}}),(0,s.jsxs)("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.jsxs)("div",{className:"mx-auto mb-1 flex w-fit flex-col items-start gap-1",children:[a5>0?(0,s.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] px-3 py-1 text-[8px] text-slate-200 shadow-[0_10px_24px_rgba(0,0,0,0.14)]",children:[(0,s.jsx)(r.A,{className:"h-3 w-3 text-slate-400"}),(0,s.jsxs)("span",{className:"leading-3 text-slate-300",children:[a5," hidden"]})]}):null,v?(0,s.jsxs)("button",{type:"button",onClick:sn,className:"inline-flex items-center gap-1.5 rounded-full border border-cyan-300/18 bg-[linear-gradient(180deg,rgba(16,25,38,0.98),rgba(8,12,20,0.96))] px-3 py-1 text-[8px] text-cyan-100 shadow-[0_10px_24px_rgba(0,0,0,0.14)] transition-colors hover:border-cyan-200/30 hover:bg-[linear-gradient(180deg,rgba(20,33,49,0.98),rgba(10,15,25,0.96))]","aria-label":"Reset focus and show the full workspace",title:"Reset Focus",children:[(0,s.jsx)(n.A,{className:"h-3 w-3 text-cyan-300"}),(0,s.jsx)("span",{className:"leading-3 text-cyan-50",children:"Reset Focus"})]}):null]}),(0,s.jsx)(S,{snapshot:aD,surfaceTheme:ar,activeWorkspaceId:h,selectedNodeId:g,composeIntent:F,isComposerActive:T,onTargetAgentChange:A,onTargetAgentSelect:sa,onComposerActiveChange:sr,onRefresh:p,onOpenWorkspaceCreate:()=>{si("basic")},onOpenWorkspaceChannels:sc,onAgentCreatedVisible:a9,onMissionDispatchStart:e=>{eu.current.set(e.requestId,e.abortController);let t=(0,ez.Ig)(e,a);U(a=>[t,...a.filter(t=>t.requestId!==e.requestId)]),e.workspaceId&&x(e.workspaceId),az(t.task.id),ef(!0)},onMissionDispatchFailure:(e,t)=>{eu.current.delete(e),U(a=>a.map(a=>a.requestId===e?{...a,task:(0,ez.GU)(a.task,{status:"stalled",subtitle:t,bootstrapStage:"stalled",feedEvent:{id:`${a.task.id}:failed:${Date.now()}`,kind:"warning",timestamp:new Date().toISOString(),title:"Dispatch failed",detail:t,isError:!0}})}:a))},onMissionResponse:(e,t)=>{var a;eu.current.delete(t.requestId),_(e);let s="stalled"===e.status&&"string"==typeof(a=e.summary)&&(/No transcript file was found for this runtime session/i.test(a)||/No transcript entries were found for this runtime/i.test(a));U(a=>a.map(a=>a.requestId===t.requestId?{...a,dispatchId:e.dispatchId??a.dispatchId,task:(0,ez.GU)(a.task,{dispatchId:e.dispatchId,status:s?"running":"stalled"===e.status?"stalled":"cancelled"===e.status?"cancelled":"queued",subtitle:e.summary,bootstrapStage:s?"runtime-observed":"stalled"===e.status?"stalled":"cancelled"===e.status?"cancelled":"accepted",feedEvent:{id:`${a.task.id}:response:${Date.now()}`,kind:"cancelled"!==e.status&&("stalled"!==e.status||s)?"status":"warning",timestamp:new Date().toISOString(),title:s?"Waiting for output":"stalled"===e.status?"Dispatch blocked":"cancelled"===e.status?"Dispatch cancelled":"Mission accepted",detail:s?"The runtime is live, but AgentOS has not captured transcript output yet.":e.summary||"Mission accepted and queued for OpenClaw execution.",isError:"cancelled"===e.status||"stalled"===e.status&&!s}})}:a)),e.dispatchId&&E(e.dispatchId)}})]}),(0,s.jsx)(am._,{snapshot:aD,workspaceId:h??aD.workspaces[0]?.id??null,open:ax,onOpenChange:ag,onRefresh:p,onSnapshotChange:m}),(0,s.jsx)(ah.W,{snapshot:aD,workspaceId:ab,open:null!==ab,onOpenChange:sp}),(0,s.jsx)(ao,{open:!!ei,task:aE,snapshot:aD,surfaceTheme:ar,onOpenChange:e=>{e||s3()},onAccept:s4,onContinue:s6,onRetry:s7,onDismiss:s8,onOpenEvidence:s9}),a2?(0,s.jsx)(tw,{snapshot:a,surfaceTheme:ar,stage:aH,systemReady:"success"===th||aK,modelReady:"success"===tZ.phase||t5||aJ,systemSetupRequired:t4,showReadyState:t5,systemActionLabel:aQ.label,systemActionDescription:aQ.description,systemPhase:tg,modelPhase:tL,systemRun:{runState:th,statusMessage:tf,resultMessage:ty,log:tk,manualCommand:tS,docsUrl:tT},modelRun:{runState:tD,statusMessage:tF,resultMessage:tW,log:tG,manualCommand:tK,docsUrl:tH},modelSwitchFeedback:tZ,selectedModelId:tR,discoveredModels:tP,onSelectedModelIdChange:tO,onClearModelSwitchFeedback:()=>tQ(ng),onRunSystemSetup:sN,onRunModelSetDefault:sR,onOpenAddModels:sU,onOpenGatewayAuthSettings:sD,onEnterAgentOS:sE,onCreateWorkspace:sP,onContinueToModels:s1,onBackToSystem:()=>tI("system"),onSelectStage:e=>{t3(!1),tI(eH(e,aK))},launchpadCreateProgress:eY,launchpadCreateRunState:eq}):null,(0,s.jsx)(rD,{open:ai,onOpenChange:so,initialMode:ac,workspaceEditId:ap,surfaceTheme:ar,snapshot:a,onRefresh:p,onWorkspaceCreated:e=>{aW(e,{markPending:!0})},onWorkspaceUpdated:e=>{aW(e,{markPending:!0})}},ap?`workspace-edit:${ap}`:"workspace-create"),(0,s.jsx)(l.o,{open:aw,onOpenChange:av,snapshot:a,initialProvider:ay,onSnapshotChange:m}),(0,s.jsx)(tN,{open:null!==ek,target:ek,surfaceTheme:ar,previewState:eC,preview:eA,previewError:e$,runState:eI,statusMessage:eO,resultMessage:e_,backgroundLogPath:eE,log:eU,confirmText:eW,onConfirmTextChange:eG,onRefreshPreview:()=>{ek&&sY(ek)},onExecute:()=>{sQ()},onBackToSetup:s0,onOpenChange:sX}),(0,s.jsx)(eB,{snapshot:a,surfaceTheme:ar,isInspectorOpen:eb,taskAbortRequest:ee,taskAbortRunState:ea,taskAbortMessage:er,onTaskAbortOpenChange:e=>{"running"!==ea&&(e||(et(null),es("idle"),en(null)))},onTaskAbortConfirm:()=>{sy()},updateDialogOpen:ta,updateRunState:tr,updateStatusMessage:ti,updateResultMessage:to,updateLog:td,updateManualCommand:tu,activeRuntimeCount:aV,updateInstallSummary:aZ,onUpdateDialogOpenChange:e=>{"running"===tr?ts(e):(ts(e),e||su())},onRunOpenClawUpdate:()=>{sk()}})]})]})}},57442:(e,t,a)=>{Promise.resolve().then(a.bind(a,18112))},88790:(e,t,a)=>{"use strict";a.d(t,{G:()=>m});var s=a(36366),r=a(58359),n=a(23688),i=a(48583),l=a(82711),o=a(23351);let c=/https?:\/\/[^\s<>"'`)\]]+/g,d=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,p=/(?:^|[\s(])((?:\.{1,2}\/)?(?:deliverables|memory|docs|app|components|lib|public|scripts|packages|hooks|output)\/[^\s`),;]+)/g,u=/`((?:\/|\.{1,2}\/|deliverables\/|memory\/|docs\/|app\/|components\/|lib\/|public\/|scripts\/|packages\/|hooks\/|output\/)[^`\n]+)`/g;function m({text:e,className:t,url:a,filePath:i,displayPath:g,basePath:b,compact:f=!1}){let w=function(e,t){let a=new Set;for(let s of(t&&a.add(t),e.matchAll(c)))s[0]&&a.add(s[0]);return[...a]}(e,a),v=function(e){let t=new Set;for(let a of e.matchAll(d))a[0]&&t.add(a[0]);return[...t]}(e),y=function(e,t,a){var s,r;let n,i,l=[],o=(s=t,r=a,n=h(s),i=h(r),n&&i&&n.startsWith("/")?{path:n.replace(/\/+$/,""),label:i.replace(/\/+$/,"")}:null),c=(e,t)=>{let a=function(e,t){let a=h(e);if(!a)return null;if(a.startsWith("/")||!t)return a;if(a===t.label)return t.path;let s=`${t.label}/`;if(!a.startsWith(s))return a;let r=a.slice(s.length).replace(/^\/+/,"");return r?`${t.path}/${r}`:t.path}(e,o),s=h(t||e);a&&s&&(l.some(e=>h(e.path)===a||h(e.label)===s)||l.push({path:a,label:s}))};for(let s of(t&&c(t,a||t),e.matchAll(u))){let e=h(s[1]);e&&c(e,e)}for(let t of e.matchAll(p)){let e=h(t[1]);e&&c(e,e)}return l}(e,i,g);return(0,s.jsxs)("div",{className:(0,o.cn)("space-y-2",f&&"space-y-1.5"),children:[(0,s.jsx)("p",{className:(0,o.cn)("whitespace-pre-wrap break-words",t),children:function(e){let t=Array.from(e.matchAll(c));if(0===t.length)return e;let a=[],r=0;for(let[n]of t){let t=e.indexOf(n,r);t>r&&a.push(e.slice(r,t)),a.push((0,s.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:"nodrag nopan text-cyan-100 underline decoration-cyan-200/45 underline-offset-2 transition-colors hover:text-cyan-50 hover:decoration-cyan-100",onClick:e=>e.stopPropagation(),children:n},`${n}:${t}`)),r=t+n.length}return r<e.length&&a.push(e.slice(r)),a}(e)}),w.length>0||v.length>0||y.length>0?(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[w.map(e=>(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noreferrer",className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-cyan-300/16 bg-cyan-400/[0.08] px-2 py-1 text-[10px] text-cyan-100 transition-colors hover:border-cyan-200/30 hover:bg-cyan-400/[0.14]",f&&"px-1.5 py-[3px] text-[9px]"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(r.A,{className:(0,o.cn)("h-3 w-3 shrink-0",f&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:function(e){try{let t=new URL(e);return`${t.hostname}${"/"===t.pathname?"":t.pathname}`}catch{return e}}(e)})]},e)),v.map(e=>(0,s.jsxs)("a",{href:`mailto:${e}`,className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-sky-300/16 bg-sky-400/[0.08] px-2 py-1 text-[10px] text-sky-50 transition-colors hover:border-sky-200/30 hover:bg-sky-400/[0.14]",f&&"px-1.5 py-[3px] text-[9px]"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(r.A,{className:(0,o.cn)("h-3 w-3 shrink-0",f&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:e})]},e)),y.map(e=>(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-300/16 bg-emerald-400/[0.08] px-2 py-1 text-[10px] text-emerald-50 transition-colors hover:border-emerald-200/30 hover:bg-emerald-400/[0.14]",f&&"px-1.5 py-[3px] text-[9px]"),onClick:t=>{t.stopPropagation(),x(e.path,b)},children:[(0,s.jsx)(n.A,{className:(0,o.cn)("h-3 w-3 shrink-0",f&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:(0,l.$7)(e.label)})]},`${e.path}:${e.label}`))]}):null]})}function h(e){let t=e?.trim();return t?t.replace(/[.,:;]+$/g,""):null}async function x(e,t){try{let a=await fetch("/api/files/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,basePath:t??null})}),s=await a.json();if(!a.ok)throw Error(s.error||"Unable to reveal file.");i.oR.success("Revealed file.",{description:(0,l.$7)(e)})}catch(e){i.oR.error("Could not reveal file.",{description:e instanceof Error?e.message:"Unknown file reveal error."})}}},93028:(e,t,a)=>{"use strict";a.d(t,{B4:()=>p,E2:()=>m,HR:()=>r,Kf:()=>i,UF:()=>o,VL:()=>d,hy:()=>s,kg:()=>c,l_:()=>u,ss:()=>n,wg:()=>l});let s="mission-control-task-review-state-v1";function r(e){let t="string"==typeof e.key?e.key.trim():"",a="string"==typeof e.dispatchId?e.dispatchId.trim():"";return t||a||e.id}function n(e,t,a,s=new Date().toISOString()){return{taskId:e.id,taskKey:r(e),status:t,action:a,reviewedAt:s}}function i(e){if(!e)return{};try{let a=JSON.parse(e);if(!a||"object"!=typeof a||Array.isArray(a))return{};let s={};for(let[e,r]of Object.entries(a)){var t;(t=r)&&"object"==typeof t&&"string"==typeof t.taskId&&"string"==typeof t.taskKey&&h(t.status)&&"string"==typeof t.action&&"string"==typeof t.reviewedAt&&(s[e]={...r,taskKey:r.taskKey||e})}return s}catch{return{}}}function l(e,t){if(0===Object.keys(t).length)return e;let a=!1,s=e.tasks.map(e=>{var s,n,i,l;let o=t[r(e)];return o?(a=!0,s=e,n=o,{...s,metadata:{...s.metadata,reviewStatus:n.status,reviewAction:n.action,reviewedAt:n.reviewedAt,reviewEvents:[(i=s,l=n,{id:`task-review:${l.taskKey}:${l.status}`,kind:"accepted"===l.status||"continued"===l.status?"status":"warning",timestamp:l.reviewedAt,title:function(e){switch(e){case"accepted":return"Review accepted";case"continued":return"Continuation sent";case"retried":return"Retry drafted";case"dismissed":return"Review dismissed"}}(l.status),detail:`${m(l.status)} Task: ${i.title.trim()||i.id}.`})]}}):e});return a?{...e,tasks:s}:e}function o(e){let t=e.metadata.reviewedAt;return"string"==typeof t&&t.trim().length>0?t:null}function c(e){let t=e.metadata.reviewAction;return"string"==typeof t&&t.trim().length>0?t:null}function d(e,t={}){let a,s=h(a=e.metadata.reviewStatus)?a:null;return"continued"!==s?s:!function(e,t={}){let a=o(e),s=a?Date.parse(a):NaN;return!(!Number.isNaN(s)&&function(e,t){if(!e)return!1;let a=Date.parse(e);return!Number.isNaN(a)&&a>t}(t.latestEvidenceAt,s))&&(!!t.hasLiveActivity||!Number.isNaN(s)&&(t.nowMs??Date.now())-s<12e4)}(e,t)?null:s}function p(e){switch(e){case"accepted":return"accepted";case"continued":return"continuing";case"retried":return"retry drafted";case"dismissed":return"dismissed"}}function u(e){switch(e){case"accepted":return"review accepted";case"continued":return"continuation sent";case"retried":return"retry drafted";case"dismissed":return"review dismissed"}}function m(e){switch(e){case"accepted":return"An operator accepted the captured result. The original warning remains available for audit.";case"continued":return"An operator sent a continuation in the existing task session.";case"retried":return"An operator drafted a retry from the original mission.";case"dismissed":return"An operator dismissed this review item without accepting the captured result."}}function h(e){return"accepted"===e||"continued"===e||"retried"===e||"dismissed"===e}},96595:(e,t,a)=>{"use strict";a.d(t,{F:()=>l});var s=a(36366),r=a(70430),n=a(16337),i=a(23351);let l=r.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(n.bL,{ref:r,className:(0,i.cn)("relative overflow-hidden",e),...a,children:[(0,s.jsx)(n.LM,{className:"mission-scroll h-full w-full rounded-[inherit] [&>div]:!block [&>div]:!w-full [&>div]:!min-w-0",children:t}),(0,s.jsx)(o,{}),(0,s.jsx)(n.OK,{})]}));l.displayName=n.bL.displayName;let o=r.forwardRef(({className:e,orientation:t="vertical",...a},r)=>(0,s.jsx)(n.VM,{ref:r,orientation:t,className:(0,i.cn)("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)(n.lr,{className:"relative flex-1 rounded-full bg-white/[0.12]"})}));o.displayName=n.VM.displayName}}]);
|