@wrongstack/webui 0.281.1 → 0.282.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AnalyticsDashboard-Cb08RPms.js → AnalyticsDashboard-BrQc2ss-.js} +1 -1
- package/dist/assets/AutoPhaseView-8NTdnZ0a.js +1 -0
- package/dist/assets/{CodeEditor-CSTcX3Za.js → CodeEditor-C-pJLtUR.js} +1 -1
- package/dist/assets/{DebugDashboard-D6-znhBO.js → DebugDashboard-BHpiEOcf.js} +1 -1
- package/dist/assets/{DesignGalleryView-yKa55dpM.js → DesignGalleryView-M6Hp7s9b.js} +1 -1
- package/dist/assets/KanbanView-nMv98m0N.js +1 -0
- package/dist/assets/{MailboxDetailView-DbX_cNcu.js → MailboxDetailView-g3IQx4DB.js} +1 -1
- package/dist/assets/OfficeMapPanel-D3VE7UCd.js +4 -0
- package/dist/assets/{ProcessMonitor-DvPiHdzj.js → ProcessMonitor-CbfQYneY.js} +1 -1
- package/dist/assets/{QueuePanel-BVvnJXHh.js → QueuePanel-eGK1SSKx.js} +1 -1
- package/dist/assets/{RefreshDebugView-pmMPOier.js → RefreshDebugView-BXq2P3wo.js} +1 -1
- package/dist/assets/{SddBoardView-CGJbbRrh.js → SddBoardView-DvuH4f4e.js} +2 -2
- package/dist/assets/{SddFlowGraph-WW0qCx0t.js → SddFlowGraph-CtMpzU4S.js} +1 -1
- package/dist/assets/SddWizard-G55Yw9Bb.js +1 -0
- package/dist/assets/{SessionsDashboard-VwXvmSxS.js → SessionsDashboard-Dqsrp5CK.js} +1 -1
- package/dist/assets/SkillDetailView-CX9zeWBG.js +2 -0
- package/dist/assets/{SpecsView-BRdxB6rh.js → SpecsView-BnUsqkrG.js} +1 -1
- package/dist/assets/{TerminalPanel-CAcbPNO_.js → TerminalPanel-BCpddej2.js} +1 -1
- package/dist/assets/{chat-store-YPRVJGbn.js → chat-store-CIMOL6-x.js} +1 -1
- package/dist/assets/{i18n-BJCOtLro.js → i18n-CNo6A2vu.js} +1 -1
- package/dist/assets/index-BhO3caLf.js +146 -0
- package/dist/assets/index-D7_FeyCA.css +1 -0
- package/dist/assets/{session-store-Do0MGnXu.js → session-store-DN1UYDL9.js} +1 -1
- package/dist/assets/ui-store-BdOsq6T-.js +1 -0
- package/dist/assets/utils-DBns3uMk.js +1 -0
- package/dist/assets/{vendor-Bhf0nZ3B.js → vendor-Ch4m_qLI.js} +25 -25
- package/dist/assets/{ws-client-D9IQ9580.js → ws-client-BAV7SLzK.js} +1 -1
- package/dist/assets/{xyflow-Bp8EMwkC.js → xyflow-D5_yey7w.js} +3 -3
- package/dist/index.html +9 -9
- package/dist/index.js +6154 -5253
- package/dist/index.js.map +1 -1
- package/dist/server/entry.js +345 -13
- package/dist/server/entry.js.map +1 -1
- package/dist/server/index.js +345 -13
- package/dist/server/index.js.map +1 -1
- package/dist/types.d.ts +18 -3
- package/package.json +6 -6
- package/dist/assets/AutoPhaseView--Ec4Mom8.js +0 -1
- package/dist/assets/OfficeMapPanel-BMxzEv_S.js +0 -4
- package/dist/assets/SddWizard-Cen90k6M.js +0 -1
- package/dist/assets/SkillDetailView-CjUeZv6V.js +0 -2
- package/dist/assets/index-BSuiEQIC.js +0 -145
- package/dist/assets/index-CMiinLaB.css +0 -1
- package/dist/assets/ui-store-D3gGpJWY.js +0 -1
- package/dist/assets/utils-sFCTikqz.js +0 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Usage } from '@wrongstack/core';
|
|
1
|
+
import { Usage, KanbanBoard, KanbanBoardSummary, KanbanTask } from '@wrongstack/core';
|
|
2
2
|
|
|
3
3
|
interface WSMessage {
|
|
4
4
|
type: string;
|
|
@@ -119,6 +119,7 @@ interface WSIterationLimitReached {
|
|
|
119
119
|
interface WSProviderResponse {
|
|
120
120
|
type: 'provider.response';
|
|
121
121
|
payload: SessionScopedPayload & {
|
|
122
|
+
content?: unknown;
|
|
122
123
|
usage: Usage;
|
|
123
124
|
stopReason: string;
|
|
124
125
|
messageId: string;
|
|
@@ -873,6 +874,14 @@ interface WSAgentStatusChanged {
|
|
|
873
874
|
task?: string | undefined;
|
|
874
875
|
};
|
|
875
876
|
}
|
|
877
|
+
interface WSKanbanResult {
|
|
878
|
+
type: `kanban.${string}`;
|
|
879
|
+
payload: {
|
|
880
|
+
success: boolean;
|
|
881
|
+
data?: KanbanBoard | KanbanBoardSummary[] | KanbanTask | KanbanTask[] | Record<string, unknown> | null;
|
|
882
|
+
error?: string | undefined;
|
|
883
|
+
};
|
|
884
|
+
}
|
|
876
885
|
/** One worktree lane in the swim-lane / DAG view. */
|
|
877
886
|
interface WorktreeHandleView {
|
|
878
887
|
handleId: string;
|
|
@@ -999,6 +1008,9 @@ type WSClientMessage = WSUserMessage | WSToolConfirmResult | {
|
|
|
999
1008
|
} | {
|
|
1000
1009
|
type: 'autophase.status';
|
|
1001
1010
|
payload?: Record<string, never>;
|
|
1011
|
+
} | {
|
|
1012
|
+
type: 'autophase.state';
|
|
1013
|
+
payload?: Record<string, never>;
|
|
1002
1014
|
} | {
|
|
1003
1015
|
type: 'autophase.save';
|
|
1004
1016
|
payload?: Record<string, never>;
|
|
@@ -1791,6 +1803,9 @@ type WSClientMessage = WSUserMessage | WSToolConfirmResult | {
|
|
|
1791
1803
|
payload: {
|
|
1792
1804
|
id: string;
|
|
1793
1805
|
};
|
|
1806
|
+
} | {
|
|
1807
|
+
type: `kanban.${string}`;
|
|
1808
|
+
payload?: Record<string, unknown> | undefined;
|
|
1794
1809
|
} | {
|
|
1795
1810
|
type: 'plan.template_use';
|
|
1796
1811
|
payload: {
|
|
@@ -1876,7 +1891,7 @@ type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSThinkingD
|
|
|
1876
1891
|
payload: {
|
|
1877
1892
|
runId: string;
|
|
1878
1893
|
};
|
|
1879
|
-
} | WSEternalIteration | WSAgentTimelineMessage | WSAgentStatusChanged | {
|
|
1894
|
+
} | WSEternalIteration | WSAgentTimelineMessage | WSAgentStatusChanged | WSKanbanResult | {
|
|
1880
1895
|
type: 'subagent.event';
|
|
1881
1896
|
payload: SessionScopedPayload & Record<string, unknown> & {
|
|
1882
1897
|
kind: string;
|
|
@@ -2507,4 +2522,4 @@ interface WSCollabInjectionGranted {
|
|
|
2507
2522
|
};
|
|
2508
2523
|
}
|
|
2509
2524
|
|
|
2510
|
-
export type { BroadcastFn, CollabPanelMessage, CollabRole, CompletionItemKind, MemoryScope, OAuthKind, SessionScopedPayload, WSAgentStatusChanged, WSAgentTimelineMessage, WSAuthOAuthStatus, WSAutoPhaseLifecycle, WSAutoPhaseList, WSAutoPhaseProgress, WSAutoPhaseState, WSClientMessage, WSCollabAnnotate, WSCollabAnnotationAdded, WSCollabAnnotationResolved, WSCollabEvent, WSCollabGrantControl, WSCollabInjectTool, WSCollabInjectionGranted, WSCollabJoin, WSCollabLeave, WSCollabParticipantJoined, WSCollabParticipantLeft, WSCollabPauseGranted, WSCollabPauseReleased, WSCollabRequestPause, WSCollabResolve, WSCollabResume, WSCollabState, WSCompactionFailed, WSCompletionRequest, WSCompletionResult, WSContextCompacted, WSContextDebug, WSContextMaxContext, WSContextModeChanged, WSContextModesList, WSContextPct, WSContextRepaired, WSDelegateCompleted, WSDelegateStarted, WSDesignKitSummary, WSDesignList, WSDesignMaterialize, WSDesignSet, WSDesignState, WSDesignUse, WSDesignVerify, WSDiagGet, WSError, WSEternalIteration, WSFilesList, WSIterationCompleted, WSIterationLimitReached, WSIterationStarted, WSKeyOperationResult, WSMemoryList, WSMessage, WSModelSwitch, WSModesList, WSProviderCatalog, WSProviderError, WSProviderFallback, WSProviderModels, WSProviderProbe, WSProviderResponse, WSProviderRetry, WSProviderStreamError, WSRunResult, WSSavedProviders, WSServerMessage, WSSessionEnd, WSSessionStart, WSSessionStats, WSSessionsList, WSSideEffects, WSSkillContent, WSSkillsCreated, WSSkillsEdited, WSSkillsExported, WSSkillsInstalled, WSSkillsList, WSSkillsUninstalled, WSSkillsUpdated, WSStatsGet, WSTextDelta, WSThinkingDelta, WSTodosCleared, WSTodosUpdated, WSTokenCostEstimateUnavailable, WSTokenThreshold, WSToolConfirmNeeded, WSToolConfirmResult, WSToolExecuted, WSToolLoopDetected, WSToolProgress, WSToolUseStart, WSToolsList, WSTrustPersisted, WSUserMessage, WSWorktreeCleanupResult, WSWorktreeDiffResult, WSWorktreeEvent, WSWorktreeMergeResult, WSWorktreeOrphans, WSWorktreeState, WorktreeDiffSummary, WorktreeHandleView, WorktreeOrphanView };
|
|
2525
|
+
export type { BroadcastFn, CollabPanelMessage, CollabRole, CompletionItemKind, MemoryScope, OAuthKind, SessionScopedPayload, WSAgentStatusChanged, WSAgentTimelineMessage, WSAuthOAuthStatus, WSAutoPhaseLifecycle, WSAutoPhaseList, WSAutoPhaseProgress, WSAutoPhaseState, WSClientMessage, WSCollabAnnotate, WSCollabAnnotationAdded, WSCollabAnnotationResolved, WSCollabEvent, WSCollabGrantControl, WSCollabInjectTool, WSCollabInjectionGranted, WSCollabJoin, WSCollabLeave, WSCollabParticipantJoined, WSCollabParticipantLeft, WSCollabPauseGranted, WSCollabPauseReleased, WSCollabRequestPause, WSCollabResolve, WSCollabResume, WSCollabState, WSCompactionFailed, WSCompletionRequest, WSCompletionResult, WSContextCompacted, WSContextDebug, WSContextMaxContext, WSContextModeChanged, WSContextModesList, WSContextPct, WSContextRepaired, WSDelegateCompleted, WSDelegateStarted, WSDesignKitSummary, WSDesignList, WSDesignMaterialize, WSDesignSet, WSDesignState, WSDesignUse, WSDesignVerify, WSDiagGet, WSError, WSEternalIteration, WSFilesList, WSIterationCompleted, WSIterationLimitReached, WSIterationStarted, WSKanbanResult, WSKeyOperationResult, WSMemoryList, WSMessage, WSModelSwitch, WSModesList, WSProviderCatalog, WSProviderError, WSProviderFallback, WSProviderModels, WSProviderProbe, WSProviderResponse, WSProviderRetry, WSProviderStreamError, WSRunResult, WSSavedProviders, WSServerMessage, WSSessionEnd, WSSessionStart, WSSessionStats, WSSessionsList, WSSideEffects, WSSkillContent, WSSkillsCreated, WSSkillsEdited, WSSkillsExported, WSSkillsInstalled, WSSkillsList, WSSkillsUninstalled, WSSkillsUpdated, WSStatsGet, WSTextDelta, WSThinkingDelta, WSTodosCleared, WSTodosUpdated, WSTokenCostEstimateUnavailable, WSTokenThreshold, WSToolConfirmNeeded, WSToolConfirmResult, WSToolExecuted, WSToolLoopDetected, WSToolProgress, WSToolUseStart, WSToolsList, WSTrustPersisted, WSUserMessage, WSWorktreeCleanupResult, WSWorktreeDiffResult, WSWorktreeEvent, WSWorktreeMergeResult, WSWorktreeOrphans, WSWorktreeState, WorktreeDiffSummary, WorktreeHandleView, WorktreeOrphanView };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/webui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.282.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Browser-based WebUI for WrongStack — React + Vite frontend with WebSocket backend that drives the same agent kernel as the CLI/TUI.",
|
|
6
6
|
"keywords": [
|
|
@@ -84,11 +84,11 @@
|
|
|
84
84
|
"virtua": "^0.49.1",
|
|
85
85
|
"ws": "^8.21.0",
|
|
86
86
|
"zustand": "^5.0.14",
|
|
87
|
-
"@wrongstack/core": "0.
|
|
88
|
-
"@wrongstack/
|
|
89
|
-
"@wrongstack/
|
|
90
|
-
"@wrongstack/
|
|
91
|
-
"@wrongstack/tools": "0.
|
|
87
|
+
"@wrongstack/core": "0.282.0",
|
|
88
|
+
"@wrongstack/providers": "0.282.0",
|
|
89
|
+
"@wrongstack/mcp": "0.282.0",
|
|
90
|
+
"@wrongstack/runtime": "0.282.0",
|
|
91
|
+
"@wrongstack/tools": "0.282.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"node-pty": "^1.1.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-YPRVJGbn.js";import{m as n,p as r}from"./markdown-D0X23O-i.js";import{Br as i,Ht as a,Ir as o,It as s,Lt as c,Qr as l,Ut as u,Vr as d,X as f,Yr as p,Z as m,bt as h,cr as g,ct as _,ei as v,or as y,ot as b,qt as x,si as S,ui as C}from"./vendor-Bhf0nZ3B.js";import"./i18n-BJCOtLro.js";import{t as w}from"./utils-sFCTikqz.js";import{C as T,I as E,N as D,T as O,n as k,p as A,r as ee,s as j,t as M}from"./index-BSuiEQIC.js";var N=e(n(),1),P=r(),F={pending:{icon:(0,P.jsx)(g,{className:`w-4 h-4`}),color:`text-muted-foreground`,label:`Pending`},in_progress:{icon:(0,P.jsx)(y,{className:`w-4 h-4 animate-spin`}),color:`text-primary`,label:`In Progress`},blocked:{icon:(0,P.jsx)(x,{className:`w-4 h-4`}),color:`text-[hsl(var(--warning))]`,label:`Blocked`},failed:{icon:(0,P.jsx)(l,{className:`w-4 h-4`}),color:`text-destructive`,label:`Failed`},review:{icon:(0,P.jsx)(s,{className:`w-4 h-4`}),color:`text-[hsl(var(--info))]`,label:`Review`},completed:{icon:(0,P.jsx)(v,{className:`w-4 h-4`}),color:`text-[hsl(var(--success))]`,label:`Done`}},I={critical:`bg-destructive/15 text-destructive`,high:`bg-orange-500/15 text-orange-600 dark:text-orange-400`,medium:`bg-[hsl(var(--info)/0.15)] text-[hsl(var(--info))]`,low:`bg-muted text-muted-foreground`},L={feature:`bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))]`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-violet-500/15 text-violet-600 dark:text-violet-400`,docs:`bg-sky-500/15 text-sky-600 dark:text-sky-400`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function R(e){if(!e)return``;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function z({task:e,onStatusChange:t,onRetry:n,agents:r,onAssign:i,compact:a,className:o}){let{t:c}=S(),l=F[e.status],[u,d]=(0,N.useState)(!1),f=e.status===`in_progress`;return(0,P.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,f?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-[hsl(var(--success)/0.35)] bg-[hsl(var(--success)/0.06)]`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,o),children:[(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`span`,{className:w(`mt-0.5`,l.color),"aria-label":f?c(`common:status.inProgress`):void 0,children:l.icon}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.priority]),children:e.priority}),(0,P.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,L[e.type]),children:e.type})]}),e.description&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,P.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,f?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[f&&(0,P.jsx)(y,{className:`w-3 h-3 animate-spin`,"aria-label":c(`common:status.working`)}),(0,P.jsx)(`span`,{children:e.assignee})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,P.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,P.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,P.jsxs)(`span`,{children:[`• `,R(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!a&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`in_progress`),className:`px-2 py-0.5 text-[10px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,children:c(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))] hover:bg-[hsl(var(--success)/0.25)] transition-colors`,children:c(`activity:task.complete`)}),n&&(e.status===`failed`||e.status===`completed`)&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,children:[(0,P.jsx)(s,{className:`w-3 h-3`}),` `,c(`activity:task.retry`)]}),i&&r&&r.length>0&&(u?(0,P.jsxs)(`select`,{autoFocus:!0,defaultValue:e.assignee??``,onChange:t=>{i(e.id,t.target.value),d(!1)},onBlur:()=>d(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,P.jsx)(`option`,{value:``,children:c(`activity:task.unassigned`)}),r.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,title:c(`activity:task.assignTitle`),children:[(0,P.jsx)(b,{className:`w-3 h-3`}),` `,c(`activity:task.assign`)]}))]})]})}var B=[{key:`pending`,label:`Pending`,match:[`pending`,`blocked`]},{key:`in_progress`,label:`In Progress`,match:[`in_progress`]},{key:`review`,label:`Review`,match:[`review`]},{key:`failed`,label:`Failed`,match:[`failed`]},{key:`completed`,label:`Done`,match:[`completed`]}],V={pending:`bg-muted text-muted-foreground`,ready:`bg-[hsl(var(--info)/0.15)] text-[hsl(var(--info))]`,running:`bg-primary/15 text-primary`,paused:`bg-amber-500/15 text-amber-600 dark:text-amber-400`,completed:`bg-[hsl(var(--success)/0.15)] text-[hsl(var(--success))]`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function H(){let{client:e}=T(),{t}=S(),n=D(e=>e.phases),[r,i]=(0,N.useState)(`phase`),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),d=(0,N.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),f=(0,N.useMemo)(()=>[...new Set(d.map(e=>e.assignee).filter(e=>!!e))],[d]),m=(0,N.useCallback)(t=>e?.send?.(t),[e]),h=(0,N.useCallback)((e,t)=>m({type:`autophase.taskStatus`,payload:{taskId:e,status:t}}),[m]),g=(0,N.useCallback)(e=>m({type:`autophase.retryTask`,payload:{taskId:e}}),[m]),_=(0,N.useCallback)((e,t)=>m({type:`autophase.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[m]),v=(0,N.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&m({type:`autophase.addTask`,payload:{phaseId:e,title:t}})})},[m]),y=(0,N.useCallback)(e=>{s&&m({type:`autophase.moveTask`,payload:{taskId:s,toPhaseId:e}}),c(null),u(null)},[s,m]),b=(0,N.useCallback)(e=>{s&&m({type:`autophase.taskStatus`,payload:{taskId:s,status:e}}),c(null),u(null)},[s,m]),x={onStatusChange:h,onRetry:g,agents:f,onAssign:_};function C(e){return{draggable:!0,onDragStart:t=>{c(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{c(null),u(null)}}}function E(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,l!==e&&u(e)},onDragLeave:()=>u(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":l===e||void 0}}return n.length===0?(0,P.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,P.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:d.length})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,r===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(p,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,r===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r===`phase`?(0,P.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:n.map(e=>{let n=d.filter(t=>t.phaseId===e.id);return(0,P.jsxs)(`div`,{...E(`phase:${e.id}`,()=>y(e.id)),className:w(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,l===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,P.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,V[e.status]),children:e.status})]}),(0,P.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>v(e.id),title:t(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,P.jsx)(a,{className:`h-4 w-4`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:n.length===0?(0,P.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:t(`activity:board.dropHere`)}):n.map(e=>(0,P.jsx)(`div`,{...C(e.id),className:w(s===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,...x})},e.id))})]},e.id)})}):(0,P.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,P.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${B.length}, minmax(0, 1fr))`},children:[(0,P.jsx)(`div`,{}),B.map(e=>(0,P.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:t(`activity:board.status.${e.key}`)},e.key)),n.map(e=>(0,P.jsxs)(U,{children:[(0,P.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,P.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,V[e.status]),children:e.status})]})}),B.map(t=>{let n=d.filter(n=>n.phaseId===e.id&&t.match.includes(n.status)),r=`cell:${e.id}:${t.key}`;return(0,P.jsx)(`div`,{...E(r,()=>b(t.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,l===r?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,P.jsx)(`div`,{...C(e.id),className:w(s===e.id&&`opacity-50`),children:(0,P.jsx)(z,{task:e,compact:!0,...x})},e.id))},t.key)})]},e.id))]})})]})}function U({children:e}){return(0,P.jsx)(P.Fragment,{children:e})}function W({onClose:e}){let{client:n}=T(),{t:r}=S(),o=D(e=>e.phases),s=D(e=>e.overallPercent),l=D(e=>e.autonomous),p=D(e=>e.title),g=D(e=>e.goal),v=D(e=>e.status),y=D(e=>e.lastError),b=D(e=>e.graphs);(0,N.useEffect)(()=>{n?.send?.({type:`autophase.list`})},[n]);let j=E(e=>e.worktrees),F=E(e=>e.baseBranch),[I,L]=(0,N.useState)(``),[R,z]=(0,N.useState)(null),[B,V]=(0,N.useState)(!1),[U,W]=(0,N.useState)(!0),G=o.length>0,K=R!=null&&!G;(0,N.useEffect)(()=>{G&&z(null)},[G]);let q=(0,N.useCallback)(()=>{let e=I.trim();if(!e||R!=null)return;let r=t.getState();r.addMessage({role:`user`,content:e}),r.addMessage({role:`assistant`,content:C.t(`activity:autoPhase.planningAck`)}),z(e),L(``),n?.send?.({type:`autophase.start`,payload:{title:e,autonomous:!0,worktrees:U}}),O(`chat`)},[I,R,n,U]),J=(0,N.useCallback)(()=>{n?.send?.({type:`autophase.stop`,payload:{}}),z(null)},[n]),Y=(0,N.useCallback)(()=>{n?.send?.({type:`autophase.toggleAutonomous`,payload:{}})},[n]),X=(0,N.useCallback)(()=>{n?.send?.(v===`paused`?{type:`autophase.resume`,payload:{}}:{type:`autophase.pause`,payload:{}})},[n,v]),Z=(0,N.useCallback)(()=>{n?.send?.({type:`autophase.stop`,payload:{}})},[n]),Q=(0,N.useCallback)(()=>{n?.send?.({type:`autophase.clear`,payload:{}}),D.getState().clear(),z(null),L(``)},[n]),[te,$]=(0,N.useState)(!1),ne=(0,N.useCallback)(()=>{n?.send?.({type:`autophase.revert`,payload:{}}),$(!1)},[n]),re=v===`running`||v===`paused`,ie=v===`stopped`||v===`completed`||v===`failed`,ae=(0,N.useCallback)(e=>{e&&n?.send?.({type:`autophase.load`,payload:{graphId:e}})},[n]);return(0,P.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,P.jsxs)(`header`,{className:`flex items-center justify-between px-4 py-2 border-b bg-card shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(d,{className:`h-5 w-5 text-muted-foreground`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-lg font-semibold`,children:G&&p||`AutoPhase`}),G&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`activity:autoPhase.summary`,{count:o.length,pct:s})})]}),G&&(0,P.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,v===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:v===`paused`||v===`stopped`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:v===`completed`?`border-green-500/40 bg-green-500/10 text-green-700 dark:text-green-300`:`border-primary/30 bg-primary/10 text-primary`),title:y??void 0,children:v})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b.length>0&&(0,P.jsxs)(`select`,{value:G?b.find(e=>e.title===p)?.id??``:``,onChange:e=>ae(e.target.value),title:r(`activity:autoPhase.switchBoard`),className:`rounded border border-border bg-card px-2 py-1 text-xs text-foreground`,children:[(0,P.jsx)(`option`,{value:``,disabled:!0,children:r(`activity:autoPhase.boardsCount`,{count:b.length})}),b.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),G&&(0,P.jsxs)(`button`,{type:`button`,onClick:Y,title:r(`activity:autoPhase.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,l?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,P.jsx)(f,{className:`h-3.5 w-3.5`}),` `,r(l?`activity:autoPhase.autonomous`:`activity:autoPhase.manual`)]}),re&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:X,title:r(v===`paused`?`activity:autoPhase.resumeTitle`:`activity:autoPhase.pauseTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[v===`paused`?(0,P.jsx)(u,{className:`h-3.5 w-3.5`}):(0,P.jsx)(x,{className:`h-3.5 w-3.5`}),r(v===`paused`?`activity:autoPhase.resume`:`activity:autoPhase.pause`)]}),(0,P.jsxs)(`button`,{type:`button`,onClick:Z,title:r(`activity:autoPhase.stopTitle`),className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,P.jsx)(h,{className:`h-3.5 w-3.5 fill-current`}),` `,r(`activity:autoPhase.stop`)]})]}),G&&ie&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:Q,title:r(`activity:autoPhase.newTitle`),className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-primary/20`,children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),` `,r(`activity:autoPhase.newLabel`)]}),te?(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-amber-700 dark:text-amber-300`,children:r(`activity:autoPhase.revertConfirm`)}),(0,P.jsx)(`button`,{type:`button`,onClick:ne,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:r(`common:action.yes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:r(`common:action.no`)})]}):(0,P.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:r(`activity:autoPhase.revertTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,P.jsx)(_,{className:`h-3.5 w-3.5`}),` `,r(`activity:autoPhase.revert`)]})]}),(0,P.jsx)(A,{variant:`ghost`,size:`icon`,onClick:e,children:(0,P.jsx)(m,{className:`h-4 w-4`})})]})]}),G&&g&&(0,P.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(c,{className:`h-3 w-3`}),` `,r(`activity:autoPhase.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:g})]}),G?(0,P.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,P.jsx)(H,{})}):K?(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,P.jsx)(i,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:r(`activity:autoPhase.planning`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`activity:autoPhase.planningBody`)})]}),(0,P.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,P.jsx)(c,{className:`h-3 w-3`}),` `,r(`activity:autoPhase.goal`)]}),(0,P.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:R})]}),(0,P.jsxs)(A,{variant:`outline`,onClick:J,className:`gap-2`,children:[(0,P.jsx)(h,{className:`h-4 w-4 fill-current`}),` `,r(`common:action.cancel`)]})]})}):(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,P.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,P.jsx)(c,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,P.jsx)(`h2`,{className:`text-xl font-semibold`,children:r(`activity:autoPhase.startHeading`)}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`activity:autoPhase.startBody`)})]}),(0,P.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:r(`activity:autoPhase.startPlaceholder`),rows:5,className:`w-full rounded-lg border border-border bg-card px-4 py-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 placeholder:text-muted-foreground/50`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),q())}}),(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>W(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),r(`activity:autoPhase.isolateLabel`)]}),(0,P.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,P.jsxs)(A,{onClick:q,disabled:!I.trim(),className:`flex-1 gap-2`,children:[(0,P.jsx)(u,{className:`h-4 w-4`}),r(`activity:autoPhase.startButton`)]})}),(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[r(`activity:autoPhase.ctrlHint`),` ·`,` `,r(U?`activity:autoPhase.isolateOn`:`activity:autoPhase.isolateOff`)]})]})}),j.length>0&&(0,P.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:r(`activity:autoPhase.lanes`)}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,B?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:r(`activity:autoPhase.graph`)})]}),(0,P.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,P.jsx)(M,{}),B?(0,P.jsx)(ee,{worktrees:j,baseBranch:F}):(0,P.jsx)(k,{worktrees:j,baseBranch:F})]})]})]})}export{W as AutoPhaseView};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{c as t,m as n,p as r,s as i}from"./markdown-D0X23O-i.js";import{$ as a,Cn as o,Nt as s,Qn as c,T as l,Tn as u,X as d,_r as f,en as p,et as m,it as h,jr as g,jt as _,kr as v,nr as y,on as ee,or as b,pt as x,rt as S,si as C,sn as w,ti as T,ui as E,vn as te,yr as D}from"./vendor-Bhf0nZ3B.js";import"./i18n-BJCOtLro.js";import{s as ne}from"./ws-client-D9IQ9580.js";import{t as re}from"./session-store-Do0MGnXu.js";import{t as O}from"./utils-sFCTikqz.js";import{D as ie,E as k,F as A,L as j,P as ae,c as M,d as N,f as P,l as oe,u as F,x as se}from"./index-BSuiEQIC.js";import{a as I,c as L,d as ce,f as le,h as R,i as ue,l as de,m as z,n as fe,o as pe,p as me,r as he,s as ge,t as _e,u as ve}from"./xyflow-Bp8EMwkC.js";var B=e(n(),1),V=r();function H(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var ye={user:{Icon:h,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-primary`,bubbleBorder:`border-transparent`,textColor:`text-primary-foreground`},assistant:{Icon:D,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:x,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:D,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:T,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function U({entry:e}){let{t:n}=C();return e.role===`error`?(0,V.jsx)(oe,{text:e.text}):e.role===`tool`?(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,V.jsx)(x,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{className:`font-mono`,children:e.tool??n(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,V.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,V.jsx)(b,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),H(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,V.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,V.jsx)(M,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,V.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,V.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.output}):(0,V.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,V.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,V.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.text})}):null,e.isError&&(0,V.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:n(`activity:watch.toolFailed`)}),e.text&&(0,V.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,V.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,V.jsx)(t,{remarkPlugins:[i],rehypePlugins:P,components:N,children:e.text})})}function be({entry:e,isContinuation:t=!1}){let{t:n}=C(),r=ye[e.role],i=r.Icon;return(0,V.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,V.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,V.jsx)(`div`,{className:O(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,V.jsx)(i,{className:`h-4 w-4`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:O(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,V.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,H(e.durationMs)]})]}),(0,V.jsx)(`div`,{className:O(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,V.jsx)(`div`,{className:O(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,V.jsx)(U,{entry:e})})}),e.text&&e.role!==`error`&&(0,V.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,V.jsx)(F,{text:e.text,label:n(`common:action.copy`)})})]})]})}var xe=[`steer`,`ask`,`assign`,`note`],W=2500;function Se({sessionId:e,limit:t=200}){let[n,r]=(0,B.useState)(null),{t:i}=C(),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(`steer`),[h,g]=(0,B.useState)(`high`),[_,v]=(0,B.useState)([]),[y,ee]=(0,B.useState)(!1),b=(0,B.useRef)(null),x=(0,B.useRef)(!0),S=(0,B.useRef)(!0),w=ie(e=>e.liveSessions),T=(0,B.useMemo)(()=>w.find(t=>t.sessionId===e),[w,e]),te=(0,B.useMemo)(()=>{let e=T;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[T]),ne=T?.status===`active`||(T?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),re=(0,B.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[T,i]),k=(0,B.useMemo)(()=>{if(!T)return null;let e=T.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??T.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[T,i]),A=(0,B.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();S.current&&(r(i),o(null))}catch(e){S.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),j=(0,B.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();S.current&&Array.isArray(n.thread)&&v(n.thread)}catch{}},[e]);(0,B.useEffect)(()=>{S.current=!0,r(null),o(null),v([]),A(),j();let e=setInterval(()=>void A(),W),t=setInterval(()=>void j(),W);return()=>{S.current=!1,clearInterval(e),clearInterval(t)}},[A,j]),(0,B.useEffect)(()=>{te&&A()},[te,A]),(0,B.useEffect)(()=>{x.current&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[n,k]);let ae=()=>{let e=b.current;e&&(x.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},M=async()=>{let t=s.trim();if(!(!t||l)){u(!0),f(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:p,priority:h})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),f(ne?E.t(`activity:sessionWatch.sentRunning`):E.t(`activity:sessionWatch.sentIdle`)),j()}catch(e){f(E.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(!1)}}},N=async()=>{if(!y){ee(!0),f(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:E.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);f(E.t(`activity:sessionWatch.interruptSent`)),j()}catch(e){f(E.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{ee(!1)}}},P=n?.entries??[];return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,V.jsx)(`span`,{className:O(`h-1.5 w-1.5 rounded-full`,ne?`bg-green-500 animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,V.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),ne&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:y,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(y?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),re&&(0,V.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,re]}),a&&(0,V.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,V.jsxs)(`div`,{ref:b,onScroll:ae,className:`min-h-0 min-w-0 flex-1 overflow-y-auto space-y-1.5 pr-1`,children:[P.length===0&&!a&&(0,V.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),P.map((e,t)=>(0,V.jsx)(be,{entry:e,isContinuation:t>0&&P[t-1].role===e.role},`${e.ts}-${t}`)),k&&(0,V.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,V.jsx)(D,{className:`h-4 w-4 animate-pulse`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:k.label}),(0,V.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,V.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[k.text,(0,V.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),_.length>0&&(0,V.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,V.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),_.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,V.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,V.jsx)(`span`,{className:O(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,V.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,V.jsx)(`span`,{className:O(`ml-1.5 text-[9px]`,e.completed?`text-green-500`:e.readByLeader?`text-cyan-500`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,V.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,V.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),title:i(`activity:sessionWatch.msgType.${p}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:xe.map(e=>(0,V.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,V.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,V.jsx)(`option`,{value:`high`,children:`high`}),(0,V.jsx)(`option`,{value:`normal`,children:`normal`}),(0,V.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,V.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,V.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),M())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${p}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void M(),disabled:l||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:l?`…`:i(`activity:sessionWatch.send`)})]}),d&&(0,V.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d}),(0,V.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}function G(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function Ce(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function we(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function Te(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function Ee(e,t=380){let n=new Map,r=Math.max(1,e.length);return e.forEach((e,i)=>{let a=(i-(r-1)/2)*t;n.set(e,600+a)}),n}function De(e,t,n){let r=Math.min(3,n),i=Math.floor(t/r),a=t%r;return{x:e-(Math.min(r,n-i*r)-1)*190/2+a*190,y:640+i*150}}function Oe(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function ke(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function K(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function Ae(e,t){let n=new Set,r=[];for(let i of e){let e=Oe(i.clientType),a=`client-${i.pid??i.sessionId}`,o=[],s=!1;for(let e of i.agents){n.add(e.id);let r=t.get(e.id),i=K(r?.status??e.status);(i===`active`||i===`streaming`)&&(s=!0),o.push({officeId:`${a}__agent-${e.id}`,serverId:e.id,name:r?.name??e.name??e.id,status:i,iteration:r?.iteration??e.iterations??0,toolCalls:r?.toolCalls??e.toolCalls??0,costUsd:r?.costUsd??e.costUsd??0,tokensIn:r?.tokensIn??e.tokensIn??0,tokensOut:r?.tokensOut??e.tokensOut??0,ctxPct:r?.ctxPct??e.ctxPct,model:r?.model??e.model,lastActivityAt:e.lastActivityAt,currentTask:r?.currentTool??r?.lastTool??e.currentTool})}let c=i.status===`closing`||i.status===`stale`?`offline`:s?`active`:`idle`;r.push({id:a,type:e,label:i.projectName||ke(e),sublabel:[ke(e),i.gitBranch?`⎇ ${i.gitBranch}`:``,i.pid?`pid ${i.pid}`:``].filter(Boolean).join(` · `),status:c,sessionId:i.sessionId,pid:i.pid,branch:i.gitBranch,workingDir:i.workingDir,startedAt:i.startedAt,agents:o})}let i=[...t.values()].filter(e=>!n.has(e.id));if(i.length>0){let e=r.find(e=>e.type===`webui`);e||(e={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},r.push(e));for(let t of i){let n=K(t.status);(n===`active`||n===`streaming`)&&(e.status=`active`),e.agents.push({officeId:`${e.id}__agent-${t.id}`,serverId:t.id,name:t.name,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTask:t.currentTool??t.lastTool})}}return r.length===0&&r.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),r}function q(e){return e.startsWith(`tool`)?`#eab308`:e.startsWith(`mailbox`)?`#06b6d4`:e.startsWith(`provider`)?`#a855f7`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`#22c55e`:e.includes(`error`)?`#ef4444`:`#6366f1`}function je(e){return Math.min(100,Math.max(0,e??0))}function J({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6;return(0,V.jsx)(`span`,{className:O(`rounded-full`,r,n>0&&`animate-pulse`,{idle:`bg-gray-500`,active:`bg-emerald-500`,streaming:`bg-blue-500`,completed:`bg-blue-500`,error:`bg-red-500`,offline:`bg-gray-600`}[e]),style:{boxShadow:n>0?`0 0 ${i}px ${{idle:`#9ca3af`,active:`#22c55e`,streaming:`#3b82f6`,completed:`#3b82f6`,error:`#ef4444`,offline:`#6b7280`}[e]}`:void 0}})}function Me(){let{t:e}=C(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:a}=ie(l(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),o=t.tui+t.webui+t.repl,s=e=>e?.toLocaleString()??`0`;return(0,V.jsxs)(`div`,{className:`absolute top-20 left-4 z-10 bg-slate-800/95 backdrop-blur border border-slate-700 rounded-lg p-3 shadow-xl`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,V.jsx)(g,{className:`h-3.5 w-3.5 text-emerald-400`}),(0,V.jsx)(`span`,{className:`text-[10px] font-bold text-gray-300 uppercase tracking-wide`,children:e(`activity:office.sessionStats`)})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(S,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.clients`)})]}),(0,V.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,V.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,V.jsx)(`span`,{className:`text-emerald-400`,children:o})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(x,{className:`h-2.5 w-2.5 text-emerald-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:`TUI`}),(0,V.jsx)(`span`,{className:`text-emerald-400 font-mono`,children:t.tui})]}),t.webui>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(p,{className:`h-2.5 w-2.5 text-blue-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:`WebUI`}),(0,V.jsx)(`span`,{className:`text-blue-400 font-mono`,children:t.webui})]}),t.repl>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(x,{className:`h-2.5 w-2.5 text-amber-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:`REPL`}),(0,V.jsx)(`span`,{className:`text-amber-400 font-mono`,children:t.repl})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(D,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.agents`)})]}),(0,V.jsxs)(`span`,{className:`text-gray-200 font-mono`,children:[i,` `,(0,V.jsx)(`span`,{className:`text-gray-500`,children:`/`}),` `,(0,V.jsx)(`span`,{className:`text-cyan-400`,children:r})]})]}),n.model&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(y,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.model`)})]}),(0,V.jsx)(`span`,{className:`text-cyan-400 font-mono truncate max-w-[120px]`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(d,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:officeMap.mode`)})]}),(0,V.jsx)(`span`,{className:O(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-purple-500/20 text-purple-400`,n.mode===`suggest`&&`bg-blue-500/20 text-blue-400`,n.mode===`off`&&`bg-gray-500/20 text-gray-400`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-gray-500/20 text-gray-400`),children:n.mode})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(u,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.toolCallsLabel`)})]}),(0,V.jsx)(`span`,{className:`text-yellow-400 font-mono`,children:s(a.toolCalls)})]}),(0,V.jsxs)(`div`,{className:`border-t border-slate-700 pt-1.5 mt-1.5 space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`IN`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.input`)})]}),(0,V.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:s(a.tokensIn)})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-gray-500 text-[8px]`,children:`OUT`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.output`)})]}),(0,V.jsx)(`span`,{className:`text-gray-300 font-mono text-[9px]`,children:s(a.tokensOut)})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4 border-t border-slate-700 pt-1.5 mt-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(c,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.cost`)})]}),(0,V.jsx)(`span`,{className:`text-emerald-400 font-mono font-medium`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(a.costUsd)})]})]})]})}function Y(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(I,{type:`target`,position:z.Top,style:e,isConnectable:!1}),(0,V.jsx)(I,{type:`source`,position:z.Bottom,style:e,isConnectable:!1})]})}function X({data:e}){let{t}=C();return(0,V.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-white/5 pt-1.5 text-[8px] text-gray-500`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`font-mono text-gray-300`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,V.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:we(e.startedAt,Date.now())})})]})}function Ne({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,o=e.color||`#3b82f6`;return(0,V.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-blue-500/20`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5 opacity-60`,!n&&!r&&!i&&`border-blue-500/30 bg-blue-500/10`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,V.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-blue-500/20`:`bg-blue-500/10`),children:(0,V.jsx)(p,{className:`h-5 w-5`,style:{color:o}})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:o},children:e.label}),(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.webuiClient`)})]}),(0,V.jsx)(J,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,V.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,V.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:i?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(m,{className:`h-3 w-3 text-gray-500`}),(0,V.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(a,{className:`h-3 w-3 text-emerald-500`}),(0,V.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,V.jsx)(`div`,{className:`mt-2 h-1 rounded-full bg-blue-500/30 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full bg-blue-500 animate-pulse`,style:{width:`60%`}})}),(0,V.jsx)(X,{data:e})]})}function Z({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||`#22c55e`;return(0,V.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-emerald-500/20`,r&&`border-red-500/50 bg-red-500/10`,!n&&!r&&`border-emerald-500/30 bg-emerald-500/10`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,V.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-emerald-500/20`:`bg-emerald-500/10`),children:(0,V.jsx)(x,{className:`h-5 w-5`,style:{color:i}})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.tuiClient`)})]}),(0,V.jsx)(J,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,V.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-2 truncate`,children:e.sublabel}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-gray-500`,children:[(0,V.jsx)(x,{className:`h-3 w-3 text-emerald-500`}),(0,V.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,V.jsx)(X,{data:e})]})}function Pe({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#f59e0b`;return(0,V.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-amber-500/20`,!n&&`border-amber-500/30 bg-amber-500/10`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,V.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-amber-500/20`:`bg-amber-500/10`),children:(0,V.jsx)(x,{className:`h-5 w-5`,style:{color:r}})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:t(`activity:office.repl`)})]}),(0,V.jsx)(J,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,V.jsx)(`div`,{className:`text-[10px] text-gray-400 mb-1 truncate`,children:e.sublabel}),(0,V.jsx)(X,{data:e})]})}function Fe({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.color||`#a855f7`;return(0,V.jsxs)(`div`,{className:`rounded-xl border-2 p-4 min-w-[200px] transition-all backdrop-blur-sm relative bg-slate-900/90`,children:[(0,V.jsx)(Y,{}),(0,V.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-purple-600 text-white text-[9px] rounded-full font-bold`,children:t(`activity:office.coordinator`)}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,V.jsx)(`div`,{className:O(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-purple-500/20`:`bg-purple-500/10`),children:(0,V.jsx)(y,{className:`h-6 w-6`,style:{color:r}})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,V.jsx)(J,{status:e.status,activity:e.vizActivity??0})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsxs)(`div`,{className:`font-mono`,children:[(0,V.jsx)(`span`,{className:`text-emerald-400`,children:e.agentsActive||0}),(0,V.jsx)(`span`,{className:`text-gray-500`,children:` / `}),(0,V.jsx)(`span`,{className:`text-purple-400`,children:e.agentsTotal||0})]}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:officeMap.agents`)})]}),(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsx)(`div`,{className:`font-mono text-yellow-400`,children:(e.toolCalls||0).toLocaleString()}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.toolCallsLabel`)})]}),(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsx)(`div`,{className:`font-mono text-gray-300`,children:G(e.tokensIn)}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.tokensLabel`)})]}),(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsxs)(`div`,{className:`font-mono text-emerald-400`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.cost`)})]})]}),n&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-purple-400`,children:[(0,V.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-purple-400 animate-pulse`}),t(`activity:office.coordinatingFleet`)]})]})}function Ie({data:e}){let{t}=C(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||`#06b6d4`,o=je(e.ctxPct);return(0,V.jsxs)(`div`,{className:O(`rounded-lg border p-3 min-w-[150px] transition-all backdrop-blur-sm`,n&&`border-cyan-500/50 bg-cyan-500/10 shadow-lg shadow-cyan-500/10`,r&&`border-red-500/50 bg-red-500/10`,i&&`border-gray-500/30 bg-gray-500/5`,!n&&!r&&!i&&`border-cyan-500/30 bg-cyan-500/10`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,V.jsx)(D,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,V.jsx)(`div`,{className:`text-[8px] text-gray-500 truncate`,children:Te(e.model)})]}),(0,V.jsx)(J,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-cyan-300/90 truncate mb-1.5`,children:[(0,V.jsx)(`span`,{className:O(`w-1.5 h-1.5 rounded-full bg-cyan-400 shrink-0`,n&&`animate-pulse`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.currentTask})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[9px] mb-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`iter`}),(0,V.jsx)(`span`,{className:`text-gray-300 font-mono`,children:e.iteration||0})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`tools`}),(0,V.jsx)(`span`,{className:`text-yellow-400/90 font-mono`,children:e.toolCalls||0})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`tok`}),(0,V.jsx)(`span`,{className:`text-gray-300 font-mono`,children:G((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`cost`}),(0,V.jsxs)(`span`,{className:`text-emerald-400/90 font-mono`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,V.jsxs)(`div`,{className:`mb-1`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-[8px] text-gray-500 mb-0.5`,children:[(0,V.jsx)(`span`,{children:`ctx`}),(0,V.jsxs)(`span`,{className:O(`font-mono`,o>=90?`text-red-400`:o>=70?`text-amber-400`:`text-gray-400`),children:[o,`%`]})]}),(0,V.jsx)(`div`,{className:`h-1 rounded-full bg-slate-700/60 overflow-hidden`,children:(0,V.jsx)(`div`,{className:O(`h-full`,o>=90?`bg-red-500`:o>=70?`bg-amber-500`:`bg-cyan-500`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,V.jsxs)(`div`,{className:O(`flex items-center gap-1 text-[8px]`,n?`text-gray-600`:`text-gray-500`),children:[i&&(0,V.jsx)(`span`,{className:`text-emerald-500/70`,children:t(`activity:office.donePrefix`)}),r&&(0,V.jsx)(`span`,{className:`text-red-400/80`,children:t(`activity:office.failedPrefix`)}),(0,V.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:Ce(e.lastActivityAt,Date.now())})})]})]})}function Le({data:e}){let{t}=C();return(0,V.jsxs)(`div`,{className:O(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-gray-600 bg-gray-800/30`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,V.jsx)(v,{className:`h-4 w-4 text-gray-600`}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500 truncate`,children:e.label})}),(0,V.jsx)(J,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,V.jsx)(`div`,{className:`text-[9px] text-gray-600`,children:t(`activity:office.availableDesk`)})]})}function Q({data:e}){let{t}=C(),n=e.color||`#eab308`,r=(e.unreadCount||0)>0;return(0,V.jsxs)(`div`,{className:O(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,r&&`border-yellow-500/50 bg-yellow-500/10 shadow-lg shadow-yellow-500/10`,!r&&`border-yellow-500/30 bg-yellow-500/5`),children:[(0,V.jsx)(Y,{}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,V.jsx)(`div`,{className:O(`flex items-center justify-center w-10 h-10 rounded-lg`,r?`bg-yellow-500/20`:`bg-yellow-500/10`),children:(0,V.jsx)(w,{className:`h-5 w-5`,style:{color:n}})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:r?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),r&&(0,V.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-yellow-500 text-black text-[10px] font-bold flex items-center justify-center`,children:e.unreadCount})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-yellow-400`,children:[(0,V.jsx)(_,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{children:e.messageCount||0})]}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.total`)})]}),(0,V.jsxs)(`div`,{className:`bg-black/20 rounded p-1.5 text-center`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-emerald-400`,children:[(0,V.jsx)(o,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{children:e.unreadCount||0})]}),(0,V.jsx)(`div`,{className:`text-gray-500`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,V.jsxs)(`div`,{className:`mt-2 truncate border-t border-white/5 pt-1.5 text-[9px] text-gray-400`,children:[`✉ `,e.sublabel]})]})}var Re={webui:Ne,tui:Z,repl:Pe,coordinator:Fe,agent:Ie,mailbox:Q,desk:Le},ze={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||`#6366f1`,l=k(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=R({sourceX:e,sourceY:t,sourcePosition:i??z.Bottom,targetX:n,targetY:r,targetPosition:a??z.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,V.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,V.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,V.jsx)(ue,{children:(0,V.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none rounded-full border border-white/15 bg-slate-800/90 px-1.5 py-0.5 text-[8px] font-medium text-white/85 backdrop-blur-sm`,children:o.label})})]})}};function Be({events:e,now:t}){let{t:n}=C(),r=e.slice(0,14);return(0,V.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,V.jsxs)(`div`,{className:`pointer-events-auto rounded-lg bg-slate-900/85 border border-slate-700/70 backdrop-blur px-3 py-2 max-w-3xl mx-auto`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5 text-[10px] uppercase tracking-wide text-cyan-400/80`,children:[(0,V.jsx)(g,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,V.jsx)(`div`,{className:`text-[11px] text-gray-500 italic`,children:n(`activity:office.waitingActivity`)}):(0,V.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,V.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:q(e.kind)}}),(0,V.jsx)(`span`,{className:`text-gray-300 truncate flex-1`,children:e.label}),(0,V.jsx)(`span`,{className:`text-gray-600 shrink-0 tabular-nums`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function $(){let{t:e}=C(),{fitView:t}=me(),n=ne(e=>e.events),r=A(e=>e.agents),i=A(e=>e.agentTranscripts),a=A(e=>e.leaderId),o=ie(e=>e.liveSessions),c=j(e=>e.messages),l=re(e=>e.session),u=(0,B.useMemo)(()=>Ae(o,r),[o,r]),d=k(e=>e.showHud),m=k(e=>e.showLegend),h=k(e=>e.showMinimap),g=k(e=>e.showControls),v=k(e=>e.showFeed),b=k(e=>e.setShowFeed),S=k(e=>e.background),[T,E,M]=le([]),[N,P,oe]=ce([]),[F,I]=(0,B.useState)(null),[L,R]=(0,B.useState)(null),[ue,z]=(0,B.useState)(!1),[H,ye]=(0,B.useState)(``),[U,be]=(0,B.useState)(!1),[xe,W]=(0,B.useState)(null),Oe=(0,B.useMemo)(()=>{if(F?.data.kind!==`agent`)return ae;let e=F.data.serverId??(F.id.includes(`__agent-`)?F.id.split(`__agent-`).pop():F.id.replace(/^agent-/,``));return e?i.get(e)??ae:ae},[i,F]),K=(0,B.useCallback)(async()=>{let e=H.trim();if(!(!e||U)){be(!0),W(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();ye(``),W(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){W(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{be(!1)}}},[H,U]),q=(0,B.useRef)(new Map),J=4e3,Y=(0,B.useRef)(new Map),X=(0,B.useRef)(new Map),Ne=(0,B.useRef)(new Map),Z=(0,B.useRef)(new Map),Pe=(0,B.useRef)(``);(0,B.useEffect)(()=>{let n=[],i=[],o=Date.now(),s=Math.max(1,...u.map(e=>e.agents.length||1)),l=Math.max(380,Math.min(3,s)*190+80),d=Ee(u.map(e=>e.id),l),f=c.filter(e=>!e.completed&&(e.readByCount??0)===0).length,p=c.length?[...c].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:f>0?`active`:`idle`,unreadCount:f,messageCount:c.length,sublabel:p?`${p.from} → ${p.to}: ${p.subject}`:void 0,color:`#eab308`}});let m=0,h=0,g=0,_=0,v=0;for(let e of u)for(let t of e.agents)h+=1,(t.status===`active`||t.status===`streaming`)&&(m+=1),g+=t.toolCalls,_+=t.costUsd,v+=t.tokensIn+t.tokensOut;let y=a?r.get(a):null,ee=m>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:u.length}),kind:`coordinator`,status:y?.status===`failed`?`error`:ee?`active`:`idle`,connections:u.length,agentsActive:m,agentsTotal:h,toolCalls:g,costUsd:_,tokensIn:v,color:`#a855f7`}});let b={tui:`#22c55e`,webui:`#3b82f6`,repl:`#f59e0b`};for(let t of u){let r=d.get(t.id)??600,a=b[t.type],s=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:r,y:370},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:a}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:s,data:{color:a,animated:s,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:f>0,data:{color:`#eab308`,animated:f>0,label:f>0?`${f}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:r,y:640},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:`#374151`}});continue}t.agents.forEach((a,s)=>{let c=a.status===`active`||a.status===`streaming`,l=Z.current.get(a.serverId);if(l&&(a.toolCalls>l.toolCalls||a.iteration>l.iteration)||c){q.current.set(a.officeId,o+J);let e=X.current.get(a.officeId)??0;X.current.set(a.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${a.officeId}`,`${t.id}->coordinator`]){let t=Y.current.get(e)??0;Y.current.set(e,Math.min(1,t+.5))}}Z.current.set(a.serverId,{toolCalls:a.toolCalls,iteration:a.iteration}),n.push({id:a.officeId,type:`agent`,position:De(r,s,t.agents.length),data:{label:a.name,kind:`agent`,status:a.status,serverId:a.serverId,sessionId:t.sessionId,currentTask:a.currentTask,iteration:a.iteration,toolCalls:a.toolCalls,costUsd:a.costUsd,tokensIn:a.tokensIn,tokensOut:a.tokensOut,ctxPct:a.ctxPct,model:a.model,lastActivityAt:a.lastActivityAt,color:`#06b6d4`}}),i.push({id:`${t.id}->${a.officeId}`,source:t.id,target:a.officeId,type:`wire`,animated:c,data:{color:`#06b6d4`,animated:c,label:c?a.currentTask??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(u.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...Z.current.keys()])x.has(e)||Z.current.delete(e);let S=n.map(e=>{let t=q.current.get(e.id),n=X.current.get(e.id)??0;return t&&t>o&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),C=i.map(e=>{let t=Y.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});Ne.current=w,E(S),P(C);let T=S.map(e=>e.id).sort().join(`|`);if(T!==Pe.current){Pe.current=T;let e=setTimeout(()=>t({padding:.2,duration:300}),50);return()=>clearTimeout(e)}},[u,a,r,c,l,J,E,P,t]);let Fe=u.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),Ie=u.map(e=>e.id),Le=new Map;for(let e of Fe)(!Le.has(e.serverId)||e.clientType===`webui`)&&Le.set(e.serverId,e.officeId);function Q(e){return Le.get(e)??`agent-${e}`}function $(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Ve(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?Ie.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=Q(e.target??e.source);return{nodes:[t],edges:[$(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:Fe.map(e=>$(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=Q(e.source);return{nodes:[t],edges:[$(t)],status:`streaming`}}case`agent:status`:{let t=Q(e.source);return{nodes:[`coordinator`,t],edges:[$(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[Q(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,Q(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[Q(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=Q(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,B.useEffect)(()=>{if(n.length===0)return;let e=n[0];if(!e)return;let{nodes:t,edges:r,status:i}=Ve(e),a=Date.now();t.length>0&&(t.forEach(e=>{q.current.set(e,a+J);let t=X.current.get(e)??0;X.current.set(e,Math.min(1,t+(1-t)*.5))}),E(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:i,vizActivity:X.current.get(e.id)??0}}:e))),r.length>0&&(r.forEach(e=>{let t=Y.current.get(e)??0;Y.current.set(e,Math.min(1,t+.5))}),P(e=>e.map(e=>r.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:Y.current.get(e.id)??1}}:e)))},[n,E,P,J,r]),(0,B.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of Y.current){let i=r*.85;i<.05?(Y.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(Y.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&P(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,animated:n.animated,data:{...t.data,animated:n.animated,intensity:n.intensity}}:t}));let n=new Map,r=!1;for(let[e,t]of X.current){let i=t*.9;i<.03?(X.current.delete(e),n.set(e,0),r=!0):(X.current.set(e,i),n.set(e,i),r=!0)}r&&E(e=>e.map(e=>{let t=n.get(e.id);return t===void 0?e:{...e,data:{...e.data,vizActivity:t}}}))},1e3);return()=>clearInterval(e)},[P,E]);let He=(0,B.useCallback)(e=>P(t=>de({...e,type:`wire`},t)),[P]),Ue=(0,B.useCallback)((e,t)=>{I(t)},[]),We=(0,B.useCallback)(()=>{I(null)},[]);(0,B.useEffect)(()=>{if(!L)return;let e=e=>{e.key===`Escape`&&R(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[L]);let Ge=(0,B.useCallback)(()=>{E(e=>e.map(e=>{let t=Ne.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:.2,duration:300}),50)},[E,t]),[,Ke]=(0,B.useState)(0);return(0,B.useEffect)(()=>{let e=setInterval(()=>Ke(e=>e+1),2e3);return()=>clearInterval(e)},[]),(0,V.jsxs)(`div`,{className:`w-full h-full bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 relative overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
2
|
-
linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
|
|
3
|
-
linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
|
|
4
|
-
`,backgroundSize:`40px 40px`}}),d&&(0,V.jsx)(Me,{}),(0,V.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,V.jsx)(`div`,{className:`bg-slate-800/90 backdrop-blur px-4 py-2 rounded-lg border border-slate-700 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-xs font-bold text-slate-300 flex items-center gap-2`,children:[(0,V.jsx)(f,{className:`h-4 w-4 text-purple-400`}),e(`activity:office.fleetHq`),(0,V.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse ml-2`}),(0,V.jsx)(`span`,{className:`text-[10px] text-gray-400 font-normal`,children:e(`activity:office.live`)})]})})}),m&&(0,V.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,V.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendStatus`)}),(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-pulse`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendActive`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-gray-500`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendIdle`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-red-500 animate-pulse`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendError`)})]})]})]}),m&&(0,V.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 bg-slate-800/90 backdrop-blur rounded-lg border border-slate-700 p-3 text-[10px]`,children:[(0,V.jsx)(`div`,{className:`font-bold text-gray-300 mb-2`,children:e(`activity:office.legendConnections`)}),(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-yellow-400`,children:`✉`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendMail`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-purple-400`,children:`→`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendTask`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-emerald-400`,children:`●`}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:e(`activity:office.legendStatusConn`)})]})]})]}),(0,V.jsxs)(ve,{nodes:T,edges:N,onNodesChange:M,onEdgesChange:oe,onConnect:He,onNodeClick:Ue,onPaneClick:We,nodeTypes:Re,edgeTypes:ze,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,V.jsxs)(ge,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:Ge,title:e(`activity:office.arrangeTitle`),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-slate-800/90 border border-slate-700 text-xs text-slate-200 hover:bg-slate-700 transition-colors`,children:[(0,V.jsx)(te,{className:`h-3.5 w-3.5`}),e(`activity:office.arrange`)]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>b(!v),title:e(`activity:office.feedTitle`),className:O(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,v?`bg-cyan-500/20 border-cyan-500/40 text-cyan-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,V.jsx)(s,{className:`h-3.5 w-3.5`}),e(`activity:office.feed`)]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>z(e=>!e),title:e(`activity:office.broadcastTitle`),className:O(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,ue?`bg-amber-500/20 border-amber-500/40 text-amber-300`:`bg-slate-800/90 border-slate-700 text-slate-300 hover:bg-slate-700`),children:[(0,V.jsx)(_,{className:`h-3.5 w-3.5`}),e(`activity:office.broadcast`)]})]}),S!==`none`&&(0,V.jsx)(_e,{variant:S===`lines`?fe.Lines:S===`cross`?fe.Cross:fe.Dots,gap:20,size:1,color:`rgba(255,255,255,0.05)`}),g&&(0,V.jsx)(he,{className:`bg-slate-800 border border-slate-700 rounded-lg [&>button]:bg-slate-700 [&>button]:text-slate-200`}),h&&(0,V.jsx)(pe,{className:`bg-slate-800/90 border border-slate-700 rounded-lg`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return`#a855f7`;case`webui`:return`#3b82f6`;case`tui`:return`#22c55e`;case`repl`:return`#f59e0b`;case`mailbox`:return`#eab308`;case`agent`:return`#06b6d4`;default:return`#6366f1`}},maskColor:`rgba(0,0,0,0.8)`})]}),v&&(0,V.jsx)(Be,{events:n,now:Date.now()}),ue&&(0,V.jsxs)(`div`,{className:`absolute top-16 right-4 z-30 w-80 rounded-lg border border-amber-500/40 bg-slate-900/97 p-3 shadow-2xl backdrop-blur`,children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-amber-300`,children:[(0,V.jsx)(_,{className:`h-3.5 w-3.5`}),` `,e(`activity:office.broadcastToAll`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`text-gray-400 hover:text-white text-base leading-none`,children:`×`})]}),(0,V.jsx)(`textarea`,{value:H,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),K())},rows:3,placeholder:e(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-slate-700 bg-slate-900/70 px-2 py-1 text-[11px] text-gray-200 placeholder:text-gray-600 focus:border-amber-500/50 focus:outline-none`}),(0,V.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-[9px] text-gray-600`,children:e(`activity:office.broadcastSendHint`)}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void K(),disabled:U||!H.trim(),className:`rounded-md border border-amber-500/40 bg-amber-500/20 px-2.5 py-1 text-[11px] text-amber-200 transition-colors hover:bg-amber-500/30 disabled:cursor-not-allowed disabled:opacity-40`,children:U?`…`:e(`activity:office.broadcast`)})]}),xe&&(0,V.jsx)(`div`,{className:`mt-1 text-[10px] text-gray-400`,children:xe})]}),F&&(0,V.jsxs)(`div`,{className:O(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,F.data.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:F.data.sessionId?`w-80`:`w-64`),children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F.data.kind===`webui`&&(0,V.jsx)(p,{className:`h-4 w-4 text-blue-500`}),F.data.kind===`tui`&&(0,V.jsx)(x,{className:`h-4 w-4 text-emerald-500`}),F.data.kind===`coordinator`&&(0,V.jsx)(y,{className:`h-4 w-4 text-purple-500`}),F.data.kind===`agent`&&(0,V.jsx)(D,{className:`h-4 w-4 text-cyan-500`}),F.data.kind===`mailbox`&&(0,V.jsx)(w,{className:`h-4 w-4 text-yellow-500`}),(0,V.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:F.data.label})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[F.data.sessionId&&(0,V.jsx)(`button`,{type:`button`,title:e(`activity:office.openFullView`),onClick:()=>R({sessionId:F.data.sessionId,label:F.data.label}),className:`text-muted-foreground hover:text-primary`,children:(0,V.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,V.jsx)(`button`,{onClick:We,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(()=>{let t=F.data,n=Date.now(),r=({k:e,v:t,accent:n})=>(0,V.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,V.jsx)(`span`,{className:O(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]}),i=t.kind===`agent`,a=t.kind===`webui`||t.kind===`tui`||t.kind===`repl`,o=(t.tokensIn||0)+(t.tokensOut||0),s=je(t.ctxPct);return(0,V.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,V.jsx)(r,{k:`Status`,v:String(t.status).toUpperCase(),accent:O(t.status===`active`&&`text-emerald-600 dark:text-emerald-400`,t.status===`streaming`&&`text-blue-600 dark:text-blue-400`,t.status===`error`&&`text-destructive`,t.status===`idle`&&`text-muted-foreground`,t.status===`offline`&&`text-muted-foreground/50`)}),i&&(0,V.jsxs)(V.Fragment,{children:[t.model&&(0,V.jsx)(r,{k:`Model`,v:Te(t.model),accent:`text-cyan-600 dark:text-cyan-400`}),t.currentTask&&(0,V.jsx)(r,{k:`Tool`,v:t.currentTask,accent:`text-cyan-600 dark:text-cyan-400`}),(0,V.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-cyan-600 dark:text-cyan-400`}),(0,V.jsx)(r,{k:`Tool calls`,v:t.toolCalls||0,accent:`text-amber-600 dark:text-amber-400`}),(0,V.jsx)(r,{k:`Tokens in`,v:G(t.tokensIn)}),(0,V.jsx)(r,{k:`Tokens out`,v:G(t.tokensOut)}),(0,V.jsx)(r,{k:`Tokens total`,v:G(o)}),s>0&&(0,V.jsx)(r,{k:`Context`,v:`${s}%`,accent:s>=90?`text-destructive`:s>=70?`text-amber-600 dark:text-amber-400`:`text-foreground/70`}),(0,V.jsx)(r,{k:`Cost`,v:`$${(t.costUsd||0).toFixed(4)}`,accent:`text-emerald-600 dark:text-emerald-400`}),t.lastActivityAt&&(0,V.jsx)(r,{k:`Last seen`,v:Ce(t.lastActivityAt,n),accent:`text-muted-foreground`}),(0,V.jsx)(`div`,{className:`pt-2`,children:(0,V.jsx)(se,{entries:Oe,agentName:t.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),a&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(r,{k:`Surface`,v:ke(t.kind),accent:`text-foreground/80`}),t.branch&&(0,V.jsx)(r,{k:`Branch`,v:`⎇ ${t.branch}`,accent:`text-foreground/70`}),t.pid!=null&&(0,V.jsx)(r,{k:`PID`,v:t.pid}),t.workingDir&&(0,V.jsx)(r,{k:`Dir`,v:t.workingDir,accent:`text-muted-foreground`}),(0,V.jsx)(r,{k:`Agents`,v:t.agentCount??0,accent:`text-cyan-600 dark:text-cyan-400`}),t.startedAt&&(0,V.jsx)(r,{k:`Uptime`,v:we(t.startedAt,n),accent:`text-foreground/70`})]}),t.kind===`mailbox`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(r,{k:`Total messages`,v:t.messageCount||0,accent:`text-amber-600 dark:text-amber-400`}),(0,V.jsx)(r,{k:`Unread`,v:t.unreadCount||0,accent:`text-amber-600 dark:text-amber-400`}),c.length>0&&(0,V.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.recent`)}),[...c].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(t=>(0,V.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,V.jsx)(`span`,{className:O(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!t.completed&&(t.readByCount??0)===0?`bg-amber-500`:t.completed?`bg-emerald-500`:`bg-muted`)}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate text-foreground/80`,children:t.subject||e(`activity:office.noSubject`)}),(0,V.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[t.from,` → `,t.to,` · `,Ce(t.timestamp,n)]})]})]},t.id))]})]}),t.kind===`coordinator`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(r,{k:`Connections`,v:t.connections||0,accent:`text-purple-600 dark:text-purple-400`}),(0,V.jsx)(r,{k:`Iterations`,v:t.iteration||0,accent:`text-purple-600 dark:text-purple-400`})]}),(i||a)&&t.sessionId&&(0,V.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,V.jsx)(Se,{sessionId:t.sessionId})})]})})()]}),L&&(0,V.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,V.jsx)(D,{className:`h-4 w-4 text-primary shrink-0`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:L.label}),(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:office.fullOperationStream`)})]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>R(null),title:e(`activity:office.closeEsc`),className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,V.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,V.jsx)(Se,{sessionId:L.sessionId,limit:500})})]})]})}function Ve(){return(0,V.jsx)(L,{children:(0,V.jsx)($,{})})}export{Ve as OfficeMapPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{m as t,p as n}from"./markdown-D0X23O-i.js";import{Br as r,Fr as i,Lt as ee,St as te,Z as ne,Zt as a,fr as o,gr as s,hr as c,it as l,jt as re,mt as u,si as d,yr as f}from"./vendor-Bhf0nZ3B.js";import"./i18n-BJCOtLro.js";import{t as p}from"./utils-sFCTikqz.js";import{A as m,C as ie,a as ae,i as h,o as g,p as _,w as oe}from"./index-BSuiEQIC.js";import{c as se,t as v}from"./SddFlowGraph-WW0qCx0t.js";var y=e(t(),1),b=n(),x={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},S=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function C({onClose:e}){let{t}=d(),{client:n}=ie(),l=m(e=>e.snapshot),f=m(e=>e.agentText),C=m(e=>e.error),E=m(e=>e.startedRunId),D=m(e=>e.setStartedRunId),[O,ce]=(0,y.useState)(``),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(!1),[N,le]=(0,y.useState)(!0),[P,ue]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)(void 0),[z,B]=(0,y.useState)(void 0),[V,H]=(0,y.useState)([]),[U,de]=(0,y.useState)(4),[W,fe]=(0,y.useState)(!0),G=g(F),K=(0,y.useCallback)(e=>n?.send?.(e),[n]),q=(0,y.useRef)(null);(0,y.useEffect)(()=>{K({type:`sdd.spec.get`})},[K]),(0,y.useEffect)(()=>{q.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[l?.answers.length??0,f]),(0,y.useEffect)(()=>{E&&(oe(`sddboard`),D(null))},[E,D]);let J=l?.busy??!1,Y=l?.phase??`idle`,X=!!l;(0,y.useEffect)(()=>{X&&M(!1)},[X]);let pe=l?.answers[l.answers.length-1]?.question??``,me=!!l&&(l.taskCount>0||!!l.graphId||Y===`task_review`||Y===`executing`),Z=()=>{let e=O.trim();!e||J||j||(M(!0),K({type:`sdd.spec.start`,payload:{goal:e}}))},Q=()=>{let e=k.trim();!e||J||(K({type:`sdd.spec.message`,payload:{text:e}}),A(``))},he=()=>!J&&K({type:`sdd.spec.approve`,payload:{}}),ge=()=>{K({type:`sdd.run.start`,payload:{parallelSlots:U,worktrees:W,...L?{model:L,provider:z}:{},...V.length?{fallbackModels:V}:{}}}),I(!1)},$=(0,y.useMemo)(()=>(l?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[l?.board]),_e=$.length>0;return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,b.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(i,{className:`h-5 w-5 text-violet-400`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h1`,{className:`text-lg font-semibold`,children:l?.title||t(`activity:sddWizard.titleFallback`)}),X&&(0,b.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`activity:sddWizard.${x[Y]??`phaseStart`}`),Y===`questioning`&&` · ${t(`activity:sddWizard.questionsSuffix`,{cur:l?.questionCount??0,max:l?.maxQuestions??0})}`,l&&l.taskCount>0?` · ${t(`activity:sddWizard.tasksSuffix`,{count:l.taskCount})}`:``]})]}),J&&(0,b.jsx)(r,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[me&&(0,b.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>I(e=>!e),title:t(`activity:sddWizard.runCfgTitle`),className:p(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,L||V.length?`border-violet-500/40 bg-violet-500/10 text-violet-600 dark:text-violet-300`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,b.jsx)(te,{className:`h-3.5 w-3.5`}),L||t(`activity:sddWizard.modelsLabel`)]}),(0,b.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1 rounded-md bg-emerald-500/15 px-2.5 py-1 text-xs font-medium text-emerald-700 hover:bg-emerald-500/25 dark:text-emerald-400`,children:[(0,b.jsx)(ee,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddWizard.startRun`)]}),F&&(0,b.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,b.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.defaultWorkerModel`)}),(0,b.jsx)(ae,{value:L,provider:z,candidates:G,placeholder:t(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:t(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{R(e),B(t)},onReset:L?()=>{R(void 0),B(void 0)}:void 0}),(0,b.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.fallbackChain`)}),(0,b.jsx)(h,{value:V,candidates:G,onChange:H}),(0,b.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:t(`activity:sddWizard.appliesToAll`)}),(0,b.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,b.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.parallelAgents`)}),(0,b.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:U,onChange:e=>{let t=Number.parseInt(e.target.value,10);de(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-violet-500`})]}),(0,b.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`activity:sddWizard.isolateWorktrees`)}),(0,b.jsx)(`input`,{type:`checkbox`,checked:W,onChange:e=>fe(e.target.checked),className:`h-3.5 w-3.5 accent-violet-500`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(W?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)})]})]}),(0,b.jsx)(_,{variant:`ghost`,size:`icon`,onClick:e,children:(0,b.jsx)(ne,{className:`h-4 w-4`})})]})]}),X&&(0,b.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:S.map((e,n)=>{let r=e===Y,i=S.indexOf(Y)>n;return(0,b.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,b.jsxs)(`span`,{className:p(`rounded-full px-2 py-0.5`,r?`bg-violet-500/20 text-violet-600 dark:text-violet-300`:i?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`),children:[i&&(0,b.jsx)(s,{className:`mr-0.5 inline h-3 w-3`}),t(`activity:sddWizard.${x[e]}`)]}),n<S.length-1&&(0,b.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`})]},e)})}),(0,b.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:[C&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/5 p-2 text-xs text-red-300`,children:C}),X?(0,b.jsxs)(`div`,{className:`space-y-4`,children:[_e&&(0,b.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-violet-500/20 bg-[#0a0d14]`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>le(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-white/5 px-3 py-1.5 text-[11px] font-medium text-violet-300 hover:bg-white/5`,children:[N?(0,b.jsx)(c,{className:`h-3.5 w-3.5`}):(0,b.jsx)(o,{className:`h-3.5 w-3.5`}),(0,b.jsx)(a,{className:`h-3.5 w-3.5`}),t(`activity:sddWizard.taskGraphSummary`,{count:l?.taskCount??0}),(0,b.jsx)(`span`,{className:`ml-auto text-slate-500`,children:t(N?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),N&&(0,b.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,b.jsx)(v,{tasks:$,columns:l?.board?.columns??[]})})]}),(0,b.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[l?.goal&&(0,b.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,b.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3 w-3`}),` `,t(`activity:sddWizard.goalLabel`)]}),(0,b.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:l.goal})]}),l?.answers.length||f&&Y===`questioning`||J?(0,b.jsxs)(`div`,{className:`space-y-2.5`,children:[l?.answers.map((e,t)=>(0,b.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,b.jsx)(T,{role:`assistant`,text:e.question}),(0,b.jsx)(T,{role:`user`,text:e.answer})]},t)),f&&Y===`questioning`&&f!==pe&&(0,b.jsx)(T,{role:`assistant`,text:f}),J&&(0,b.jsx)(T,{role:`assistant`,text:``,thinking:!0})]}):null,l?.spec&&(0,b.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,b.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,b.jsx)(i,{className:`h-3.5 w-3.5 text-violet-400`}),l.spec.title]}),(0,b.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:l.spec.overview}),(0,b.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:l.spec.requirements.map((e,t)=>(0,b.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,b.jsx)(`span`,{className:p(`shrink-0 font-mono uppercase`,se(e.priority).text),children:e.priority[0]}),(0,b.jsx)(`span`,{children:e.description})]},t))})]}),f&&(Y===`implementation`||Y===`task_review`)&&(0,b.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>ue(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[P?(0,b.jsx)(c,{className:`h-3.5 w-3.5`}):(0,b.jsx)(o,{className:`h-3.5 w-3.5`}),(0,b.jsx)(i,{className:`h-3.5 w-3.5 text-violet-400`}),` `,t(`activity:sddWizard.implementationPlan`)]}),P&&(0,b.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,b.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:w(f)})})]}),f&&Y!==`questioning`&&Y!==`implementation`&&Y!==`task_review`&&!l?.spec&&(0,b.jsx)(T,{role:`assistant`,text:f}),(Y===`spec_review`||Y===`implementation`||Y===`task_review`)&&(0,b.jsxs)(_,{variant:`secondary`,onClick:he,disabled:J,children:[(0,b.jsx)(s,{className:`mr-1.5 h-4 w-4`}),t(Y===`spec_review`?`activity:sddWizard.approveSpec`:Y===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,b.jsx)(`div`,{ref:q})]})]}):(0,b.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,b.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:t(`activity:sddWizard.goalPrompt`)}),(0,b.jsx)(`textarea`,{id:`sdd-goal`,value:O,onChange:e=>ce(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Z()},rows:4,placeholder:t(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-violet-500`}),(0,b.jsx)(_,{className:`mt-3`,onClick:Z,disabled:!O.trim()||j,children:j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,t(`activity:sddWizard.startingInterview`)]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i,{className:`mr-1.5 h-4 w-4`}),` `,t(`activity:sddWizard.startInterview`)]})}),(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t(`activity:sddWizard.introBody`)})]})]}),X&&Y!==`executing`&&Y!==`done`&&(0,b.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,b.jsx)(`textarea`,{value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Q())},rows:1,placeholder:t(Y===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:J,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-violet-500 disabled:opacity-50`}),(0,b.jsx)(_,{size:`icon`,onClick:Q,disabled:J||!k.trim(),children:(0,b.jsx)(re,{className:`h-4 w-4`})})]})]})}function w(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function T({role:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,b.jsxs)(`div`,{className:p(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,b.jsx)(`span`,{className:p(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-sky-500/20 text-sky-600 dark:text-sky-300`:`bg-violet-500/20 text-violet-600 dark:text-violet-300`,(n||r)&&`sdd-agent-live`),children:i?(0,b.jsx)(l,{className:`h-3.5 w-3.5`}):(0,b.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(`div`,{className:p(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-sky-500/15`:`rounded-tl-sm bg-muted`),children:r?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,b.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}export{C as SddWizard};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{c as t,m as n,o as r,p as i}from"./markdown-D0X23O-i.js";import{Br as a,Bt as ee,Dn as te,Fr as ne,Hn as re,In as ie,Jt as ae,Kt as oe,Z as o,Zn as se,br as ce,dt as s,fr as c,gr as le,ir as ue,mr as de,si as fe,t as pe,ui as l,wr as me}from"./vendor-Bhf0nZ3B.js";import"./i18n-BJCOtLro.js";import{n as u}from"./ui-store-D3gGpJWY.js";import{t as d}from"./utils-sFCTikqz.js";import{C as he,T as ge,d as f}from"./index-BSuiEQIC.js";var p=e(n(),1),m=i();function h(e){return e===`project`||e===`user`}function g(e){let t=e.match(/^(.+?)\/SKILL(?:\.save)?\.md$/);return t?t[1]:null}function _e({source:e}){let{t}=fe(),n=e===`project`?`project`:e===`user`?`user`:`bundled`;return(0,m.jsx)(`span`,{className:d(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide`,n===`project`&&`bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400`,n===`user`&&`bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-400`,n===`bundled`&&`bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400`),children:t(`activity:skillDetail.${{project:`scopeProject`,user:`scopeGlobal`,bundled:`scopeBundled`}[n]}`)})}function _({className:e}){let{t:n}=fe(),{client:i}=he(),_=u(e=>e.skillsState),v=u(e=>e.setSkillsState),y=_.selectedSkill,b=_.navHistory,x=_.historyIndex,[S,C]=(0,p.useState)(null),[ve,w]=(0,p.useState)(!1),[T,E]=(0,p.useState)(null),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(``),[j,M]=(0,p.useState)(!1),[N,P]=(0,p.useState)(null),[F,I]=(0,p.useState)(!1),[L,R]=(0,p.useState)(null),[z,B]=(0,p.useState)(!1),V=(0,p.useRef)(``),[H,ye]=(0,p.useState)(!1),[U,W]=(0,p.useState)(null),[be,xe]=(0,p.useState)(!1),[G,K]=(0,p.useState)(null),[q,Se]=(0,p.useState)(!1),[Ce,we]=(0,p.useState)([]),J=(0,p.useRef)(_);J.current=_;let Y=(0,p.useRef)(!1),X=(0,p.useMemo)(()=>k?{lines:k.split(`
|
|
2
|
-
`).length,words:k.trim()?k.trim().split(/\s+/).length:0,chars:k.length}:{lines:0,words:0,chars:0},[k]),Z=(0,p.useMemo)(()=>{if(!k)return null;let e=5*1024*1024,t=new Blob([k]).size;return t>=e?{level:`critical`,used:t,limit:e}:t>=4194304?{level:`warn`,used:t,limit:e}:null},[k]);(0,p.useEffect)(()=>{if(!L)return;let e=setTimeout(()=>R(null),2e3);return()=>clearTimeout(e)},[L]),(0,p.useEffect)(()=>{if(!D||!y)return;let e=setInterval(()=>{k&&k!==V.current&&(V.current=k,localStorage.setItem(`skills_draft_${y.name}`,JSON.stringify({content:k,savedAt:Date.now()})),R(Date.now()))},5e3);return()=>clearInterval(e)},[D,k,y]),(0,p.useEffect)(()=>{if(!y||!D)return;let e=localStorage.getItem(`skills_draft_${y.name}`);if(e)try{let{content:t}=JSON.parse(e);t&&t!==k&&t!==V.current&&(A(t),V.current=t,B(!0))}catch{}},[y?.name,D]),(0,p.useEffect)(()=>{if(!i||!y)return;w(!0),C(null),E(null);let e=setTimeout(()=>{w(!1),E(l.t(`activity:skillDetail.timeoutError`))},1e4),t=t=>{clearTimeout(e);let n=t;n.payload.error?E(n.payload.error):n.payload.name&&C(n.payload),w(!1)},n=e=>{let t=e;ye(!1);let n=J.current;if(t.payload.success){let e={...n.knownRefs};for(let n of t.payload.updated??[])e[n.name]=n.newRef;v({...n,knownRefs:e,updateAvailableCount:0}),W({updated:t.payload.updated??[],unchanged:t.payload.unchanged??[],errors:t.payload.errors??[]}),i.send({type:`skills.list`})}else W({updated:[],unchanged:[],errors:[{name:``,error:t.payload.error??l.t(`activity:skillDetail.updateFailed`)}]})},r=e=>{let t=e;t.payload.skills&&we(t.payload.skills)};return i.on(`skills.content`,t),i.on(`skills.updated`,n),i.on(`skills.list`,r),i.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),()=>{clearTimeout(e),i.off(`skills.content`,t),i.off(`skills.updated`,n),i.off(`skills.list`,r)}},[i,y?.name,y?.source]),(0,p.useEffect)(()=>{D&&(O(!1),A(``),P(null))},[y?.name]);let Q=(0,p.useCallback)(e=>Ce.find(t=>t.name.toLowerCase()===e.toLowerCase()),[Ce]),Te=(0,p.useCallback)(e=>{let t=Q(e);if(t){Y.current=!1;let e=b.slice(0,x+1);e.push(t),v({...J.current,selectedSkill:t,navHistory:e,historyIndex:e.length-1}),O(!1),A(``),W(null)}},[Q,b,x,v]),Ee=(0,p.useCallback)(()=>{if(x<=0)return;Y.current=!0;let e=x-1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),O(!1),A(``),W(null)},[x,b,v]),De=(0,p.useCallback)(()=>{if(x>=b.length-1)return;Y.current=!0;let e=x+1,t=b[e];v({...J.current,selectedSkill:t,historyIndex:e}),O(!1),A(``),W(null)},[x,b,v]),$=(0,p.useCallback)(()=>{ge(`chat`)},[]),Oe=(0,p.useCallback)(()=>{S&&(A(S.body),V.current=S.body,B(!1),P(null),O(!0),I(!1))},[S]),ke=(0,p.useCallback)(()=>{O(!1),A(``),P(null),I(!1),B(!1),y&&localStorage.removeItem(`skills_draft_${y.name}`)},[y]),Ae=(0,p.useCallback)(()=>{!y||!S||(B(!1),A(S.body),V.current=S.body,y&&localStorage.removeItem(`skills_draft_${y.name}`))},[y,S]),je=(0,p.useCallback)(()=>{if(!i||!y||!k.trim())return;M(!0),P(null);let e=t=>{let n=t;M(!1),n.payload.success?(V.current=``,localStorage.removeItem(`skills_draft_${y.name}`),B(!1),O(!1),i.send({type:`skills.content`,payload:{name:y.name,source:y.source}}),i.send({type:`skills.list`})):P(n.payload.error??l.t(`activity:skillDetail.saveFailed`)),i.off(`skills.edited`,e)};i.on(`skills.edited`,e),i.editSkill(y.name,k)},[i,y,k]),Me=(0,p.useCallback)(()=>{!i||!y||(ye(!0),W(null),i.checkForUpdates(y.name,y.source===`user`))},[i,y]),Ne=(0,p.useCallback)(()=>{y?.sourceUrl&&navigator.clipboard.writeText(y.sourceUrl).then(()=>{xe(!0),setTimeout(()=>xe(!1),2e3)})},[y]),Pe=(0,p.useCallback)(()=>{if(!S?.body)return;let e=new Blob([S.body],{type:`text/markdown`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${S.name.replace(/\//g,`_`)}-SKILL.md`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},[S]),Fe=(0,p.useCallback)(async e=>{if(!i||!e)return;Se(!0);let t=e=>{let n=e;Se(!1),n.payload.success?(K(null),i.send({type:`skills.list`}),$()):P(n.payload.error??l.t(`activity:skillDetail.uninstallFailed`)),i.off(`skills.uninstalled`,t)};i.on(`skills.uninstalled`,t),i.uninstallSkill(e.name,e.source===`user`)},[i,$]);return y?(0,m.jsxs)(`div`,{className:d(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e),children:[(0,m.jsxs)(`div`,{className:`px-4 py-3 border-b bg-card shrink-0`,children:[(0,m.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(ne,{className:`h-4 w-4 text-primary shrink-0`}),(0,m.jsx)(`h1`,{className:`text-base font-semibold truncate`,children:y.name}),y.version&&(0,m.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,y.version]}),(0,m.jsx)(_e,{source:y.source})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:y.description||y.trigger}),y.sourceUrl&&(0,m.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,m.jsxs)(`a`,{href:`https://${y.sourceUrl.replace(`github:`,``)}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:n(`activity:skillDetail.openSourceRepo`),children:[(0,m.jsx)(te,{className:`h-3 w-3 shrink-0`}),(0,m.jsx)(`span`,{className:`truncate font-mono`,children:y.sourceUrl})]}),(0,m.jsx)(`button`,{type:`button`,onClick:Ne,className:`flex items-center shrink-0 text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:n(`activity:skillDetail.copySourceUrl`),children:be?(0,m.jsx)(le,{className:`h-3 w-3 text-green-500`}):(0,m.jsx)(ue,{className:`h-3 w-3`})})]}),y.scope.length>0&&(0,m.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:y.scope.map(e=>(0,m.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:e},e))}),U&&(0,m.jsxs)(`div`,{className:`mt-2 text-xs space-y-1`,children:[U.updated.length>0&&(0,m.jsx)(`div`,{className:`text-green-600`,children:n(`activity:skillDetail.updatedLabel`,{list:U.updated.map(e=>`${e.name} (${e.oldRef} → ${e.newRef})`).join(`, `)})}),U.unchanged.length>0&&(0,m.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:skillDetail.upToDateLabel`,{list:U.unchanged.join(`, `)})}),U.errors.length>0&&(0,m.jsx)(`div`,{className:`text-destructive`,children:n(`activity:skillDetail.errorsLabel`,{list:U.errors.map(e=>`${e.name?`${e.name}: `:``}${e.error}`).join(`; `)})})]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[h(y.source)&&y.sourceUrl&&(0,m.jsx)(`button`,{type:`button`,onClick:Me,disabled:H,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer disabled:opacity-50`,title:n(`activity:skillDetail.checkUpdatesTitle`),children:H?(0,m.jsx)(a,{className:`h-3.5 w-3.5 animate-spin`}):(0,m.jsx)(ee,{className:`h-3.5 w-3.5`})}),y.source!==`bundled`&&!D&&(0,m.jsx)(`button`,{type:`button`,onClick:Pe,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:n(`activity:skillDetail.exportTitle`),children:(0,m.jsx)(se,{className:`h-3.5 w-3.5`})}),h(y.source)&&!D&&(0,m.jsx)(`button`,{type:`button`,onClick:Oe,className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors cursor-pointer`,title:n(`activity:skillDetail.editTitle`),children:(0,m.jsx)(oe,{className:`h-3.5 w-3.5`})}),h(y.source)&&(0,m.jsx)(`button`,{type:`button`,onClick:()=>K(y),className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors cursor-pointer`,title:n(`activity:skillDetail.uninstallTitle`),children:(0,m.jsx)(s,{className:`h-3.5 w-3.5`})}),(0,m.jsx)(`button`,{type:`button`,onClick:$,className:`p-1.5 rounded hover:bg-accent text-muted-foreground cursor-pointer`,title:n(`activity:skillDetail.closeTitle`),children:(0,m.jsx)(o,{className:`h-4 w-4`})})]})]}),b.length>1&&(0,m.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:Ee,disabled:x<=0,className:d(`p-1 rounded transition-colors`,x<=0?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:n(`activity:skillDetail.backTitle`),children:(0,m.jsx)(de,{className:`h-4 w-4`})}),(0,m.jsx)(`button`,{type:`button`,onClick:De,disabled:x>=b.length-1,className:d(`p-1 rounded transition-colors`,x>=b.length-1?`text-muted-foreground/40 cursor-not-allowed`:`hover:bg-accent text-muted-foreground cursor-pointer`),title:n(`activity:skillDetail.forwardTitle`),children:(0,m.jsx)(c,{className:`h-4 w-4`})}),(0,m.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto text-xs`,children:b.map((e,t)=>(0,m.jsxs)(`span`,{className:`flex items-center shrink-0`,children:[t>0&&(0,m.jsx)(c,{className:`h-3 w-3 text-muted-foreground/40 mx-0.5 shrink-0`}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>{t<x&&(Y.current=!0,v({...J.current,selectedSkill:e,historyIndex:t}),O(!1),A(``),W(null))},className:d(`hover:text-primary cursor-pointer transition-colors`,t===x?`text-primary font-medium`:`text-muted-foreground`),children:e.name})]},e.name+t))})]})]}),S&&(S.relatedFiles.length>0||S.references.length>0)&&(0,m.jsxs)(`div`,{className:`px-4 py-2 border-b bg-muted/30 shrink-0 space-y-2`,children:[S.relatedFiles.length>0&&(0,m.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,m.jsx)(ie,{className:`h-3 w-3`}),(0,m.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:n(`activity:skillDetail.relatedFiles`)})]}),S.relatedFiles.map(e=>{let t=g(e);return t&&Q(t)?(0,m.jsxs)(`button`,{type:`button`,onClick:()=>Te(t),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-background border border-border hover:border-primary hover:text-primary transition-colors cursor-pointer`,title:n(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,m.jsx)(me,{className:`h-2.5 w-2.5`}),e]},e):(0,m.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-background border border-border text-muted-foreground`,children:e},e)})]}),S.references.length>0&&(0,m.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,m.jsx)(re,{className:`h-3 w-3`}),(0,m.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:n(`activity:skillDetail.references`)})]}),S.references.map(e=>{let t=g(e)??e.replace(/\.md$/,``);return Q(t)?(0,m.jsxs)(`button`,{type:`button`,onClick:()=>Te(t),className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded bg-primary/5 border border-primary/20 text-primary hover:bg-primary/10 hover:border-primary/30 transition-colors cursor-pointer`,title:n(`activity:skillDetail.goToSkillTitle`,{name:t}),children:[(0,m.jsx)(me,{className:`h-2.5 w-2.5`}),t]},e):(0,m.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-muted text-muted-foreground`,children:t},e)})]})]}),(0,m.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:ve?(0,m.jsxs)(`div`,{className:`p-8 text-center text-muted-foreground`,children:[(0,m.jsx)(a,{className:`h-6 w-6 animate-spin mx-auto mb-2`}),(0,m.jsx)(`p`,{children:n(`activity:skillDetail.loadingContent`)})]}):D?(0,m.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,m.jsxs)(`div`,{className:`px-4 py-2 border-b shrink-0 flex items-center justify-between gap-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`activity:skillDetail.editingLabel`,{name:y.name})}),(0,m.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:n(`activity:skillDetail.editStats`,{lines:X.lines,words:X.words,chars:X.chars})}),Z&&(0,m.jsx)(`span`,{className:`text-xs tabular-nums ${Z.level===`critical`?`text-red-500 font-medium`:`text-amber-500`}`,children:n(`activity:skillDetail.charsWarningFmt`,{used:(Z.used/(1024*1024)).toFixed(1),limit:(Z.limit/(1024*1024)).toFixed(0)})}),L&&(0,m.jsx)(`span`,{className:`text-xs text-green-500 animate-pulse`,children:n(`activity:skillDetail.draftSaved`)}),z&&(0,m.jsx)(`span`,{className:`text-xs text-amber-500 animate-pulse`,children:n(`activity:skillDetail.draftRestored`)})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[N&&(0,m.jsx)(`span`,{className:`text-xs text-destructive`,children:N}),z&&(0,m.jsx)(`button`,{type:`button`,onClick:Ae,className:`px-2 py-1 text-[10px] rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors cursor-pointer`,children:n(`activity:skillDetail.discardDraft`)}),(0,m.jsx)(`button`,{type:`button`,onClick:ke,className:`px-2 py-1 text-xs rounded border border-border hover:bg-accent transition-colors cursor-pointer`,children:n(`common:action.cancel`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>I(e=>!e),title:n(F?`activity:skillDetail.hidePreviewTitle`:`activity:skillDetail.splitViewTitle`),className:`px-2 py-1 text-xs rounded border transition-colors cursor-pointer ${F?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-accent text-muted-foreground`}`,children:(0,m.jsx)(ae,{className:`h-3 w-3 inline`})}),(0,m.jsx)(`button`,{type:`button`,onClick:je,disabled:j||!k.trim(),className:`px-3 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer`,children:j?(0,m.jsx)(a,{className:`h-3 w-3 animate-spin inline`}):n(`common:action.save`)})]})]}),F?(0,m.jsxs)(`div`,{className:`flex flex-1 min-h-0 gap-0.5`,children:[(0,m.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0`,children:(0,m.jsx)(pe,{value:k,onChange:e=>A(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:n(`activity:skillDetail.contentPlaceholder`)})}),(0,m.jsx)(`div`,{className:`w-px bg-border flex-shrink-0`}),(0,m.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto p-4 prose prose-sm dark:prose-invert max-w-none`,children:(0,m.jsx)(t,{rehypePlugins:[r],components:f,children:k})})]}):(0,m.jsx)(pe,{value:k,onChange:e=>A(e.target.value??``),language:`markdown`,className:`flex-1`,style:{fontSize:12,backgroundColor:`transparent`,minHeight:0},placeholder:n(`activity:skillDetail.contentPlaceholder`)})]}):S?(0,m.jsx)(`div`,{className:`p-6 prose prose-sm dark:prose-invert max-w-none`,children:(0,m.jsx)(t,{rehypePlugins:[r],components:f,children:S.body})}):T?(0,m.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,m.jsx)(`p`,{className:`text-destructive mb-2`,children:n(`activity:skillDetail.loadFailed`)}),(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:T}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>{i&&y&&(w(!0),E(null),i.send({type:`skills.content`,payload:{name:y.name,source:y.source}}))},className:`mt-4 px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors`,children:n(`common:action.retry`)})]}):(0,m.jsx)(`div`,{className:`p-8 text-center text-muted-foreground`,children:n(`activity:skillDetail.noContent`)})}),G&&(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:e=>{e.target===e.currentTarget&&K(null)},children:(0,m.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] w-[380px] max-w-[90vw] flex-col overflow-hidden rounded-lg border bg-background shadow-xl`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 border-b`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(s,{className:`h-4 w-4 text-destructive`}),(0,m.jsx)(`span`,{className:`font-semibold text-sm`,children:n(`activity:skillDetail.uninstallSkillHeading`)})]}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>K(null),className:`p-1 rounded hover:bg-accent text-muted-foreground cursor-pointer`,children:(0,m.jsx)(o,{className:`h-4 w-4`})})]}),(0,m.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 space-y-2`,children:[(0,m.jsx)(`p`,{className:`text-sm`,children:n(`activity:skillDetail.uninstallConfirm`,{name:G.name})}),(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:skillDetail.uninstallRemovePath`,{path:G.source===`user`?`~/.wrongstack/skills`:`.wrongstack/skills`})})]}),(0,m.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 p-4 border-t bg-muted/20`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>K(null),disabled:q,className:`px-3 py-1.5 text-xs rounded border border-border hover:bg-accent transition-colors disabled:opacity-50`,children:n(`common:action.cancel`)}),(0,m.jsxs)(`button`,{type:`button`,onClick:()=>Fe(G),disabled:q,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[q&&(0,m.jsx)(a,{className:`h-3 w-3 animate-spin`}),n(`activity:skillDetail.uninstallAction`)]})]})]})})]}):(0,m.jsxs)(`div`,{className:d(`flex-1 flex flex-col items-center justify-center text-muted-foreground p-8`,e),children:[(0,m.jsx)(ce,{className:`h-12 w-12 mb-4 opacity-20`}),(0,m.jsx)(`p`,{className:`text-base font-medium`,children:n(`activity:skillDetail.noSkillSelected`)}),(0,m.jsx)(`p`,{className:`text-sm mt-1 text-center max-w-[300px]`,children:n(`activity:skillDetail.selectSkillHint`)}),(0,m.jsx)(`button`,{type:`button`,onClick:$,className:`mt-4 px-4 py-2 text-sm rounded-md border border-border hover:bg-accent transition-colors`,children:n(`activity:skillDetail.goToChat`)})]})}export{_ as SkillDetailView};
|