@wrongstack/webui 0.300.0 → 0.301.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/AgentRosterView-BV6ysoGs.js +9 -0
- package/dist/assets/{AnalyticsDashboard-CIN35A_u.js → AnalyticsDashboard-UWNP8zjE.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-BAY2Bh8z.js → AudienceMemoryPanel-DwDKbvSA.js} +1 -1
- package/dist/assets/{ChangesView-CVWSTGmX.js → ChangesView-DuVlGWkD.js} +1 -1
- package/dist/assets/ChronicleDashboard-cs16n708.js +1 -0
- package/dist/assets/{CodeEditor-CWY_6cQD.js → CodeEditor-sr50ljZN.js} +1 -1
- package/dist/assets/{CodeMap-CjmKO0lB.js → CodeMap-CtK-C8gK.js} +1 -1
- package/dist/assets/ConfirmModal-ndS17YwF.js +1 -0
- package/dist/assets/{CronJobsPanel-BinzTWNs.js → CronJobsPanel-Dovomns5.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-C3CgaNVv.js → DeadCodeScanPanel-DjR4LLMs.js} +1 -1
- package/dist/assets/{DebugDashboard-BqUghn06.js → DebugDashboard-jK1yp3qS.js} +1 -1
- package/dist/assets/{DesignGalleryView-CuWWQAlD.js → DesignGalleryView-CqXlEUzE.js} +1 -1
- package/dist/assets/GoalView-CGNLrnA4.js +1 -0
- package/dist/assets/KanbanView--tAf_K7N.js +3 -0
- package/dist/assets/{MailboxDetailView-aaHx9Nma.js → MailboxDetailView-0TBzZTdN.js} +1 -1
- package/dist/assets/{MemoryManager-BgcicCyg.js → MemoryManager-CDK_MO8A.js} +1 -1
- package/dist/assets/{ModelPicker-B3BqjJnT.js → ModelPicker-BbBZuQwR.js} +1 -1
- package/dist/assets/{OfficeMapPanel-Ck8NUOEs.js → OfficeMapPanel-68sVzHRD.js} +2 -2
- package/dist/assets/{OfficeMapPanel-CpexsBed.css → OfficeMapPanel-D6yTfGIT.css} +1 -1
- package/dist/assets/{ProcessMonitor-CoMYZcdS.js → ProcessMonitor-gFwiF8gX.js} +1 -1
- package/dist/assets/{QueuePanel-CA3CVCO_.js → QueuePanel-Cx-isRGl.js} +1 -1
- package/dist/assets/{RefreshDebugView-cqBtyNna.js → RefreshDebugView-C9tdu6Ld.js} +1 -1
- package/dist/assets/{RequirementIntakeView-BBtUk8mC.js → RequirementIntakeView-cPEw-RpV.js} +1 -1
- package/dist/assets/SageTabs-BbK6VFO0.js +2 -0
- package/dist/assets/SddHub-NKvDRECi.js +2 -0
- package/dist/assets/{SessionInspectView-DHC_xTzG.js → SessionInspectView-DPG5qWhj.js} +1 -1
- package/dist/assets/SessionList-ncl-20X_.js +1 -0
- package/dist/assets/SessionsDashboard-D23UVLr4.js +1 -0
- package/dist/assets/SetupScreen-D3XQ8MGk.js +1 -0
- package/dist/assets/{SkillDetailView-D7wSJWUX.js → SkillDetailView-DDPhVFet.js} +1 -1
- package/dist/assets/{SpecsView-BRWSI1iV.js → SpecsView-afIS0QpX.js} +1 -1
- package/dist/assets/{TechStackView-BOjkuJLe.js → TechStackView-kQ2OGxxw.js} +1 -1
- package/dist/assets/{TerminalPanel-Dg8WR5Un.js → TerminalPanel-GcJWeldW.js} +1 -1
- package/dist/assets/{Toaster-DSKFSuK3.js → Toaster-CgQA9256.js} +1 -1
- package/dist/assets/{activity-BWbV0byu.js → activity-B-cvKIfT.js} +4 -4
- package/dist/assets/{activity-DA9hmVZV.js → activity-Ba3aMzvo.js} +4 -4
- package/dist/assets/{activity-GdnS66AB.js → activity-CRTVZ5A4.js} +4 -4
- package/dist/assets/{activity-eawh_OWs.js → activity-DsSuflRW.js} +4 -4
- package/dist/assets/{activity-Bze6njDy.js → activity-DxDRJ8kN.js} +4 -4
- package/dist/assets/{activity-Bjb_mil3.js → activity-VI776bUZ.js} +4 -4
- package/dist/assets/{activity-Ciqcr7Ps.js → activity-nVmsmqAI.js} +4 -4
- package/dist/assets/chat-BPuAsrkF.js +1 -0
- package/dist/assets/chat-BfQBSiII.js +1 -0
- package/dist/assets/chat-BnkVCZ3Q.js +1 -0
- package/dist/assets/chat-CR2B97dj.js +1 -0
- package/dist/assets/chat-CdiY7G6Z.js +1 -0
- package/dist/assets/chat-DResBrkV.js +1 -0
- package/dist/assets/chat-Di8o0wDz.js +1 -0
- package/dist/assets/chat-store-DbxFVDwi.js +17 -0
- package/dist/assets/i18n-COgumVF5.js +2 -0
- package/dist/assets/index-CtpViiZy.js +132 -0
- package/dist/assets/index-fIsq43fR.css +1 -0
- package/dist/assets/mailbox-store-C1mzoSqJ.js +1 -0
- package/dist/assets/{progress-ring-D_d6hn_4.js → progress-ring-D_48qsBl.js} +1 -1
- package/dist/assets/{roster-ws-D6dGRfC5.js → roster-ws-Da57e_sI.js} +1 -1
- package/dist/assets/session-store-Df7_hhe9.js +1 -0
- package/dist/assets/settings-Bb7_utQE.js +1 -0
- package/dist/assets/settings-Bd8zMwvC.js +1 -0
- package/dist/assets/settings-DdFgBMAw.js +1 -0
- package/dist/assets/settings-De6sXIFO.js +1 -0
- package/dist/assets/settings-E8SKMLxq.js +1 -0
- package/dist/assets/settings-zIY9-ivF.js +1 -0
- package/dist/assets/settings-zKBcRjqE.js +1 -0
- package/dist/assets/stores-ChEnUmic.js +7 -0
- package/dist/assets/{useWebSocket-DuLtH2jI.js → useWebSocket-_gk4MRJz.js} +7 -7
- package/dist/assets/ws-client-TTMa0XaT.js +1 -0
- package/dist/components/AgentCard.d.ts +21 -0
- package/dist/components/AgentsPage.d.ts +0 -3
- package/dist/components/ChatInput/refine-panel-host.d.ts +2 -2
- package/dist/components/ConfirmModal.d.ts +7 -2
- package/dist/components/KanbanBoardState.d.ts +1 -1
- package/dist/components/SettingsPanel/ShadowSection.d.ts +18 -1
- package/dist/components/SettingsPanel/brain-section-options.d.ts +2 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/hooks/useWebSocket.d.ts +10 -2
- package/dist/index.css +32 -0
- package/dist/index.html +15 -14
- package/dist/index.js +3480 -3168
- package/dist/lib/kanban-board-active.d.ts +19 -0
- package/dist/lib/plugin-enablement.d.ts +1 -1
- package/dist/lib/ws-client.d.ts +21 -1
- package/dist/stores/fleet-store.d.ts +1 -1
- package/dist/stores/local-prefs.d.ts +9 -0
- package/dist/stores/session-store.d.ts +9 -1
- package/dist/stores/ui-store.d.ts +2 -0
- package/dist/types/brain.d.ts +2 -0
- package/dist/types/client-message.d.ts +7 -1
- package/dist/types/protocol-core.d.ts +2 -0
- package/dist/types/runtime.d.ts +14 -0
- package/dist/types/server-message.d.ts +3 -3
- package/package.json +8 -8
- package/dist/assets/AgentRosterView-wkALMOGD.js +0 -9
- package/dist/assets/ChronicleDashboard-Bg3W7C9U.js +0 -1
- package/dist/assets/GoalView-2weuLiPM.js +0 -1
- package/dist/assets/KanbanView-DXYRrshJ.js +0 -3
- package/dist/assets/SageTabs-Di49i4Yu.js +0 -2
- package/dist/assets/SddHub-D8iV6l9A.js +0 -2
- package/dist/assets/SessionList-DH-ZsHmv.js +0 -1
- package/dist/assets/SessionsDashboard-Coi6htwg.js +0 -1
- package/dist/assets/SetupScreen-CD2Sx4n9.js +0 -1
- package/dist/assets/chat-4NEOESoU.js +0 -1
- package/dist/assets/chat-BSg62iwX.js +0 -1
- package/dist/assets/chat-Bb1TpPfJ.js +0 -1
- package/dist/assets/chat-COLKjtcx.js +0 -1
- package/dist/assets/chat-CfRKV9iX.js +0 -1
- package/dist/assets/chat-EbeT4kiS.js +0 -1
- package/dist/assets/chat-store-CtOyUCdF.js +0 -17
- package/dist/assets/chat-ux_gymOJ.js +0 -1
- package/dist/assets/i18n-C31PI0Up.js +0 -2
- package/dist/assets/index-5IWUhPO4.css +0 -1
- package/dist/assets/index-D1izXztg.js +0 -132
- package/dist/assets/mailbox-store-Bc9ER3Ph.js +0 -1
- package/dist/assets/session-store-b2KGFwkX.js +0 -1
- package/dist/assets/settings-BKuhxUSF.js +0 -1
- package/dist/assets/settings-CeK0doV7.js +0 -1
- package/dist/assets/settings-DZ-H89lu.js +0 -1
- package/dist/assets/settings-DvrdpSdA.js +0 -1
- package/dist/assets/settings-SBUqq0ll.js +0 -1
- package/dist/assets/settings-W8t1ZrxM.js +0 -1
- package/dist/assets/settings-tOqZkk9R.js +0 -1
- package/dist/assets/stores-OBoFiAKe.js +0 -7
- package/dist/assets/ws-client-Bw1ixxwI.js +0 -1
- package/dist/components/AgentsMonitor.d.ts +0 -26
- package/dist/components/FleetMonitor.d.ts +0 -21
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { KanbanBoardSummary } from '@wrongstack/kanban';
|
|
2
|
+
/**
|
|
3
|
+
* The single client-side answer to "is this board attached to a live
|
|
4
|
+
* session?": a board is active when EITHER a presence entry is live OR one
|
|
5
|
+
* of its `session:<id>` tags names a session the client currently knows to
|
|
6
|
+
* be running. Callers that cannot know the live session ids (e.g. the
|
|
7
|
+
* kanban store computing fallback totals outside React) pass an empty
|
|
8
|
+
* list — that degrades to the presence-only half of the predicate instead
|
|
9
|
+
* of forking a second, narrower definition.
|
|
10
|
+
*
|
|
11
|
+
* The server-side twin lives in
|
|
12
|
+
* `packages/webui-server/src/server/kanban-route-pagination.ts`
|
|
13
|
+
* (`isActive` inside `paginateKanbanBoards`) and must keep the same shape:
|
|
14
|
+
* the server's `activeTotal`/`orphanedTotal` land in the same store fields
|
|
15
|
+
* these fallbacks feed, so a definition drift between the two shows up as
|
|
16
|
+
* a section heading disagreeing with the list rendered under it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isKanbanBoardActive(board: Pick<KanbanBoardSummary, 'presence' | 'tags'>, activeSessionIds: readonly string[]): boolean;
|
|
19
|
+
//# sourceMappingURL=kanban-board-active.d.ts.map
|
|
@@ -26,7 +26,7 @@ export interface ResolvedPluginState {
|
|
|
26
26
|
* behaviour. The local override map may be missing, in which case only
|
|
27
27
|
* the canonical config is consulted.
|
|
28
28
|
*/
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function resolvePluginToggleStates(configuredPlugins: readonly PluginEntry[] | undefined, localOverrides: Readonly<Record<string, boolean>> | undefined): ResolvedPluginState[];
|
|
30
30
|
/**
|
|
31
31
|
* Convenience accessor for callers that only need one plugin's resolved
|
|
32
32
|
* state. Returns `undefined` if the plugin is not configured at all
|
package/dist/lib/ws-client.d.ts
CHANGED
|
@@ -75,6 +75,23 @@ declare class WrongStackWebSocketClientBase {
|
|
|
75
75
|
private attemptReconnect;
|
|
76
76
|
/** Force an immediate reconnect attempt, bypassing the backoff timer. */
|
|
77
77
|
retryNow(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Drain the offline queue onto a freshly-opened socket.
|
|
80
|
+
*
|
|
81
|
+
* Two hazards, both fatal before this guard:
|
|
82
|
+
*
|
|
83
|
+
* 1. `send()` calls `this.ws.send(...)` unguarded. The socket can race
|
|
84
|
+
* OPEN → CLOSING between the readyState check and the actual write (a
|
|
85
|
+
* normal server restart does it), which throws `InvalidStateError`. This
|
|
86
|
+
* runs from `onopen` BEFORE `resolve()`, so the throw skipped the
|
|
87
|
+
* resolve, the connect promise never settled, `.finally()` never cleared
|
|
88
|
+
* `connectPromise`, and every later `connect()` — including
|
|
89
|
+
* `attemptReconnect` and `retryNow` — returned that dead promise. The tab
|
|
90
|
+
* was offline for good with the banner stuck on "reconnecting".
|
|
91
|
+
* 2. If the socket is not OPEN, `send()` re-queues the message it was handed
|
|
92
|
+
* while this loop keeps shifting — an infinite loop on the main thread.
|
|
93
|
+
* Draining into a local array first makes the loop finite by construction.
|
|
94
|
+
*/
|
|
78
95
|
private flushMessageQueue;
|
|
79
96
|
private handleMessage;
|
|
80
97
|
private emit;
|
|
@@ -96,7 +113,10 @@ declare class WrongStackWebSocketClientBase {
|
|
|
96
113
|
type: K;
|
|
97
114
|
}>) => void): void;
|
|
98
115
|
off(eventType: string, handler: EventHandler): void;
|
|
99
|
-
sendMessage(content: string, images?: WSUserMessageImage[]): string;
|
|
116
|
+
sendMessage(content: string, images?: WSUserMessageImage[], freshContext?: boolean): string;
|
|
117
|
+
adviseTopic(prompt: string, timeoutMs?: number): Promise<Extract<WSServerMessage, {
|
|
118
|
+
type: 'topic.advice_result';
|
|
119
|
+
}>['payload']>;
|
|
100
120
|
/** Send a mailbox message of the given type (btw, steer, note, etc.)
|
|
101
121
|
* to a target agent/role. Returns the requestId for response tracking. */
|
|
102
122
|
sendMailboxMessage(opts: WSMailboxSendOptions): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentTranscriptEntry, FleetTimelineEvent,
|
|
1
|
+
import type { AgentTranscriptEntry, FleetTimelineEvent, SubagentEvent, SubagentView } from './types.js';
|
|
2
2
|
export declare const EMPTY_AGENT_TRANSCRIPT: AgentTranscriptEntry[];
|
|
3
3
|
interface FleetState {
|
|
4
4
|
agents: Map<string, SubagentView>;
|
|
@@ -24,6 +24,13 @@ export interface LocalPrefs {
|
|
|
24
24
|
fleetChatVerbosity: FleetChatVerbosity;
|
|
25
25
|
/** Predict next steps after turn completes */
|
|
26
26
|
nextPrediction: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Register the leader's agent-callable `nextsteps` tool alongside the
|
|
29
|
+
* `<nextsteps>` block it can already write. Persisted to
|
|
30
|
+
* `tools.nextsteps.enabled`; the tool registry is built at boot, so the
|
|
31
|
+
* change takes effect in the next session.
|
|
32
|
+
*/
|
|
33
|
+
nextStepsTool: boolean;
|
|
27
34
|
/** Global fallback model chain (entries: `model` or `provider/model`). */
|
|
28
35
|
fallbackModels: string[];
|
|
29
36
|
/** Named fallback chains selectable by setmodel/model routing. */
|
|
@@ -173,6 +180,8 @@ export interface LocalPrefs {
|
|
|
173
180
|
autoReviewModel: string;
|
|
174
181
|
/** Named fallback profile (from `config.fallbackProfiles`) used to derive provider/model + fallback chain. */
|
|
175
182
|
autoReviewFallbackProfile: string;
|
|
183
|
+
/** Starting-model policy for the selected auto-review profile. */
|
|
184
|
+
autoReviewModelSelection: 'round-robin' | 'random';
|
|
176
185
|
/** Explicit fallback chain (derived when no fallbackProfile is set, surfaced for visibility). */
|
|
177
186
|
autoReviewFallbackModels: string[];
|
|
178
187
|
/** Debounce window in ms — wait for quiet before firing review (default 15000). */
|
|
@@ -8,8 +8,15 @@ interface SessionState {
|
|
|
8
8
|
lastInputTokens: number;
|
|
9
9
|
cost: number;
|
|
10
10
|
startTime: number | null;
|
|
11
|
-
/**
|
|
11
|
+
/** Active effective context window. 0 = unknown. */
|
|
12
12
|
maxContext: number;
|
|
13
|
+
/** Live provider-reported decrease, shown until the session/model changes. */
|
|
14
|
+
contextLimitWarning: {
|
|
15
|
+
previousMaxContext: number;
|
|
16
|
+
maxContext: number;
|
|
17
|
+
providerId: string;
|
|
18
|
+
modelId: string;
|
|
19
|
+
} | null;
|
|
13
20
|
/** USD per 1M tokens — used to compute cost deltas on every provider.response. */
|
|
14
21
|
inputCost: number;
|
|
15
22
|
outputCost: number;
|
|
@@ -92,6 +99,7 @@ interface SessionState {
|
|
|
92
99
|
max: number;
|
|
93
100
|
} | null) => void;
|
|
94
101
|
setContextUsage: (tokens: number, maxContext?: number | undefined) => void;
|
|
102
|
+
setContextLimitWarning: (warning: SessionState['contextLimitWarning']) => void;
|
|
95
103
|
setModes: (modes: Array<{
|
|
96
104
|
id: string;
|
|
97
105
|
name: string;
|
|
@@ -181,6 +181,8 @@ interface UIState {
|
|
|
181
181
|
fallbackRef?: string | undefined;
|
|
182
182
|
/** True once the automatic timeout retry has been spent (so we don't loop). */
|
|
183
183
|
retried?: boolean | undefined;
|
|
184
|
+
/** Apply a model-context boundary atomically when the approved prompt is sent. */
|
|
185
|
+
freshContext?: boolean | undefined;
|
|
184
186
|
/** Provider id of the model running the refinement (e.g. "openai"). */
|
|
185
187
|
provider?: string | undefined;
|
|
186
188
|
/** Model name running the refinement (e.g. "gpt-4o"). */
|
package/dist/types/brain.d.ts
CHANGED
|
@@ -164,6 +164,7 @@ export interface BrainConfigWire {
|
|
|
164
164
|
perCallTimeoutMs?: number | undefined;
|
|
165
165
|
maxConcurrency?: number | undefined;
|
|
166
166
|
distinctness: 'none' | 'model' | 'provider';
|
|
167
|
+
voterMaxTokens?: number | undefined;
|
|
167
168
|
judgeMaxTokens?: number | undefined;
|
|
168
169
|
seats: BrainCouncilSeatWire[];
|
|
169
170
|
};
|
|
@@ -231,6 +232,7 @@ export interface BrainConfigPatchWire {
|
|
|
231
232
|
perCallTimeoutMs?: number | null | undefined;
|
|
232
233
|
maxConcurrency?: number | null | undefined;
|
|
233
234
|
distinctness?: 'none' | 'model' | 'provider' | null | undefined;
|
|
235
|
+
voterMaxTokens?: number | null | undefined;
|
|
234
236
|
judgeMaxTokens?: number | null | undefined;
|
|
235
237
|
seats?: BrainCouncilSeatWire[] | null | undefined;
|
|
236
238
|
} | null | undefined;
|
|
@@ -25,7 +25,13 @@ export interface ProviderCustomModelWire {
|
|
|
25
25
|
*/
|
|
26
26
|
modelsDev?: Record<string, unknown> | undefined;
|
|
27
27
|
}
|
|
28
|
-
export type WSClientMessageCore = WSUserMessage |
|
|
28
|
+
export type WSClientMessageCore = WSUserMessage | {
|
|
29
|
+
type: 'topic.advice';
|
|
30
|
+
payload: SessionScopedPayload & {
|
|
31
|
+
requestId: string;
|
|
32
|
+
prompt: string;
|
|
33
|
+
};
|
|
34
|
+
} | WSToolConfirmResult | {
|
|
29
35
|
type: 'side_effects.list';
|
|
30
36
|
payload?: Record<string, never>;
|
|
31
37
|
} | {
|
|
@@ -60,6 +60,8 @@ export interface WSUserMessage {
|
|
|
60
60
|
content: string;
|
|
61
61
|
timestamp: number;
|
|
62
62
|
stateExpiresAt?: number | undefined;
|
|
63
|
+
/** Atomically replace only the provider-bound conversation before this run. */
|
|
64
|
+
freshContext?: boolean | undefined;
|
|
63
65
|
/** Images attached in the composer (paste / drop / file picker). The
|
|
64
66
|
* server converts these to canonical ImageBlocks ahead of the text. */
|
|
65
67
|
images?: WSUserMessageImage[];
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -286,12 +286,26 @@ export interface WSContextPct {
|
|
|
286
286
|
maxContext: number;
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
+
export interface WSTopicAdviceResult {
|
|
290
|
+
type: 'topic.advice_result';
|
|
291
|
+
payload: SessionScopedPayload & {
|
|
292
|
+
requestId: string;
|
|
293
|
+
suggestNewContext: boolean;
|
|
294
|
+
confidence: number;
|
|
295
|
+
reason: string;
|
|
296
|
+
nextTopic?: string | undefined;
|
|
297
|
+
source: 'explicit' | 'model' | 'cache' | 'local';
|
|
298
|
+
};
|
|
299
|
+
}
|
|
289
300
|
export interface WSContextMaxContext {
|
|
290
301
|
type: 'ctx.max_context';
|
|
291
302
|
payload: SessionScopedPayload & {
|
|
292
303
|
providerId: string;
|
|
293
304
|
modelId: string;
|
|
294
305
|
maxContext: number;
|
|
306
|
+
previousMaxContext?: number | undefined;
|
|
307
|
+
source?: 'configured' | 'provider' | 'provider_overflow' | undefined;
|
|
308
|
+
decreased?: boolean | undefined;
|
|
295
309
|
};
|
|
296
310
|
}
|
|
297
311
|
export interface WSTokenThreshold {
|
|
@@ -4,11 +4,11 @@ import type { WSCollabAnnotationAdded, WSCollabAnnotationResolved, WSCollabEvent
|
|
|
4
4
|
import type { ConnectionsHealthReport, ServiceActionResult } from './connections.js';
|
|
5
5
|
import type { WSAgentStatusChanged, WSAgentTimelineMessage, WSEternalIteration, WSGoalAssessResult, WSGoalLifecycle, WSGoalList, WSGoalProgress, WSGoalState, WSKanbanResult, WSKanbanTaskActivity, WSModesList, WSWorktreeCleanupResult, WSWorktreeDiffResult, WSWorktreeEvent, WSWorktreeMergeResult, WSWorktreeOrphans, WSWorktreeState } from './goal-kanban-worktree.js';
|
|
6
6
|
import type { SessionScopedPayload, WSCodeMapToolExecuted, WSCodeMapToolStarted, WSIterationCompleted, WSIterationLimitReached, WSIterationStarted, WSProviderActiveBlocked, WSProviderError, WSProviderFallback, WSProviderFallbackPending, WSProviderResponse, WSProviderRetry, WSProviderStatusChanged, WSProviderStatusSnapshot, WSProviderStreamError, WSRunResult, WSSessionEnd, WSSessionStart, WSTextDelta, WSThinkingDelta, WSToolExecuted, WSToolProgress, WSToolUseStart } from './protocol-core.js';
|
|
7
|
-
import type { WSCompactionFailed, WSContextCompacted, WSContextDebug, WSContextEditorApplied, WSContextEditorSnapshot, WSContextEditorValidation, WSContextMaxContext, WSContextModeChanged, WSContextModesList, WSContextPct, WSContextRepaired, WSDelegateCompleted, WSDelegateStarted, WSError, WSMemoryList, WSSessionStats, WSTokenCostEstimateUnavailable, WSTokenThreshold, WSToolConfirmNeeded, WSToolLoopDetected, WSToolsList, WSTrustPersisted } from './runtime.js';
|
|
7
|
+
import type { WSCompactionFailed, WSContextCompacted, WSContextDebug, WSContextEditorApplied, WSContextEditorSnapshot, WSContextEditorValidation, WSContextMaxContext, WSContextModeChanged, WSContextModesList, WSContextPct, WSContextRepaired, WSDelegateCompleted, WSDelegateStarted, WSError, WSMemoryList, WSSessionStats, WSTokenCostEstimateUnavailable, WSTokenThreshold, WSToolConfirmNeeded, WSToolLoopDetected, WSToolsList, WSTopicAdviceResult, WSTrustPersisted } from './runtime.js';
|
|
8
8
|
import type { WSMemorySageBackfillRecoverable, WSMemorySageCandidateResolve, WSMemorySageDelete, WSMemorySageForFile, WSMemorySageGet, WSMemorySageGraph, WSMemorySageList, WSMemorySageListPage, WSMemorySageRecover, WSMemorySageRemember, WSMemorySageUpdate } from './sage.js';
|
|
9
9
|
import type { WSDesignList, WSDesignMaterialize, WSDesignSet, WSDesignState, WSDesignSwap, WSDesignTune, WSDesignUse, WSDesignVerify, WSSkillContent, WSSkillsCreated, WSSkillsEdited, WSSkillsExported, WSSkillsInstalled, WSSkillsList, WSSkillsUninstalled, WSSkillsUpdated } from './skills-design.js';
|
|
10
|
-
import type { WSAuthOAuthStatus, WSCatalogModelSearchResult, WSCompletionResult, WSDiagGet, WSFilesList, WSKeyOperationResult, WSModelSwitchResult, WSProviderCatalog, WSProviderModels, WSProviderProbe, WSSavedProviders,
|
|
11
|
-
export type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSThinkingDelta | WSToolUseStart | WSToolProgress | WSToolExecuted | WSCodeMapToolStarted | WSCodeMapToolExecuted | WSIterationStarted | WSIterationCompleted | WSIterationLimitReached | WSProviderResponse | WSProviderRetry | WSProviderError | WSProviderFallback | WSProviderFallbackPending | WSProviderStatusChanged | WSProviderStatusSnapshot | WSProviderActiveBlocked | WSProviderStreamError | WSRunResult | WSSessionStats | WSError | WSToolConfirmNeeded | WSTrustPersisted | WSToolLoopDetected | WSDelegateStarted | WSDelegateCompleted | WSContextDebug | WSContextCompacted | WSCompactionFailed | WSContextRepaired | WSContextEditorSnapshot | WSContextEditorValidation | WSContextEditorApplied | WSContextPct | WSContextMaxContext | WSTokenThreshold | WSTokenCostEstimateUnavailable | WSContextModesList | WSContextModeChanged | WSToolsList | WSMemoryList | WSMemorySageList | WSMemorySageListPage | WSMemorySageGet | WSMemorySageGraph | WSMemorySageUpdate | WSMemorySageRemember | WSMemorySageDelete | WSMemorySageRecover | WSMemorySageCandidateResolve | WSMemorySageBackfillRecoverable | WSMemorySageForFile | WSSkillsList | WSSkillContent | WSDesignList | WSDesignUse | WSDesignState | WSDesignSet | WSDesignTune | WSDesignSwap | WSDesignMaterialize | WSDesignVerify | WSSkillsInstalled | WSSkillsUninstalled | WSSkillsUpdated | WSSkillsCreated | WSSkillsEdited | WSSkillsExported | WSDiagGet | WSStatsGet | {
|
|
10
|
+
import type { WSAuthOAuthStatus, WSCatalogModelSearchResult, WSCompletionResult, WSDiagGet, WSFilesList, WSKeyOperationResult, WSModelSwitchResult, WSProviderCatalog, WSProviderModels, WSProviderProbe, WSSavedProviders, WSSessionInspect, WSSessionsList, WSSideEffects, WSStatsGet, WSTodosCleared, WSTodosUpdated } from './system.js';
|
|
11
|
+
export type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSThinkingDelta | WSToolUseStart | WSToolProgress | WSToolExecuted | WSCodeMapToolStarted | WSCodeMapToolExecuted | WSIterationStarted | WSIterationCompleted | WSIterationLimitReached | WSProviderResponse | WSProviderRetry | WSProviderError | WSProviderFallback | WSProviderFallbackPending | WSProviderStatusChanged | WSProviderStatusSnapshot | WSProviderActiveBlocked | WSProviderStreamError | WSRunResult | WSSessionStats | WSError | WSToolConfirmNeeded | WSTrustPersisted | WSToolLoopDetected | WSDelegateStarted | WSDelegateCompleted | WSContextDebug | WSContextCompacted | WSCompactionFailed | WSContextRepaired | WSContextEditorSnapshot | WSContextEditorValidation | WSContextEditorApplied | WSContextPct | WSTopicAdviceResult | WSContextMaxContext | WSTokenThreshold | WSTokenCostEstimateUnavailable | WSContextModesList | WSContextModeChanged | WSToolsList | WSMemoryList | WSMemorySageList | WSMemorySageListPage | WSMemorySageGet | WSMemorySageGraph | WSMemorySageUpdate | WSMemorySageRemember | WSMemorySageDelete | WSMemorySageRecover | WSMemorySageCandidateResolve | WSMemorySageBackfillRecoverable | WSMemorySageForFile | WSSkillsList | WSSkillContent | WSDesignList | WSDesignUse | WSDesignState | WSDesignSet | WSDesignTune | WSDesignSwap | WSDesignMaterialize | WSDesignVerify | WSSkillsInstalled | WSSkillsUninstalled | WSSkillsUpdated | WSSkillsCreated | WSSkillsEdited | WSSkillsExported | WSDiagGet | WSStatsGet | {
|
|
12
12
|
type: 'connections.health_result';
|
|
13
13
|
payload: ConnectionsHealthReport;
|
|
14
14
|
} | {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/webui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.301.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Browser-based WebUI for WrongStack — React + Vite frontend. The WebSocket backend lives in the separate @wrongstack/webui-server package (extracted in PR #018b to remove the CLI -> @wrongstack/webui/server cross-package edge).",
|
|
6
6
|
"keywords": [
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"tailwind-merge": "^3.6.0",
|
|
77
77
|
"virtua": "^0.49.3",
|
|
78
78
|
"zustand": "^5.0.14",
|
|
79
|
-
"@wrongstack/
|
|
80
|
-
"@wrongstack/
|
|
81
|
-
"@wrongstack/
|
|
82
|
-
"@wrongstack/
|
|
83
|
-
"@wrongstack/
|
|
84
|
-
"@wrongstack/webui-server": "0.
|
|
79
|
+
"@wrongstack/kanban": "0.301.0",
|
|
80
|
+
"@wrongstack/core": "0.301.0",
|
|
81
|
+
"@wrongstack/providers": "0.301.0",
|
|
82
|
+
"@wrongstack/tools": "0.301.0",
|
|
83
|
+
"@wrongstack/plugins": "0.301.0",
|
|
84
|
+
"@wrongstack/webui-server": "0.301.0"
|
|
85
85
|
},
|
|
86
86
|
"optionalDependencies": {
|
|
87
87
|
"node-pty": "1.2.0-beta.14"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"typescript": "^7.0.2",
|
|
104
104
|
"vite": "^8.1.5",
|
|
105
105
|
"vitest": "^4.1.10",
|
|
106
|
-
"@wrongstack/sdd": "0.
|
|
106
|
+
"@wrongstack/sdd": "0.301.0"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"dev": "vite",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{Ai as n,Ii as r,Oa as i,Ot as a,Pa as o,Qi as s,Wi as c,Wt as l,Xr as u,Zt as d,an as f,da as p,dt as m,ft as h,hr as g,ir as _,jt as v,la as y,lt as b,pr as x,tn as S,ua as C,ut as w,vi as T,vn as E,yi as D,za as O}from"./vendor-BuarzSSb.js";import"./i18n-C31PI0Up.js";import{t as k}from"./ws-client-Bw1ixxwI.js";import{t as A}from"./utils-B-9lSDIn.js";import{w as j}from"./stores-OBoFiAKe.js";import{n as M}from"./ui-store-CE4-TlwB.js";import{n as N}from"./Toaster-DSKFSuK3.js";import{n as P,t as F}from"./ModelPicker-B3BqjJnT.js";import{s as I}from"./index-D1izXztg.js";import{t as L}from"./roster-ws-D6dGRfC5.js";var R=e(O(),1),z=b(),B=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],V=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function H(e){return`${e.provider}/${e.model}`}function U(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function W(e){return Array.isArray(e)?e.join(`, `):``}function G(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function K({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let{t:a}=o(),[s,c]=(0,R.useState)(()=>structuredClone(e)),l=P(!0),u=s.modelPolicy,f=(0,R.useMemo)(()=>(u?.allowed??[]).map(H),[u?.allowed]),p=(0,R.useMemo)(()=>(u?.fallbacks??[]).map(H),[u?.fallbacks]),m=e=>c(t=>({...t,...e})),h=(e,t)=>{let n=G(t);c(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},g=(e,t)=>{c(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},_=e=>{let t=e.map(U),n=new Set(e);c(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(H(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,z.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,z.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,z.jsx)(`span`,{children:a(`activity:runtimePolicy.protectedSystemAgentRequiredToolsAnd`)})]}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.providerAndModelPolicy`)}),(0,z.jsx)(F,{candidates:l,provider:s.provider,value:s.model,placeholder:a(`activity:runtimePolicy.useProjectDefaultModel`),resetLabel:`Use project default`,onReset:()=>{c(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;m({provider:t,model:e}),u&&!f.includes(n)&&_([...f,n])}}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:!!u,onChange:e=>{if(e.target.checked){let e=s.provider&&s.model?[{provider:s.provider,model:s.model}]:l[0]?[{provider:l[0].provider,model:l[0].model}]:[];e.length&&m({modelPolicy:{allowed:e,strict:!0}})}else c(e=>{let t={...e};return delete t.modelPolicy,t})}}),a(`activity:runtimePolicy.restrictThisAgentToAnExplicit`)]}),u&&(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium`,children:a(`activity:runtimePolicy.allowedModels`)}),(0,z.jsx)(I,{value:f,candidates:l,onChange:_,placeholder:a(`activity:runtimePolicy.addAllowedModel`),emptyHint:`At least one model is required`})]}),(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium`,children:a(`activity:runtimePolicy.orderedFallbackChain`)}),(0,z.jsx)(I,{value:p,candidates:l,onChange:e=>{let t=[...new Set([...f,...e])];c(n=>({...n,modelPolicy:{allowed:t.map(U),fallbacks:e.map(U),strict:n.modelPolicy?.strict??!0}}))},placeholder:a(`activity:runtimePolicy.addFallbackModel`),emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,z.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,z.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:t}),(0,z.jsx)(`textarea`,{value:W(s[e]),onChange:t=>h(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.workspaceAndIsolation`)}),(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,z.jsx)(`span`,{children:a(`activity:runtimePolicy.projectRelativeWorkingDirectory`)}),(0,z.jsx)(`input`,{value:s.cwd??``,onChange:e=>m({cwd:e.target.value||void 0}),placeholder:a(`activity:runtimePolicy.packagesWebui`),className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,z.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,z.jsx)(`span`,{children:a(`activity:runtimePolicy.gitWorktreeIsolation`)}),(0,z.jsxs)(`select`,{value:String(s.worktree??`auto`),onChange:e=>m({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,z.jsx)(`option`,{value:`auto`,children:a(`activity:runtimePolicy.automatic`)}),(0,z.jsx)(`option`,{value:`required`,children:a(`activity:runtimePolicy.required`)}),(0,z.jsx)(`option`,{value:`off`,children:a(`activity:runtimePolicy.off`)})]})]})]})]}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h4`,{className:`text-xs font-semibold`,children:a(`activity:runtimePolicy.limits`)}),(0,z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:V.map(([e,t])=>(0,z.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,z.jsx)(`span`,{children:t}),(0,z.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:s.budget?.[e]??``,onChange:t=>g(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:!!s.availability,onChange:e=>{e.target.checked?m({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):c(e=>{let t={...e};return delete t.availability,t})}}),a(`activity:runtimePolicy.workingHours`)]}),s.availability&&(0,z.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:B.map((e,t)=>(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:s.availability?.days.includes(t)??!1,onChange:e=>{let n=s.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);m({availability:{...n,days:r}})}}),e]},e))}),(0,z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,z.jsx)(`input`,{value:s.availability.timezone,onChange:e=>m({availability:{...s.availability,timezone:e.target.value}}),placeholder:a(`activity:runtimePolicy.europeKiev`),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,z.jsx)(`input`,{type:`time`,value:s.availability.start,onChange:e=>m({availability:{...s.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,z.jsx)(`input`,{type:`time`,value:s.availability.end,onChange:e=>m({availability:{...s.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,z.jsxs)(`select`,{value:t?`advisory`:s.availability.mode??`enforce`,disabled:t,onChange:e=>m({availability:{...s.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,z.jsx)(`option`,{value:`enforce`,children:a(`activity:runtimePolicy.enforce`)}),(0,z.jsx)(`option`,{value:`advisory`,children:a(`activity:runtimePolicy.advisory`)})]})]})]})]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:n||!!(u&&u.allowed.length===0),onClick:()=>r(s),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:a(`activity:runtimePolicy.cancel`)})]})]})}var q=[{id:`live`,icon:(0,z.jsx)(i,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLive`},{id:`catalog`,icon:(0,z.jsx)(C,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCatalog`},{id:`learning`,icon:(0,z.jsx)(p,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLearning`},{id:`customize`,icon:(0,z.jsx)(S,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCustomize`}],J=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function Y({customStats:e,rosterLoading:t,onRefresh:n}){let{t:r}=o();return(0,z.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,z.jsx)(x,{className:`h-4 w-4 text-primary`})}),(0,z.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,z.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:r(`activity:agentRoster.heading`)}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:r(`activity:agentRoster.headerSummary`,{customized:e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,entries:e.reduce((e,t)=>e+t.entryCount,0)})})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,z.jsx)(_,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,z.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:r(`activity:agentRoster.refreshRosterData`),children:[(0,z.jsx)(E,{className:`h-3 w-3`}),` `,r(`common:action.refresh`)]})]})]})})}function X({activeTab:e,onTabChange:t}){let{t:n}=o();return(0,z.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:q.map(r=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(r.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===r.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[r.icon,n(r.labelKey)]},r.id))})}function ee({customStats:e,onRefresh:n}){let{t:r}=o(),[i,s]=(0,R.useState)(null),[u,d]=(0,R.useState)(null),[f,m]=(0,R.useState)({}),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)(!1),[S,E]=(0,R.useState)(!1),[D,O]=(0,R.useState)(null),[j,P]=(0,R.useState)(!1),[F,I]=(0,R.useState)(!1),B=(0,R.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),V=(0,R.useMemo)(()=>i?B.find(e=>e.role===i):null,[i,B]),H=(0,R.useCallback)(async e=>{E(!0),d(null);try{let t=await L(`agent-roster.read-learned`,{role:e});d(t.entries??[]),m({})}catch{}E(!1)},[]),U=(0,R.useCallback)(async()=>{if(!i||!u)return;x(!0);let e=u.filter((e,t)=>f[t]!==`drop`).join(`
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
`);try{await L(`agent-roster.update-learned`,{role:i,content:e}),d(null),m({})}catch{}x(!1)},[i,u,f]),W=(0,R.useCallback)(async()=>{if(!(!i||!h.trim())){y(null),x(!0);try{let e=`> Taught ${new Date().toISOString().slice(0,10)}\n\n${h.trim()}`;(await L(`agent-roster.append-learned`,{role:i,content:e})).success?(y({ok:!0,msg:r(`activity:customRoster.behaviorSaved`)}),g(``),n()):y({ok:!1,msg:r(`activity:agentRoster.saveFailed`)})}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.failed`)})}x(!1)}},[n,i,h]),G=(0,R.useCallback)(async(e,t)=>{x(!0),y(null);try{let i=await L(`agent-roster.update-learning`,{role:e,enabled:t});if(i.error)throw Error(i.error);y({ok:!0,msg:r(t?`activity:agentRoster.learningResumed`:`activity:agentRoster.autoLearningPaused`)}),n()}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.policyUpdateFailed`)})}finally{x(!1)}},[n]),K=(0,R.useCallback)(async e=>{try{let t=await L(`agent-roster.read-consolidated`,{role:e});O(t.isConsolidated?t.content:null)}catch{O(null)}},[]),q=(0,R.useCallback)(async e=>{P(!0),y(null);try{let i=await L(`agent-roster.consolidate`,{role:e});if(i.error)throw Error(i.error);if(i.rawEntryCount===0){y({ok:!1,msg:r(`activity:agentRoster.noRawEntries`)});return}if(i.consolidated){await n(),await K(e),y({ok:!0,msg:r(`activity:agentRoster.optimizedOk`)}),N.success(i.model?r(`activity:agentRoster.consolidatedWithModel`,{model:i.model}):r(`activity:agentRoster.consolidatedPlain`));return}if(i.emptySynthesis){y({ok:!1,msg:r(`activity:agentRoster.emptySynthesis`)}),N.error(r(`activity:agentRoster.optimizationEmptyToast`));return}let a=i.instruction;if(!a)throw Error(`No consolidation instruction generated`);let o=t.getState();o.addMessage({role:`user`,content:a}),o.setLoading(!0),k().sendMessage(a);let s=M.getState();s.setSidebarOpen(!1),s.setCurrentView(`chat`),y({ok:!0,msg:r(`activity:agentRoster.noActiveModelMsg`)}),N.info(r(`activity:agentRoster.noActiveModelToast`))}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.optimizationFailed`)}),N.error(e instanceof Error?e.message:r(`activity:agentRoster.optimizationFailed`))}finally{P(!1)}},[n,K]),J=(0,R.useCallback)(async e=>{if(e.length!==0){I(!0),y(null);try{let n=[],r=0,a=0,o=``,s=[];for(let t of e)try{let e=await L(`agent-roster.consolidate`,{role:t});e.error?(a++,o=e.error):e.consolidated?n.push(t):e.rawEntryCount===0?r++:e.emptySynthesis?(a++,o=`Model returned an empty result`):e.instruction?s.push({role:t,instruction:e.instruction}):(a++,o=`No consolidation produced`)}catch(e){a++,o=e instanceof Error?e.message:String(e)}if(i&&n.includes(i)&&await K(i),s.length>0){let e=`Optimize the learned data for ${s.length} agent${s.length>1?`s`:``}. For each agent below, read its raw learned entries, synthesize them into a single narrowly-scoped document preserving every fact, and save the result to its consolidated.md file.\n\n`+s.map(e=>`## Agent: ${e.role}\n\n${e.instruction}`).join(`
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
`),n=t.getState();n.addMessage({role:`user`,content:e}),n.setLoading(!0),k().sendMessage(e);let r=M.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}if(n.length===0&&s.length===0){if(a>0){let t=r>0?` ${r} skipped.`:``,n=`Bulk consolidate failed for ${a} of ${e.length} agent${e.length>1?`s`:``}.${o?` Last error: ${o}`:``}${t}`;y({ok:!1,msg:n});return}let t=r>0?`Bulk optimize: ${r} skipped (no entries to optimize).`:`No agents had optimizable entries.`;y({ok:!0,msg:t}),N.info(t,6e3);return}let c=[];n.length>0&&c.push(`${n.length} consolidated`),s.length>0&&c.push(`${s.length} sent to chat`),r>0&&c.push(`${r} skipped`),a>0&&c.push(`${a} failed`);let l=`Bulk optimize: ${c.join(`, `)}.`;y({ok:a===0,msg:l}),n.length>0&&s.length===0?N.success(l,6e3):N.info(l,6e3)}catch(e){y({ok:!1,msg:e instanceof Error?e.message:r(`activity:agentRoster.bulkOptimizationFailed`)}),N.error(e instanceof Error?e.message:r(`activity:agentRoster.bulkOptimizationFailed`))}finally{I(!1)}}},[i,K]);return B.length===0?(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,z.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,z.jsx)(T,{className:`h-10 w-10 mx-auto opacity-30`}),(0,z.jsx)(`p`,{className:`text-sm`,children:r(`activity:agentRoster.noSelfLearningDataYet`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:r(`activity:agentRoster.learningsEmpty`)})]})}):(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,i?`w-80 shrink-0`:`flex-1`),children:[(0,z.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,z.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,z.jsx)(T,{className:`h-3.5 w-3.5 text-brand-2`}),r(`activity:agentRoster.allRosterAgents`)]}),(()=>{let e=B.filter(e=>e.needsSummarization);return e.length===0?null:(0,z.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(w,{className:`h-3 w-3 text-warning shrink-0`}),(0,z.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[e.length,` agent`,e.length>1?`s`:``,` need`,e.length===1?`s`:``,` optimization`]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let t=e[0];t&&(s(t.role),d(null),O(null))},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:r(`activity:agentRoster.review`)})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>J(e.map(e=>e.role)),disabled:F,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[F?(0,z.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(w,{className:`h-3 w-3`}),F?r(`activity:agentRoster.optimizing`):r(`activity:agentRoster.optimizeAll`,{count:e.length})]})]})})()]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:B.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.role),d(null),O(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,i===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&i!==e.role&&`border-warning/40`),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,z.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?r(`activity:agentRoster.learning`):r(`activity:agentRoster.paused`)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),e.lastCapture&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,z.jsx)(w,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]}),(0,z.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[!i&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:r(`activity:agentRoster.selectAnAgentToViewLearning`)}),i&&V&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{className:`text-base font-semibold`,children:i}),(0,z.jsx)(`div`,{className:`flex gap-1`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>G(i,!V.learningEnabled),disabled:b,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,V.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,z.jsx)(T,{className:`h-3 w-3`}),` `,V.learningEnabled?r(`activity:agentRoster.learningOn`):r(`activity:agentRoster.learningPaused`)]})})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.entries`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.entryCount})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.size`)}),(0,z.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[V.totalBytes,`B`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.lastCapture`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.lastCapture?new Date(V.lastCapture).toLocaleDateString():`—`})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:r(`activity:agentRoster.lifetimeCaptures`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:V.lifetimeCaptureCount})]})]}),V.needsSummarization&&(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,z.jsx)(a,{className:`h-4 w-4 shrink-0`}),(0,z.jsx)(`span`,{className:`flex-1`,children:r(`activity:agentRoster.learningsLimitExceeded`,{bytes:V.totalBytes.toLocaleString()})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>q(i),disabled:j,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[j?(0,z.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(w,{className:`h-3 w-3`}),j?r(`activity:agentRoster.optimizing`):`Optimize Now`]})]}),(0,z.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(l,{className:`h-4 w-4 text-primary`}),(0,z.jsx)(`span`,{className:`text-xs font-semibold`,children:r(`activity:agentRoster.optimizeLearnings`)})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>q(i),disabled:j||V.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:V.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[j?(0,z.jsx)(_,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(w,{className:`h-3.5 w-3.5`}),j?r(`activity:agentRoster.optimizing`):`Optimize`]})]}),(0,z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,V.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),V.isConsolidated&&V.consolidation&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,z.jsx)(c,{className:`h-3 w-3 text-success`}),(0,z.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(V.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,V.consolidation.sourceBytes,`B →`,` `,V.consolidation.consolidatedBytes,`B`,V.consolidation.sourceEntryCount<V.entryCount&&(0,z.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,V.entryCount-V.consolidation.sourceEntryCount,` `,r(`activity:agentRoster.newPending`)]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{D===null?K(i):O(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:D===null?r(`activity:agentRoster.viewAction`):`Hide`})]}),D!==null&&(0,z.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,i]}),(0,z.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:D||`(empty)`})]})]}),V.entryCount>0&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>H(i),disabled:S,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[S?(0,z.jsx)(_,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(C,{className:`h-3 w-3`}),`Review Learned Entries (`,V.entryCount,`)`]})}),u&&(0,z.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium`,children:[u.filter((e,t)=>f[t]!==`drop`).length,`/`,u.length,` kept`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:U,disabled:b,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:b?r(`activity:agentRoster.applying`):`Apply Selection`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:r(`activity:agentRoster.cancel`)})]})]}),(0,z.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:u.map((e,t)=>{let n=f[t]??`keep`,i=e.length>200?e.slice(0,200)+`…`:e;return(0,z.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,z.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:i}),(0,z.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:r(`activity:agentRoster.keep`)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:r(`activity:agentRoster.drop`)})]})]})},t)})})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,z.jsx)(p,{className:`h-4 w-4 text-brand-2`}),` `,r(`activity:agentRoster.teachThisAgent`)]}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`activity:agentRoster.describeACommandPatternOrBehavior`)}),(0,z.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:h,onChange:e=>g(e.target.value),placeholder:r(`activity:agentRoster.eGAlwaysUsePnpmForThisProject`)}),(0,z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:W,disabled:!h.trim()||b,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),` `,r(`activity:agentRoster.teach`)]}),v&&(0,z.jsx)(`span`,{className:A(`text-xs`,v.ok?`text-success`:`text-destructive`),children:v.msg})]})]})]})]})]})}function te({customStats:e,catalog:t}){let{t:n}=o(),r=(0,R.useCallback)(e=>n(`activity:rosterRoles.${e.role}.name`,{defaultValue:e.name}),[n]),a=(0,R.useCallback)(e=>n(`activity:rosterRoles.${e.role}.summary`,{defaultValue:e.summary}),[n]),[c,l]=(0,R.useState)(``),[d,p]=(0,R.useState)(null),h=(0,R.useMemo)(()=>new Set(e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).map(e=>e.role)),[e]),g=(0,R.useMemo)(()=>{if(!c.trim())return t;let e=c.toLowerCase();return t.filter(t=>t.role.includes(e)||r(t).toLowerCase().includes(e)||a(t).toLowerCase().includes(e))},[t,c,r,a]),_=(0,R.useCallback)(t=>e.find(e=>e.role===t),[e]),v=g;return(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3 py-1.5`,children:[(0,z.jsx)(f,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:n(`activity:agentRoster.searchPlaceholder`),className:`flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/50`}),c&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>l(``),className:`text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(m,{className:`h-3 w-3`})})]})}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:v.map(e=>{let t=_(e.role),o=h.has(e.role),c=d===e.role;return(0,z.jsxs)(`div`,{className:A(`rounded-lg border bg-card transition-colors`,c?`border-primary/40 ring-1 ring-primary/20`:`border-border/60 hover:border-primary/30`),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>p(c?null:e.role),className:`w-full text-left p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(y,{className:`h-4 w-4 shrink-0 text-primary`}),(0,z.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:r(e)}),(0,z.jsxs)(`code`,{className:`text-[9px] text-muted-foreground font-mono shrink-0`,children:[`@`,e.role]})]}),(0,z.jsx)(s,{className:A(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,c&&`rotate-180`)})]}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1 leading-relaxed line-clamp-2`,children:a(e)}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:n(`activity:agentRoster.toolsCount`,{count:e.tools})}),e.budget.maxIterations&&(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:n(`activity:agentRoster.maxItShort`,{count:e.budget.maxIterations,value:e.budget.maxIterations.toLocaleString()})}),o&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-brand-2/10 px-1 py-0.5 text-[8px] text-brand-2 font-medium`,children:[(0,z.jsx)(u,{className:`h-2.5 w-2.5`}),` `,n(`activity:agentRoster.customizedBadge`)]}),t?.needsSummarization&&(0,z.jsx)(`span`,{className:`text-[9px] text-warning`,children:n(`activity:agentRoster.needsSummary`)})]})]}),c&&(0,z.jsxs)(`div`,{className:`border-t border-border/50 px-3 py-2 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.maxIterations`)}),(0,z.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxIterations?.toLocaleString()??`—`})]}),(0,z.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.timeout`)}),(0,z.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.timeoutMs?`${Math.round(e.budget.timeoutMs/6e4)}m`:`—`})]}),(0,z.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.maxToolCalls`)}),(0,z.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxToolCalls?.toLocaleString()??`—`})]}),(0,z.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.customizedBadge`)}),(0,z.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:n(o?`common:action.yes`:`common:action.no`)})]})]}),o&&t&&(0,z.jsxs)(`div`,{className:`rounded bg-accent/30 p-2 space-y-1`,children:[(0,z.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground`,children:n(`activity:agentRoster.projectCustomizations`)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[9px]`,children:[t.hasIdentity&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,z.jsx)(u,{className:`h-2.5 w-2.5 text-primary`}),` identity.md`]}),t.entryCount>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,z.jsx)(T,{className:`h-2.5 w-2.5 text-brand-2`}),` `,n(`activity:agentRoster.learnedEntriesCount`,{count:t.entryCount})]}),t.hasConfig&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,z.jsx)(S,{className:`h-2.5 w-2.5 text-muted-foreground`}),` config.json`]}),t.sessionCaptureCount>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,z.jsx)(i,{className:`h-2.5 w-2.5 text-success`}),` `,n(`activity:agentRoster.sessionCapturesCount`,{count:t.sessionCaptureCount})]})]})]})]})]},e.role)})}),v.length===0&&(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-40 text-muted-foreground`,children:[(0,z.jsx)(f,{className:`h-8 w-8 mb-2 opacity-30`}),(0,z.jsx)(`p`,{className:`text-sm`,children:n(`activity:agentRoster.noAgentsMatch`,{query:c})})]})]}),(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:t.length}),` `,n(`activity:agentRoster.footerRosterRoles`,{count:t.length})]}),(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsxs)(`span`,{className:`text-brand-2`,children:[(0,z.jsx)(`strong`,{children:h.size}),` `,n(`activity:agentRoster.footerCustomized`,{count:h.size})]}),(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:e.reduce((e,t)=>e+t.entryCount,0)}),` `,n(`activity:agentRoster.footerTotalLearned`,{count:e.reduce((e,t)=>e+t.entryCount,0)})]})]})]})}var Z={running:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,z.jsx)(`span`,{className:`led text-success led-pulse`}),color:`text-success`},completed:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,z.jsx)(c,{className:`h-3.5 w-3.5`}),color:`text-success`},failed:{led:`bg-destructive`,badge:`bg-destructive/15 text-destructive`,icon:(0,z.jsx)(r,{className:`h-3.5 w-3.5`}),color:`text-destructive`},timeout:{led:`bg-warning`,badge:`bg-muted text-muted-foreground`,icon:(0,z.jsx)(n,{className:`h-3.5 w-3.5`}),color:`text-warning`},stopped:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,z.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`},idle:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,z.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`}};function Q(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function $(e){if(e==null||!Number.isFinite(e)||e<=0)return`$0`;if(e<.01){let t=e.toFixed(5);return t===`0.00000`?`$0`:`$`+t.replace(/(\d)0+$/,`$1`).replace(/\.$/,``)}return`$`+e.toFixed(3)}function ne({nowTick:e}){let{t}=o(),n=j(e=>e.agents),r=j(e=>e.leaderId),[i,a]=(0,R.useState)(null),[s,c]=(0,R.useState)(`all`),l=(0,R.useMemo)(()=>{let e=Array.from(n.values());return e.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?t.startedAt-e.startedAt:n-r}),s===`all`?e:s===`running`?e.filter(e=>e.status===`running`):s===`done`?e.filter(e=>e.status===`completed`):s===`failed`?e.filter(e=>e.status===`failed`||e.status===`timeout`):e},[n,s]),u=(0,R.useMemo)(()=>{let e=0,t=0,r=0;for(let i of n.values())i.status===`running`?e++:i.status===`completed`?t++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:e,completed:t,failed:r,total:n.size}},[n]),d=j(e=>e.clearFinishedAgents),f=i?l.find(e=>e.id===i):null,p=(0,R.useCallback)(e=>{let t=M.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]);return l.length===0?(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,z.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,z.jsx)(y,{className:`h-10 w-10 mx-auto opacity-30`}),(0,z.jsx)(`p`,{className:`text-sm`,children:t(`activity:agentRoster.noActiveFleetAgents`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:t(`activity:agentRoster.liveEmpty`)})]})}):(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden`,f?`w-80 shrink-0 border-r border-border/50`:`flex-1`),children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-3 py-2 border-b border-border/50`,children:[[`all`,`running`,`done`,`failed`].map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:A(`rounded px-2 py-0.5 text-[10px] font-medium transition-colors`,s===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[e===`all`&&t(`activity:agentRoster.filterAll`,{count:u.total}),e===`running`&&t(`activity:agentRoster.filterRunning`,{count:u.running}),e===`done`&&t(`activity:agentRoster.filterDone`,{count:u.completed}),e===`failed`&&t(`activity:agentRoster.filterFailed`,{count:u.failed})]},e)),(0,z.jsx)(`span`,{className:`flex-1`}),u.completed+u.failed>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:d,className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,z.jsx)(v,{className:`h-2.5 w-2.5`}),` `,t(`activity:agentRoster.clear`)]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:l.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(i===e.id?null:e.id),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors flex items-center gap-2`,i===e.id?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30 hover:bg-primary/[0.03]`),children:[(0,z.jsx)(`span`,{className:A(`led shrink-0`,Z[e.status]?.led??`bg-muted-foreground`,e.status===`running`&&`led-pulse`)}),(0,z.jsx)(`span`,{className:`text-xs font-semibold min-w-0 truncate max-w-[7rem]`,children:e.name}),e.id===r&&(0,z.jsx)(D,{className:`h-3 w-3 shrink-0 text-warning`}),e.model&&(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground font-mono truncate max-w-[6rem] shrink-0`,children:e.model}),(0,z.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums shrink-0`,children:[e.iteration,`it · `,e.toolCalls,`t`]}),e.status===`running`&&(0,z.jsx)(`span`,{className:`text-[9px] text-primary tabular-nums shrink-0 ml-auto`,children:Q(Date.now()-e.startedAt)}),e.status!==`running`&&(0,z.jsx)(`span`,{className:A(`text-[9px] tabular-nums shrink-0 ml-auto`,Z[e.status]?.color??`text-muted-foreground`),children:e.status}),e.costUsd>0&&(0,z.jsx)(`span`,{className:`text-[9px] text-success tabular-nums font-medium shrink-0`,children:$(e.costUsd)}),e.status===`running`&&e.currentTool&&(0,z.jsxs)(`span`,{className:`text-[9px] text-primary font-mono truncate max-w-[6rem] shrink-0`,children:[`→ `,e.currentTool]})]},e.id))}),(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium tabular-nums`,children:u.total}),` `,t(`activity:agentRoster.agentsTotal`),(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsx)(`span`,{className:`text-success tabular-nums`,children:u.running}),` running`,(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:u.completed}),` done`,u.failed>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsx)(`span`,{className:`text-destructive tabular-nums`,children:u.failed}),` failed`]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>p(),className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 hover:bg-accent transition-colors`,children:[(0,z.jsx)(g,{className:`h-3 w-3`}),t(`activity:agentRoster.fleetInspector`)]})]})]}),f&&(0,z.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:(0,z.jsx)(re,{agent:f,nowTick:e})})]})}function re({agent:e,nowTick:t}){let{t:n}=o(),r=e.status===`running`?Q(t-e.startedAt):e.completedAt?Q(e.completedAt-e.startedAt):`-`,i=Math.min(100,Math.max(0,e.ctxPct)),a=e.currentTool||e.lastTool,s=j(e=>e.leaderId);return(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,z.jsx)(y,{className:`h-5 w-5 text-primary`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),e.id===s&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[9px] font-medium text-warning`,children:[(0,z.jsx)(D,{className:`h-2.5 w-2.5`}),` `,n(`activity:agentRoster.leader`)]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:A(`led`,Z[e.status]?.led,e.status===`running`&&`led-pulse`)}),(0,z.jsx)(`span`,{children:e.status}),e.model&&(0,z.jsxs)(`span`,{children:[`· `,e.provider,`/`,e.model]}),(0,z.jsxs)(`span`,{children:[`· `,r]})]})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.iterations`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.iteration})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.toolCalls`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.toolCalls})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.cost`)}),(0,z.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5 text-success`,children:$(e.costUsd)})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:n(`activity:agentRoster.context`)}),(0,z.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[i,`%`]})]})]}),e.maxContext>0&&(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:agentRoster.contextWindow`)}),(0,z.jsxs)(`span`,{className:A(`tabular font-medium`,i>=85?`text-destructive`:i>=70?`text-warning`:`text-success`),children:[e.ctxTokens.toLocaleString(),` / `,e.maxContext.toLocaleString(),` tokens`]})]}),(0,z.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:A(`h-full rounded-full transition-all`,i>=85?`bg-destructive`:i>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,i)}%`}})})]}),a&&(0,z.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded-lg border px-3 py-2`,e.status===`running`?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,z.jsx)(h,{className:A(`h-4 w-4`,e.status===`running`?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,z.jsx)(`span`,{className:`text-sm font-mono`,children:e.currentTool??e.lastTool}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?n(`activity:agentRoster.running`):`Last tool`})]}),e.error&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:n(`activity:agentRoster.error`)}),(0,z.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1`,children:e.error.message})]}),e.toolLog.length>0&&(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[`Tool Log (`,e.toolLog.length,`)`]}),(0,z.jsx)(`div`,{className:`space-y-0.5`,children:e.toolLog.slice(0,10).map((e,t)=>(0,z.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded px-2 py-1 text-[10px] font-mono`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,z.jsx)(`span`,{className:A(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,z.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,z.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,z.jsx)(`span`,{className:`text-destructive`,children:`✗`})]},`${e.name}-${t}`))})]}),e.budgetWarning&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,z.jsx)(w,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,z.jsxs)(`span`,{className:`text-warning`,children:[`Budget: `,e.budgetWarning.kind,` limit (`,e.budgetWarning.used,`/`,e.budgetWarning.limit,`)`]})]})]})}function ie(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)(J),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),c=(0,R.useCallback)(async()=>{a(!0),s(null);try{let e=await L(`agent-roster.list`,{});e.stats&&t(e.stats),e.catalog?.length&&r(e.catalog)}catch(e){s(e instanceof Error?e.message:`Failed to load roster`)}a(!1)},[]);return(0,R.useEffect)(()=>{c()},[c]),(0,R.useEffect)(()=>{let e=null,t=k().on(`agent-roster.updated`,()=>{e&&clearTimeout(e),e=setTimeout(()=>{e=null,c()},300)});return()=>{e&&clearTimeout(e),t()}},[c]),{customStats:e,catalog:n,rosterLoading:i,rosterError:o,loadRoster:c}}function ae({customStats:e,catalog:n,onRefresh:r}){let{t:i}=o(),[a,s]=(0,R.useState)(null),[c,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(``),[h,g]=(0,R.useState)(null),[_,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(null),[w,E]=(0,R.useState)(!1),[D,O]=(0,R.useState)({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),j=(0,R.useMemo)(()=>a?e.find(e=>e.role===a):null,[a,e]),N=(0,R.useMemo)(()=>{let e=n.find(e=>e.role===a);return e?.systemProtected??!e?.custom},[n,a]),P=(0,R.useCallback)(async(e,t)=>{y(!0),x(null),s(e);try{let n=await L(`agent-roster.read-customization`,{role:e});m(t===`config`?`${JSON.stringify(n.config??{},null,2)}\n`:n[t]??``),f(t),g(null)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.loadCustomizationFailed`))}finally{y(!1)}},[]),F=(0,R.useCallback)(async e=>{y(!0),x(null),s(e);try{let t=await L(`agent-roster.read-customization`,{role:e});g(t.config??{}),f(null)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.loadRuntimePolicyFailed`))}finally{y(!1)}},[]),I=(0,R.useCallback)(async e=>{if(a){y(!0),x(null);try{await L(`agent-roster.update-config`,{role:a,config:e}),g(null),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.runtimePolicySaveFailed`))}finally{y(!1)}}},[r,a]),B=(0,R.useCallback)(async()=>{if(!(!a||!c)){y(!0);try{let e={identity:`agent-roster.update-identity`,learned:`agent-roster.update-learned`,config:`agent-roster.update-config`},t={role:a};if(c===`config`)try{t.config=JSON.parse(p)}catch{x(`config.json must contain valid JSON`),y(!1);return}else t.content=p;await L(e[c],t),f(null),x(null),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.saveFailed`))}y(!1)}},[a,c,p,r]),V=(0,R.useCallback)(async()=>{if(a)try{let e=await L(`agent-roster.llm-improve`,{role:a,prompt:`Improve this agent for optimal project performance`});if(!e.instruction)throw Error(`No improvement instruction generated`);let n=t.getState();n.addMessage({role:`user`,content:e.instruction}),n.setLoading(!0),k().sendMessage(e.instruction);let r=M.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.llmImprovementFailed`))}},[a]),H=(0,R.useCallback)(async e=>{if(window.confirm(i(`activity:agentRoster.resetConfirm`,{role:e})))try{await L(`agent-roster.reset`,{role:e}),s(null),r()}catch{}},[r]),U=(0,R.useCallback)(async()=>{let e=D.taskTypes.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean);y(!0),x(null);try{let t=await L(`agent-roster.create`,{name:D.name,role:D.role,baseRole:D.baseRole,purpose:D.purpose,taskTypes:e});E(!1),O({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),s(t.role),r()}catch(e){x(e instanceof Error?e.message:i(`activity:agentRoster.agentCreationFailed`))}finally{y(!1)}},[D,r]),W=(0,R.useMemo)(()=>[...e].sort((e,t)=>{let n=+!!e.hasIdentity+ +(e.entryCount>0)+ +!!e.hasConfig;return+!!t.hasIdentity+ +(t.entryCount>0)+ +!!t.hasConfig-n}),[e]);return(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`w-80 shrink-0 border-r border-border/50 flex flex-col overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`shrink-0 border-b border-border/50 px-3 py-2`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold`,children:[(0,z.jsx)(S,{className:`h-3.5 w-3.5`}),i(`activity:agentRoster.projectAgents`)]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{E(!0),s(null),g(null),x(null)},className:`rounded border border-primary/40 px-1.5 py-1 text-[9px] text-primary hover:bg-primary/10`,children:i(`activity:agentRoster.clone`)})]})}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:[W.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.role),g(null),f(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,a===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold`,children:e.role}),(0,z.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[9px] text-muted-foreground`,children:[e.hasIdentity&&(0,z.jsx)(`span`,{className:`text-primary`,children:`id`}),e.entryCount>0&&(0,z.jsxs)(`span`,{className:`text-brand-2`,children:[e.entryCount,`e`]}),e.hasConfig&&(0,z.jsx)(`span`,{children:`cfg`})]})]},e.role)),W.length===0&&(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground text-center py-4`,children:i(`activity:agentRoster.noCustomizations`)})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-y-auto p-4`,children:[w&&(0,z.jsxs)(`div`,{className:`max-w-2xl space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-base font-semibold`,children:i(`activity:agentRoster.createOrCloneTitle`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`activity:agentRoster.createOrCloneHint`)})]}),(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.cloneFromRole`)}),(0,z.jsx)(`select`,{value:D.baseRole,onChange:e=>O(t=>({...t,baseRole:e.target.value})),className:`h-9 w-full rounded border border-border bg-card px-2`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,z.jsxs)(`option`,{value:e.role,children:[e.name,` (`,e.role,`)`]},e.role))}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i(`activity:agentRoster.cloneHint`)})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.displayName`)}),(0,z.jsx)(`input`,{value:D.name,onChange:e=>O(t=>({...t,name:e.target.value})),placeholder:i(`activity:agentRoster.abc`),className:`h-9 w-full rounded border border-border bg-card px-2`})]}),(0,z.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.roleIdOptional`)}),(0,z.jsx)(`input`,{value:D.role,onChange:e=>O(t=>({...t,role:e.target.value})),placeholder:i(`activity:agentRoster.abcGeneratedFromName`),className:`h-9 w-full rounded border border-border bg-card px-2 font-mono`})]})]}),(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.purpose`)}),(0,z.jsx)(`textarea`,{value:D.purpose,onChange:e=>O(t=>({...t,purpose:e.target.value})),placeholder:i(`activity:agentRoster.descriptionPlaceholder`),className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:i(`activity:agentRoster.taskTypesCommaOrOnePer`)}),(0,z.jsx)(`textarea`,{value:D.taskTypes,onChange:e=>O(t=>({...t,taskTypes:e.target.value})),placeholder:i(`activity:agentRoster.taskTypesPlaceholder`),className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),b&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:b}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:U,disabled:_||!D.name.trim()||D.purpose.trim().length<10||!D.taskTypes.trim(),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:_?i(`activity:agentRoster.creating`):`Clone Agent`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>E(!1),className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:i(`activity:agentRoster.cancel`)})]})]}),!w&&!a&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:i(`activity:agentRoster.selectAnAgentToEditCustomizations`)}),!w&&a&&j&&(0,z.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{className:`text-base font-semibold`,children:a}),(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:V,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:[(0,z.jsx)(l,{className:`h-3 w-3 text-brand-2`}),` `,i(`activity:agentRoster.llmImprove`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>H(a),className:`inline-flex items-center gap-1 rounded border border-destructive/30 px-2 py-1 text-[10px] text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,z.jsx)(v,{className:`h-3 w-3`}),` `,i(`activity:agentRoster.reset`)]})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[j.hasIdentity&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:[(0,z.jsx)(u,{className:`h-3 w-3`}),` identity.md`]}),j.hasConfig&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(S,{className:`h-3 w-3`}),` config.json`]}),j.hasKnowledge&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(T,{className:`h-3 w-3`}),` knowledge.json`]}),j.entryCount>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-brand-2/10 px-2 py-1 text-[10px] text-brand-2`,children:[(0,z.jsx)(C,{className:`h-3 w-3`}),` `,j.entryCount,` learned entries`]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`identity`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,z.jsx)(u,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editIdentityMd`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`learned`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,z.jsx)(C,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editLearnedMd`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>F(a),className:`inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/5 px-3 py-1.5 text-xs text-primary hover:bg-primary/10 transition-colors`,children:[(0,z.jsx)(d,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.runtimePolicy`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>P(a,`config`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,z.jsx)(S,{className:`h-3.5 w-3.5`}),` `,i(`activity:agentRoster.editConfigJson`)]})]}),b&&(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:b}),h&&(0,z.jsx)(K,{initialConfig:h,systemProtected:N,saving:_,onSave:I,onCancel:()=>g(null)},a),c&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium`,children:[c,`.md / `,c,`.json`]}),(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:B,disabled:_,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:i(_?`activity:agentRoster.saving`:`common:action.save`)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>f(null),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:i(`activity:agentRoster.cancel`)})]})]}),(0,z.jsx)(`textarea`,{className:`w-full h-48 font-mono text-xs p-2 bg-card border border-border rounded resize-y`,value:p,onChange:e=>m(e.target.value),placeholder:c===`config`?`{ "tools": [...], "budget": {...} }`:`# Project identity for ${a}\n\nDescribe this agent's role…`})]})]})]})]})}function oe({className:e}){let{t}=o(),[n,r]=(0,R.useState)(`live`),[i,s]=(0,R.useState)(Date.now()),{customStats:c,catalog:l,rosterLoading:u,rosterError:d,loadRoster:f}=ie();return(0,R.useEffect)(()=>{let e=setInterval(()=>{document.hidden||s(Date.now())},2e3);return()=>clearInterval(e)},[]),(0,z.jsxs)(`div`,{className:A(`flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,e),children:[(0,z.jsx)(Y,{customStats:c,rosterLoading:u,onRefresh:f}),(0,z.jsx)(X,{activeTab:n,onTabChange:r}),(0,z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-full flex-1 overflow-hidden bg-background/50`,children:[d&&(0,z.jsxs)(`div`,{className:`flex items-center justify-center w-full text-destructive text-xs gap-2`,children:[(0,z.jsx)(a,{className:`h-4 w-4`}),d,(0,z.jsx)(`button`,{type:`button`,onClick:f,className:`underline`,children:t(`activity:agentRoster.retry`)})]}),n===`live`&&(0,z.jsx)(ne,{nowTick:i}),n===`catalog`&&(0,z.jsx)(te,{customStats:c,catalog:l}),n===`learning`&&(0,z.jsx)(ee,{customStats:c,onRefresh:f}),n===`customize`&&(0,z.jsx)(ae,{customStats:c,catalog:l,onRefresh:f})]})]})}export{oe as AgentRosterView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nr as t,Oa as n,Ot as r,Pa as i,Rr as a,Vt as o,Xi as s,Zt as c,an as ee,dt as te,ji as ne,la as l,lt as u,mn as re,oa as d,oi as f,ur as ie,vi as p,vn as ae,za as m}from"./vendor-BuarzSSb.js";import"./i18n-C31PI0Up.js";import{t as h}from"./ws-client-Bw1ixxwI.js";import{t as g}from"./utils-B-9lSDIn.js";import{C as oe,S as se}from"./index-D1izXztg.js";var _=e(m(),1),v=u();function y({status:e}){let{t}=i();return(0,v.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,v.jsxs)(`span`,{children:[`collect `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,v.jsxs)(`span`,{children:[`process `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,v.jsxs)(`span`,{children:[`serve `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,v.jsxs)(`span`,{children:[`PID `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,v.jsxs)(`span`,{children:[`watcher`,` `,(0,v.jsx)(`b`,{className:g(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,v.jsxs)(`span`,{children:[`store `,(0,v.jsx)(`b`,{className:`text-foreground`,children:b(e.pipeline.storage)})]}),e.mode===`inline`&&(0,v.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function b(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var x=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],S=1440*60*1e3;function C(){return{limit:300,order:`desc`,from:new Date(Date.now()-S).toISOString()}}var w=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,v.jsx)(n,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,v.jsx)(d,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,v.jsx)(l,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,v.jsx)(o,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,v.jsx)(f,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,v.jsx)(r,{})}];function T(){let{t:e}=i(),t=h(),[n,r]=(0,_.useState)([]),[s,c]=(0,_.useState)(null),[u,p]=(0,_.useState)({}),[m,b]=(0,_.useState)(C()),[S,T]=(0,_.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,k]=(0,_.useState)(`all`),[N,F]=(0,_.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,L]=(0,_.useState)(D),[R,z]=(0,_.useState)(!0),[B,V]=(0,_.useState)(null),[pe,H]=(0,_.useState)(null),[U,me]=(0,_.useState)([]),[W,he]=(0,_.useState)([]),[G,ge]=(0,_.useState)(null),K=(0,_.useCallback)(e=>{if(!t.supportsCapability(`chronicle.query`)){z(!1),V(`Restart the backend once to activate Chronicle protocol support.`);return}if(z(!0),V(null),b(e),p({}),t.send({type:`chronicle.query`,payload:{query:e}}),t.supportsCapability(`chronicle.facets`))t.send({type:`chronicle.facets`,payload:{fields:[...x],query:e,limit:12}});else for(let n of x)t.send({type:`chronicle.facet`,payload:{field:n,query:e,limit:12}})},[t]),q=(0,_.useCallback)(()=>{t.supportsCapability(`chronicle.metrics`)&&(t.send({type:`chronicle.metrics`,payload:{view:`providers`}}),t.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[t]),J=(0,_.useCallback)(()=>{t.supportsCapability(`chronicle.status`)&&t.send({type:`chronicle.status`})},[t]);(0,_.useEffect)(()=>{let e=t.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(r(e.payload.events),F(e.payload),L(e.payload.summary??D),z(!1))}),n=t.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&p(t=>({...t,[e.payload.field]:e.payload.values}))}),i=t.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&p(e.payload.values)}),a=t.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(V(e.payload.message),z(!1))}),o=t.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),s=t.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?me(e.payload.data):e.payload.view===`tasks`&&he(e.payload.data))}),c=t.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&ge(e.payload)});return K(C()),q(),J(),()=>{e(),n(),i(),a(),o(),s(),c()}},[t,K,q,J]);let Y=(0,_.useMemo)(()=>n.filter(e=>O(e,E)),[n,E]),X=oe(Y,25,E),Z=(0,_.useMemo)(()=>{let e=n.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[n]),Q=(0,_.useMemo)(()=>{let e={};for(let t of W)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...C(),...S.text?{text:S.text}:{},...S.path?{path:S.path}:{},...S.providerId?{providerId:S.providerId}:{},...S.modelId?{modelId:S.modelId}:{},...S.sessionId?{sessionId:S.sessionId}:{}}),_e=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),k(`all`),K(C())},ve=e=>{c(e),H(null),t.supportsCapability(`chronicle.graph`)&&t.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,v.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,v.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,v.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(d,{className:`h-5 w-5 text-primary`}),(0,v.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,v.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:e(`activity:chronicle.chronicle`)})]}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,B?`bg-destructive`:R?`animate-pulse bg-warning`:`bg-success`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:R?`Reading journal`:B?`Unavailable`:`Live evidence`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{K(m),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,v.jsx)(ae,{className:g(`h-4 w-4`,R&&`animate-spin`)})})]})]})}),(0,v.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,v.jsx)(M,{icon:(0,v.jsx)(d,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,v.jsx)(M,{icon:(0,v.jsx)(l,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,v.jsx)(M,{icon:(0,v.jsx)(o,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,v.jsx)(M,{icon:(0,v.jsx)(f,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,v.jsx)(M,{icon:(0,v.jsx)(re,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,v.jsx)(M,{icon:(0,v.jsx)(ne,{}),label:e(`activity:chronicle.providerP95`),value:A(I.providerP95DurationMs),detail:`${A(I.providerAvgDurationMs)} average · all matches`})]}),(0,v.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,v.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`output `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache write`,` `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.length>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,v.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),U.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${A(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(ie,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,v.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,v.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,v.jsx)(`b`,{className:g(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,v.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:A(e.durationMs)}),e.filesTouched>0&&(0,v.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,v.jsx)(f,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,v.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,v.jsx)(j,{icon:(0,v.jsx)(ee,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:S.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:S.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:e(`activity:chronicle.provider`),value:S.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:e(`activity:chronicle.model`),value:S.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:e(`activity:chronicle.session`),value:S.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,v.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,v.jsx)(a,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,v.jsx)(`button`,{type:`button`,onClick:_e,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,v.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[w.map(t=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>k(t.id),className:g(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,v.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,v.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,v.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,v.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,v.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),G&&(0,v.jsx)(y,{status:G}),Z&&(0,v.jsx)(ue,{health:Z}),(0,v.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,v.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(u[e]??[]).slice(0,4).map(t=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({...m,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,v.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,v.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,v.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,v.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,v.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,v.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,v.jsx)(`span`,{})]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:B?(0,v.jsx)(P,{text:B}):!R&&Y.length===0?(0,v.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,v.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,v.jsx)(de,{event:e,active:s?.eventId===e.eventId,onClick:()=>ve(e)},e.eventId))})}),(0,v.jsx)(se,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),s&&(0,v.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,v.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,v.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,s.sequence,` · `,s.eventId]})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded p-1 hover:bg-muted`,children:(0,v.jsx)(te,{className:`h-4 w-4`})})]}),(0,v.jsx)(fe,{event:s,graph:pe})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function ce(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function O(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function k(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function A(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function j({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,v.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,v.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,v.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function M({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,v.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,v.jsx)(`div`,{className:g(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,v.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function ue({health:e}){let{t}=i();return(0,v.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,v.jsxs)(`span`,{children:[`ELU`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[`p95 `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,v.jsxs)(`span`,{children:[`heap`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,v.jsxs)(`span`,{children:[`queue `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,v.jsxs)(`span`,{children:[`dropped`,` `,(0,v.jsx)(`b`,{className:g((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,v.jsxs)(`button`,{type:`button`,onClick:n,className:g(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,v.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,v.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,v.jsx)(`span`,{className:g(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,v.jsx)(s,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:n}){let{t:r}=i(),a=(0,_.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,v.jsxs)(`div`,{className:`p-4`,children:[(0,v.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,v.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,v.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,v.jsx)(`span`,{children:k(Number(e.durationNs??0))})]})]}),(0,v.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,v.jsx)(N,{icon:(0,v.jsx)(c,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,v.jsx)(N,{icon:(0,v.jsx)(p,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),n&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(t,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,v.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,v.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,v.jsx)(`span`,{className:g(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,v.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,v.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),a.map(([e,t])=>t&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,v.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function N({icon:e,label:t,value:n}){return(0,v.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,v.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,v.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{Ai as n,Bt as r,Cn as i,Ct as a,Et as o,Fi as s,Ii as c,La as l,Pa as u,Ti as d,Wi as f,dn as p,dt as m,gr as h,hn as g,ir as _,kn as v,lt as y,mn as b,ut as x,wn as S,za as C}from"./vendor-BuarzSSb.js";import"./i18n-C31PI0Up.js";import{t as ee}from"./useWebSocket-DuLtH2jI.js";import{t as w}from"./utils-B-9lSDIn.js";import{_ as T,g as E,t as D}from"./stores-OBoFiAKe.js";import{o as O}from"./view-navigation-DIDEcp4V.js";import{t as k}from"./button-Dcy288Mc.js";import{h as A,m as te,p as ne,y as j}from"./index-D1izXztg.js";var M=e(C(),1),N=y(),P={pending:{icon:(0,N.jsx)(s,{className:`w-4 h-4`}),color:`text-muted-foreground`},in_progress:{icon:(0,N.jsx)(n,{className:`w-4 h-4 animate-spin`}),color:`text-primary`},blocked:{icon:(0,N.jsx)(v,{className:`w-4 h-4`}),color:`text-warning`},failed:{icon:(0,N.jsx)(c,{className:`w-4 h-4`}),color:`text-destructive`},review:{icon:(0,N.jsx)(b,{className:`w-4 h-4`}),color:`text-info`},completed:{icon:(0,N.jsx)(f,{className:`w-4 h-4`}),color:`text-success`}},F={critical:`bg-destructive/15 text-destructive`,high:`bg-warning/15 text-warning`,medium:`bg-info/15 text-info`,low:`bg-muted text-muted-foreground`},I={feature:`bg-success/15 text-success`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-primary/15 text-primary`,docs:`bg-info/15 text-info`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function L(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 R({task:e,onStatusChange:t,onRetry:r,agents:i,onAssign:o,compact:s,className:c}){let{t:l}=u(),d=P[e.status],[f,p]=(0,M.useState)(!1),m=e.status===`in_progress`;return(0,N.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,m?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-success/35 bg-success/6`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,c),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,N.jsx)(`span`,{className:w(`mt-0.5`,d.color),role:`img`,"aria-label":m?l(`common:status.inProgress`):void 0,children:d.icon}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,N.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,F[e.priority]),children:e.priority}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.type]),children:e.type})]}),e.description&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,N.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,m?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[m&&(0,N.jsx)(n,{className:`w-3 h-3 animate-spin`,"aria-label":l(`common:status.working`)}),(0,N.jsx)(`span`,{children:e.assignee})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,N.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,N.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,N.jsxs)(`span`,{children:[`• `,L(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!s&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,N.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:l(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,children:l(`activity:task.complete`)}),r&&(e.status===`failed`||e.status===`completed`)&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(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,N.jsx)(b,{className:`w-3 h-3`}),` `,l(`activity:task.retry`)]}),o&&i&&i.length>0&&(f?(0,N.jsxs)(`select`,{defaultValue:e.assignee??``,onChange:t=>{o(e.id,t.target.value),p(!1)},onBlur:()=>p(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,N.jsx)(`option`,{value:``,children:l(`activity:task.unassigned`)}),i.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>p(!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:l(`activity:task.assignTitle`),children:[(0,N.jsx)(a,{className:`w-3 h-3`}),` `,l(`activity:task.assign`)]}))]})]})}var z=[{key:`pending`,match:[`pending`,`blocked`]},{key:`in_progress`,match:[`in_progress`]},{key:`review`,match:[`review`]},{key:`failed`,match:[`failed`]},{key:`completed`,match:[`completed`]}],B={pending:`bg-muted text-muted-foreground`,ready:`bg-info/15 text-info`,running:`bg-primary/15 text-primary`,paused:`bg-warning/15 text-warning`,completed:`bg-success/15 text-success`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function re(){let{client:e}=ee(),{t}=u(),n=E(e=>e.phases),r=E(e=>e.multiBoard),[i,a]=(0,M.useState)(`phase`),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),[f,m]=(0,M.useState)(0),h=Math.min(f,Math.max(0,n.length-1)),g=r?n[h]:void 0,_=(0,M.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),v=(0,M.useMemo)(()=>[...new Set(_.map(e=>e.assignee).filter(e=>!!e))],[_]),y=(0,M.useCallback)(t=>e?.send?.(t),[e]),b=(0,M.useCallback)((e,t)=>y({type:`goal.taskStatus`,payload:{taskId:e,status:t}}),[y]),x=(0,M.useCallback)(e=>y({type:`goal.retryTask`,payload:{taskId:e}}),[y]),S=(0,M.useCallback)((e,t)=>y({type:`goal.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[y]),C=(0,M.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&y({type:`goal.addTask`,payload:{phaseId:e,title:t}})})},[y]),T=(0,M.useCallback)(e=>{o&&y({type:`goal.moveTask`,payload:{taskId:o,toPhaseId:e}}),s(null),l(null)},[o,y]),D=(0,M.useCallback)(e=>{o&&y({type:`goal.taskStatus`,payload:{taskId:o,status:e}}),s(null),l(null)},[o,y]),O={onStatusChange:b,onRetry:x,agents:v,onAssign:S};function k(e){return{draggable:!0,onDragStart:t=>{s(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{s(null),l(null)}}}function A(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,c!==e&&l(e)},onDragLeave:()=>l(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":c===e||void 0}}return n.length===0?(0,N.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:_.length})}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(d,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r&&g?(0,N.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border px-3 py-1.5`,children:n.map((e,t)=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>m(t),className:w(`shrink-0 rounded-t px-3 py-1.5 text-xs font-medium transition-colors`,t===h?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.name}),(0,N.jsxs)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount]})]},e.id))}),(0,N.jsx)(U,{phase:g,allTasks:_,layout:i,dragId:o,hoverKey:c,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:C})]}):(0,N.jsx)(H,{phases:n,allTasks:_,layout:i,dragId:o,hoverKey:c,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:C})]})}function V({phase:e,phaseTasks:t,callbacks:n,draggable:r,dropZone:a,dropToPhase:o,onAddTask:s,dragId:c,hoverKey:l}){let{t:d}=u();return(0,N.jsxs)(`div`,{...a(`phase:${e.id}`,()=>o(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,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,N.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,B[e.status]),children:e.status})]}),(0,N.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:d(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,N.jsx)(i,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-2`,children:t.length===0?(0,N.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:d(`activity:board.dropHere`)}):t.map(e=>(0,N.jsx)(`div`,{...r(e.id),className:w(c===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,...n})},e.id))})]})}function H({phases:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){return(0,N.jsx)(N.Fragment,{children:n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:e.map(e=>(0,N.jsx)(V,{phase:e,phaseTasks:t.filter(t=>t.phaseId===e.id),callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i},e.id))}):(0,N.jsx)(W,{phases:e,allTasks:t,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToStatus:l})})}function U({phase:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:d}){let f=t.filter(t=>t.phaseId===e.id),{t:p}=u();return n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:(0,N.jsx)(V,{phase:e,phaseTasks:f,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:d,dragId:r,hoverKey:i})}):(0,N.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:p(`activity:board.status.${e.key}`)},e.key)),(0,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(t=>{let n=f.filter(e=>t.match.includes(e.status)),c=`cell:${e.id}:${t.key}`;return(0,N.jsx)(`div`,{...s(c,()=>l(t.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,i===c?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,N.jsx)(`div`,{...o(e.id),className:w(r===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...a})},e.id))},t.key)})]},e.id)]})})}function W({phases:e,allTasks:t,dragId:n,hoverKey:r,callbacks:i,draggable:a,dropZone:o,dropToStatus:s}){let{t:c}=u();return(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:c(`activity:board.status.${e.key}`)},e.key)),e.map(e=>(0,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(c=>{let l=t.filter(t=>t.phaseId===e.id&&c.match.includes(t.status)),u=`cell:${e.id}:${c.key}`;return(0,N.jsx)(`div`,{...o(u,()=>s(c.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,r===u?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:l.map(e=>(0,N.jsx)(`div`,{...a(e.id),className:w(n===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...i})},e.id))},c.key)})]},e.id))]})}function G({children:e}){return(0,N.jsx)(N.Fragment,{children:e})}function K({onClose:e}){let{client:n}=ee(),{t:a}=u(),s=E(e=>e.phases),c=E(e=>e.overallPercent),d=E(e=>e.autonomous),f=E(e=>e.title),p=E(e=>e.goal),y=E(e=>e.status),b=E(e=>e.lastError),C=E(e=>e.graphs);(0,M.useEffect)(()=>{n?.send?.({type:`goal.list`}),n?.send?.({type:`goal.state`})},[n]);let j=D(e=>e.worktrees),P=D(e=>e.baseBranch),[F,I]=(0,M.useState)(``),[L,R]=(0,M.useState)(null),[z,B]=(0,M.useState)(!1),[V,H]=(0,M.useState)(!0),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(!1),[q,ie]=(0,M.useState)(!1),J=T(e=>e.result),Y=T(e=>e.loading),X=(0,M.useRef)(null);(0,M.useEffect)(()=>{if(X.current&&clearTimeout(X.current),!F.trim()){T.getState().clear();return}return X.current=setTimeout(()=>{T.getState().setLoading();let e=T.getState().nextSeq();n?.send?.({type:`goal.assess`,payload:{goal:F,seq:e}})},800),()=>{X.current&&clearTimeout(X.current)}},[F,n]),(0,M.useEffect)(()=>{!F.trim()&&!L&&T.getState().clear()},[F,L]);let Z=s.length>0,ae=L!=null&&!Z;(0,M.useEffect)(()=>{Z&&R(null)},[Z]);let Q=(0,M.useCallback)(()=>{let e=F.trim();if(!e||L!=null)return;let r=t.getState();r.addMessage({role:`user`,content:e}),r.addMessage({role:`assistant`,content:l.t(`activity:goalRun.planningAck`)}),R(e),I(``),n?.send?.({type:`goal.start`,payload:{title:e,autonomous:!0,worktrees:V,multiBoard:U,verifyTasks:G,chimeraReview:q}}),O(`chat`)},[F,L,n,V]),oe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}}),R(null)},[n]),se=(0,M.useCallback)(()=>{n?.send?.({type:`goal.toggleAutonomous`,payload:{}})},[n]),ce=(0,M.useCallback)(()=>{n?.send?.(y===`paused`?{type:`goal.resume`,payload:{}}:{type:`goal.pause`,payload:{}})},[n,y]),le=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}})},[n]),ue=(0,M.useCallback)(()=>{n?.send?.({type:`goal.clear`,payload:{}}),E.getState().clear(),R(null),I(``)},[n]),[de,$]=(0,M.useState)(!1),fe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.revert`,payload:{}}),$(!1)},[n]),pe=y===`running`||y===`paused`,me=y===`stopped`||y===`completed`||y===`failed`,he=(0,M.useCallback)(e=>{e&&n?.send?.({type:`goal.load`,payload:{graphId:e}})},[n]);return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,N.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-2 border-b bg-card px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(h,{className:`h-5 w-5 text-muted-foreground`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-lg font-semibold`,children:Z&&f||`Goal`}),Z&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`activity:goalRun.summary`,{count:s.length,pct:c})})]}),Z&&(0,N.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,y===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:y===`paused`||y===`stopped`?`border-warning/40 bg-warning/10 text-warning`:y===`completed`?`border-success/40 bg-success/10 text-success`:`border-primary/30 bg-primary/10 text-primary`),title:b??void 0,children:y})]}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[C.length>0&&(0,N.jsxs)(`select`,{value:Z?C.find(e=>e.title===f)?.id??``:``,onChange:e=>he(e.target.value),title:a(`activity:goalRun.switchBoard`),className:`min-w-0 flex-1 rounded border border-border bg-card px-2 py-1 text-xs text-foreground sm:w-72 sm:flex-none`,children:[(0,N.jsx)(`option`,{value:``,disabled:!0,children:a(`activity:goalRun.boardsCount`,{count:C.length})}),C.map(e=>(0,N.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),Z&&(0,N.jsxs)(`button`,{type:`button`,onClick:se,title:a(`activity:goalRun.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,d?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(x,{className:`h-3.5 w-3.5`}),` `,a(d?`activity:goalRun.autonomous`:`activity:goalRun.manual`)]}),pe&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ce,title:a(y===`paused`?`activity:goalRun.resumeTitle`:`activity:goalRun.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:[y===`paused`?(0,N.jsx)(S,{className:`h-3.5 w-3.5`}):(0,N.jsx)(v,{className:`h-3.5 w-3.5`}),a(y===`paused`?`activity:goalRun.resume`:`activity:goalRun.pause`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:le,title:a(`activity:goalRun.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,N.jsx)(r,{className:`h-3.5 w-3.5 fill-current`}),` `,a(`activity:goalRun.stop`)]})]}),Z&&me&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ue,title:a(`activity:goalRun.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,N.jsx)(i,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.newLabel`)]}),de?(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.revertConfirm`)}),(0,N.jsx)(`button`,{type:`button`,onClick:fe,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:a(`common:action.yes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:a(`common:action.no`)})]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:a(`activity:goalRun.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,N.jsx)(o,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.revert`)]})]}),(0,N.jsx)(k,{variant:`ghost`,size:`icon`,onClick:e,children:(0,N.jsx)(m,{className:`h-4 w-4`})})]})]}),Z&&p&&(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:p})]}),Z?(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,N.jsx)(re,{})}):ae?(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,N.jsx)(_,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.planning`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.planningBody`)})]}),(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:L})]}),(0,N.jsxs)(k,{variant:`outline`,onClick:oe,className:`gap-2`,children:[(0,N.jsx)(r,{className:`h-4 w-4 fill-current`}),` `,a(`common:action.cancel`)]})]})}):(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,N.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,N.jsx)(g,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.startHeading`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.startBody`)})]}),(0,N.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:a(`activity:goalRun.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/70`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Q())}}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(_,{className:`h-3 w-3 animate-spin`}),a(`activity:goalRun.assess.analyzing`)]}),!Y&&J&&!J.parseFailed&&(0,N.jsxs)(`div`,{className:w(`rounded-lg border px-3 py-2 text-xs space-y-1.5`,J.realistic?`border-success/40 bg-success/10`:`border-warning/40 bg-warning/10`),children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:J.realistic?(0,N.jsx)(`span`,{className:`text-success`,children:a(`activity:goalRun.assess.realistic`)}):(0,N.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.assess.durationConcern`)})}),J.durationClaimed&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.durationClaimed`,{duration:J.durationClaimed})}),(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:J.explanation}),J.recommendedDuration&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.recommendation`,{duration:J.recommendedDuration})}),J.concerns.length>0&&(0,N.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,N.jsx)(`p`,{className:`font-medium text-foreground/80`,children:a(`activity:goalRun.assess.concerns`)}),(0,N.jsx)(`ul`,{className:`list-disc pl-4 space-y-0.5 text-muted-foreground`,children:J.concerns.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})]})]}),!Y&&J?.parseFailed&&(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:a(`activity:goalRun.assess.analysisFailed`)}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.isolateLabel`)]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground`,children:[(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>W(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.multiBoardLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:G,onChange:e=>K(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.verifyTasksLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>ie(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.chimeraReviewLabel`)]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!Y&&J&&!J.realistic&&!J.parseFailed&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>T.getState().clear(),className:`shrink-0 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:a(`activity:goalRun.assess.overrideTitle`),children:a(`activity:goalRun.assess.override`)}),(0,N.jsxs)(k,{onClick:Q,disabled:!F.trim()||L!=null||Y||!Y&&J!=null&&!J.parseFailed&&!J.realistic,className:`flex-1 gap-2`,title:F.trim()&&!Y&&J&&!J.parseFailed&&!J.realistic?a(`activity:goalRun.assess.disableTitle`):``,children:[(0,N.jsx)(S,{className:`h-4 w-4`}),a(`activity:goalRun.startButton`)]})]}),(0,N.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[a(`activity:goalRun.ctrlHint`),` ·`,` `,a(V?`activity:goalRun.isolateOn`:`activity:goalRun.isolateOff`)]})]})}),j.length>0&&(0,N.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:a(`activity:goalRun.lanes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:a(`activity:goalRun.graph`)})]}),(0,N.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,N.jsx)(ne,{}),z?(0,N.jsx)(A,{worktrees:j,baseBranch:P}):(0,N.jsx)(te,{worktrees:j,baseBranch:P})]})]})]})}export{K as GoalView};
|