@inf-monkeys-tech/monkeys-design 1.0.8 → 1.0.9-canary.55.1.dbae3ce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/components/agent-workbench/index.d.mts +111 -0
  2. package/dist/components/agent-workbench/index.d.ts +111 -0
  3. package/dist/components/agent-workbench/index.js +1096 -0
  4. package/dist/components/agent-workbench/index.js.map +1 -0
  5. package/dist/components/agent-workbench/index.mjs +1091 -0
  6. package/dist/components/agent-workbench/index.mjs.map +1 -0
  7. package/dist/components/base/index.js +77 -0
  8. package/dist/components/base/index.js.map +1 -1
  9. package/dist/components/base/index.mjs +77 -0
  10. package/dist/components/base/index.mjs.map +1 -1
  11. package/dist/components/data-explorer/index.js +77 -0
  12. package/dist/components/data-explorer/index.js.map +1 -1
  13. package/dist/components/data-explorer/index.mjs +77 -0
  14. package/dist/components/data-explorer/index.mjs.map +1 -1
  15. package/dist/components/layout/index.js +77 -0
  16. package/dist/components/layout/index.js.map +1 -1
  17. package/dist/components/layout/index.mjs +77 -0
  18. package/dist/components/layout/index.mjs.map +1 -1
  19. package/dist/components/runtime/index.js +77 -0
  20. package/dist/components/runtime/index.js.map +1 -1
  21. package/dist/components/runtime/index.mjs +77 -0
  22. package/dist/components/runtime/index.mjs.map +1 -1
  23. package/dist/components/toast/index.d.mts +1 -1
  24. package/dist/components/toast/index.d.ts +1 -1
  25. package/dist/components/toast/index.js +77 -0
  26. package/dist/components/toast/index.js.map +1 -1
  27. package/dist/components/toast/index.mjs +77 -0
  28. package/dist/components/toast/index.mjs.map +1 -1
  29. package/dist/components/toolbar/index.js +77 -0
  30. package/dist/components/toolbar/index.js.map +1 -1
  31. package/dist/components/toolbar/index.mjs +77 -0
  32. package/dist/components/toolbar/index.mjs.map +1 -1
  33. package/dist/components/workbench/index.js +77 -0
  34. package/dist/components/workbench/index.js.map +1 -1
  35. package/dist/components/workbench/index.mjs +77 -0
  36. package/dist/components/workbench/index.mjs.map +1 -1
  37. package/dist/index.d.mts +3 -2
  38. package/dist/index.d.ts +3 -2
  39. package/dist/index.js +2541 -1471
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +2538 -1472
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/locale/index.d.mts +208 -2
  44. package/dist/locale/index.d.ts +208 -2
  45. package/dist/locale/index.js +220 -0
  46. package/dist/locale/index.js.map +1 -1
  47. package/dist/locale/index.mjs +220 -0
  48. package/dist/locale/index.mjs.map +1 -1
  49. package/dist/provider/index.d.mts +2 -2
  50. package/dist/provider/index.d.ts +2 -2
  51. package/dist/provider/index.js +220 -0
  52. package/dist/provider/index.js.map +1 -1
  53. package/dist/provider/index.mjs +220 -0
  54. package/dist/provider/index.mjs.map +1 -1
  55. package/dist/styles.css +1 -1
  56. package/dist/types-fed4675a38fa.d.mts +278 -0
  57. package/dist/types-fed4675a38fa.d.ts +278 -0
  58. package/package.json +8 -3
  59. package/dist/types-183d24c0fff3.d.mts +0 -158
  60. package/dist/types-183d24c0fff3.d.ts +0 -158
@@ -0,0 +1,1096 @@
1
+ 'use strict';
2
+
3
+ var lucideReact = require('lucide-react');
4
+ var react = require('react');
5
+ require('@radix-ui/react-dropdown-menu');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ // src/components/agent-workbench/AgentWorkbenchActivity.tsx
9
+
10
+ // src/locale/en-US.ts
11
+ var enUS = {
12
+ locale: "en-US",
13
+ messages: {
14
+ pagination: {
15
+ navigation: "Pagination",
16
+ first: "First",
17
+ previous: "Previous",
18
+ next: "Next",
19
+ last: "Last",
20
+ page: ({ page, pageCount }) => `Page ${page} of ${pageCount}`,
21
+ currentPage: ({ page, pageCount }) => `Page ${page} of ${pageCount}, current page`,
22
+ emptyResults: "0 results",
23
+ range: ({ start, end, total }) => `${start}-${end} of ${total}`
24
+ },
25
+ dialog: {
26
+ close: "Close dialog"
27
+ },
28
+ dropdownMenu: {
29
+ actions: "Actions"
30
+ },
31
+ loading: {
32
+ spinner: "Loading"
33
+ },
34
+ layout: {
35
+ resizePanels: "Resize panels"
36
+ },
37
+ steps: {
38
+ label: "Progress",
39
+ current: "Current",
40
+ completed: "Completed",
41
+ error: "Error",
42
+ disabled: "Disabled"
43
+ },
44
+ numberInput: {
45
+ increment: "Increase value",
46
+ decrement: "Decrease value"
47
+ },
48
+ passwordInput: {
49
+ showPassword: "Show password",
50
+ hidePassword: "Hide password"
51
+ },
52
+ multiSelect: {
53
+ placeholder: "Select options",
54
+ empty: "No options",
55
+ removeOption: ({ value }) => `Remove ${value}`
56
+ },
57
+ table: {
58
+ dragColumn: ({ columnId }) => `Drag column ${columnId}`,
59
+ resizeColumn: ({ columnId }) => `Resize column ${columnId}`,
60
+ sortColumn: ({ columnId }) => columnId ? `Sort column ${columnId}` : "Sort column",
61
+ loadingRow: "Loading table row"
62
+ },
63
+ toolbar: {
64
+ theme: {
65
+ label: "Appearance",
66
+ toggle: "Toggle theme",
67
+ auto: "Auto",
68
+ light: "Light",
69
+ dark: "Dark"
70
+ },
71
+ language: {
72
+ label: "Language",
73
+ switch: "Switch language"
74
+ }
75
+ },
76
+ toast: {
77
+ errorTitle: "Error",
78
+ warningTitle: "Warning",
79
+ defaultErrorDescription: "Something went wrong.",
80
+ defaultWarningDescription: "Please check and try again."
81
+ },
82
+ dataExplorer: {
83
+ viewTree: {
84
+ actions: "More actions",
85
+ expand: "Expand",
86
+ collapse: "Collapse",
87
+ loading: "Loading...",
88
+ empty: "No views",
89
+ error: "Unable to load views"
90
+ }
91
+ },
92
+ workbench: {
93
+ interactiveTable: {
94
+ columnActions: "Column actions",
95
+ freezeColumn: "Freeze to left",
96
+ freezeEndColumn: "Freeze to right",
97
+ unfreezeColumn: "Unfreeze from left",
98
+ unfreezeEndColumn: "Unfreeze from right",
99
+ unfreezeAllColumns: "Unfreeze all columns",
100
+ resetColumnWidth: "Reset column width",
101
+ frozenColumnTitle: "Frozen column"
102
+ }
103
+ },
104
+ agentWorkbench: {
105
+ label: "Session activity",
106
+ reasoning: "Reasoning",
107
+ plan: "Plan",
108
+ taskNoDetail: "No additional details",
109
+ tool: {
110
+ input: "Input",
111
+ output: "Output"
112
+ },
113
+ approval: {
114
+ approve: "Approve",
115
+ reject: "Reject",
116
+ approved: "Approved",
117
+ rejected: "Rejected"
118
+ },
119
+ artifact: {
120
+ pending: "Preparing",
121
+ ready: "Ready",
122
+ failed: "Failed",
123
+ open: ({ name }) => `Open ${name}`
124
+ },
125
+ run: {
126
+ stopping: "Stopping...",
127
+ stoppedAfter: ({ duration }) => `You stopped after ${duration}`
128
+ },
129
+ usage: {
130
+ label: "Context usage",
131
+ context: ({ used, total }) => `${used} / ${total} tokens`
132
+ },
133
+ details: {
134
+ title: "Task details",
135
+ description: "Summary and workspace activity",
136
+ duration: "Duration",
137
+ updated: "Updated",
138
+ summary: "Summary",
139
+ summaryEmpty: "No summary is available yet.",
140
+ summaryFailed: "The summary could not be generated.",
141
+ highlights: "Highlights",
142
+ pendingItems: "Pending items",
143
+ tabs: {
144
+ label: "Task detail views",
145
+ summary: "Summary",
146
+ workspace: "Workspace"
147
+ },
148
+ status: {
149
+ queued: "Queued",
150
+ running: "Running",
151
+ waiting_approval: "Waiting for approval",
152
+ stopping: "Stopping",
153
+ stopped: "Stopped",
154
+ completed: "Completed",
155
+ failed: "Failed"
156
+ },
157
+ state: {
158
+ loading: { title: "Loading task details", description: "Restoring the latest session activity." },
159
+ empty: { title: "No task selected", description: "Select a task to inspect its details." },
160
+ error: { title: "Unable to load task details", description: "Try again after the session is available." }
161
+ },
162
+ actions: {
163
+ close: "Close task details",
164
+ copySummary: "Copy summary",
165
+ retry: "Retry",
166
+ retrySummary: "Retry summary",
167
+ resume: "Resume"
168
+ },
169
+ workspace: {
170
+ diffs: "Code changes",
171
+ files: "Files",
172
+ terminals: "Terminals",
173
+ tests: "Tests",
174
+ artifacts: "Artifacts",
175
+ exitCode: ({ code }) => `Exit code ${code}`,
176
+ diffStatus: { added: "Added", modified: "Modified", deleted: "Deleted", renamed: "Renamed" },
177
+ fileOperation: { upsert: "Updated", delete: "Deleted" }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ };
183
+
184
+ // src/locale/resolve-locale.ts
185
+ function mergeMonkeysLocaleMessages(base, override) {
186
+ return base;
187
+ }
188
+ var defaultMonkeysLocale = {
189
+ locale: enUS.locale,
190
+ messages: mergeMonkeysLocaleMessages(
191
+ enUS.messages
192
+ )
193
+ };
194
+ var EMPTY_ENVIRONMENT = Object.freeze({});
195
+ var EMPTY_PORTAL = Object.freeze({});
196
+ var MONKEYS_PROVIDER_CONTEXTS_KEY = /* @__PURE__ */ Symbol.for(
197
+ "@inf-monkeys-tech/monkeys-design/provider-context@1"
198
+ );
199
+ function createMonkeysProviderContexts() {
200
+ return Object.freeze({
201
+ locale: react.createContext({
202
+ ...defaultMonkeysLocale,
203
+ provided: false
204
+ }),
205
+ theme: react.createContext({
206
+ provided: false
207
+ }),
208
+ direction: react.createContext({
209
+ provided: false
210
+ }),
211
+ environment: react.createContext({
212
+ provided: false,
213
+ environment: EMPTY_ENVIRONMENT,
214
+ portal: EMPTY_PORTAL
215
+ })
216
+ });
217
+ }
218
+ function getMonkeysProviderContexts() {
219
+ const host = globalThis;
220
+ const existing = host[MONKEYS_PROVIDER_CONTEXTS_KEY];
221
+ if (existing) return existing;
222
+ const contexts = createMonkeysProviderContexts();
223
+ Object.defineProperty(host, MONKEYS_PROVIDER_CONTEXTS_KEY, {
224
+ value: contexts,
225
+ enumerable: false,
226
+ configurable: false,
227
+ writable: false
228
+ });
229
+ return contexts;
230
+ }
231
+ var providerContexts = getMonkeysProviderContexts();
232
+ var MonkeysLocaleContext = providerContexts.locale;
233
+ providerContexts.theme;
234
+ providerContexts.direction;
235
+ providerContexts.environment;
236
+ function useMonkeysLocale() {
237
+ return react.useContext(MonkeysLocaleContext);
238
+ }
239
+ function useMonkeysLocaleMessages() {
240
+ return react.useContext(MonkeysLocaleContext).messages;
241
+ }
242
+ function cn(...inputs) {
243
+ return inputs.filter(Boolean).join(" ");
244
+ }
245
+
246
+ // src/components/agent-workbench/activity-model.ts
247
+ var EVENT_CAPABILITIES = {
248
+ reasoning: "reasoning",
249
+ plan: "plan",
250
+ task: "tasks",
251
+ tool: "tools",
252
+ approval: "approval",
253
+ artifact: "artifacts",
254
+ usage: "usage"
255
+ };
256
+ function isVisible(event, capabilities) {
257
+ const capability = EVENT_CAPABILITIES[event.eventType];
258
+ return capability ? capabilities[capability] === true : true;
259
+ }
260
+ function latestBy(events, eventType, key) {
261
+ const latest = /* @__PURE__ */ new Map();
262
+ for (const event of events) {
263
+ if (event.eventType !== eventType) continue;
264
+ const typedEvent = event;
265
+ latest.set(key(typedEvent), typedEvent);
266
+ }
267
+ return [...latest.values()].sort(
268
+ (left, right) => left.sequence - right.sequence
269
+ );
270
+ }
271
+ function createAgentWorkbenchActivityModel(viewModel) {
272
+ const visibleEvents = viewModel.events.filter(
273
+ (event) => isVisible(event, viewModel.snapshot.capabilities)
274
+ );
275
+ return {
276
+ mode: viewModel.snapshot.mode,
277
+ status: viewModel.status,
278
+ reasoning: latestBy(
279
+ visibleEvents,
280
+ "reasoning",
281
+ (event) => event.payload.reasoningId
282
+ ),
283
+ plans: latestBy(
284
+ visibleEvents,
285
+ "plan",
286
+ (event) => event.payload.planId
287
+ ),
288
+ tasks: latestBy(
289
+ visibleEvents,
290
+ "task",
291
+ (event) => event.payload.taskId
292
+ ),
293
+ tools: latestBy(
294
+ visibleEvents,
295
+ "tool",
296
+ (event) => event.payload.toolCallId
297
+ ),
298
+ approvals: latestBy(
299
+ visibleEvents,
300
+ "approval",
301
+ (event) => event.payload.approvalId
302
+ ),
303
+ artifacts: latestBy(
304
+ visibleEvents,
305
+ "artifact",
306
+ (event) => event.payload.artifactId
307
+ ),
308
+ usage: [...visibleEvents].reverse().find(
309
+ (event) => event.eventType === "usage"
310
+ ),
311
+ run: [...visibleEvents].reverse().find(
312
+ (event) => event.eventType === "status"
313
+ )
314
+ };
315
+ }
316
+ function ActivityDetails({
317
+ icon: Icon,
318
+ title,
319
+ open,
320
+ streaming,
321
+ className,
322
+ triggerClassName,
323
+ contentClassName,
324
+ children
325
+ }) {
326
+ return /* @__PURE__ */ jsxRuntime.jsxs(
327
+ "details",
328
+ {
329
+ className: cn(
330
+ "group rounded-lg border border-border bg-card text-card-foreground",
331
+ className
332
+ ),
333
+ open,
334
+ children: [
335
+ /* @__PURE__ */ jsxRuntime.jsxs(
336
+ "summary",
337
+ {
338
+ className: cn(
339
+ "flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",
340
+ triggerClassName
341
+ ),
342
+ children: [
343
+ streaming ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 shrink-0 animate-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
344
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: title }),
345
+ /* @__PURE__ */ jsxRuntime.jsx(
346
+ lucideReact.ChevronDown,
347
+ {
348
+ className: "size-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180",
349
+ "aria-hidden": "true"
350
+ }
351
+ )
352
+ ]
353
+ }
354
+ ),
355
+ /* @__PURE__ */ jsxRuntime.jsx(
356
+ "div",
357
+ {
358
+ className: cn(
359
+ "border-t border-border px-3 py-3 text-sm",
360
+ contentClassName
361
+ ),
362
+ children
363
+ }
364
+ )
365
+ ]
366
+ }
367
+ );
368
+ }
369
+ function StatusIcon({ status }) {
370
+ if (status === "completed" || status === "passed") {
371
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { className: "size-4 text-primary", "aria-hidden": "true" });
372
+ }
373
+ if (status === "failed") {
374
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "size-4 text-destructive-text", "aria-hidden": "true" });
375
+ }
376
+ if (status === "running") {
377
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock3, { className: "size-4 animate-pulse", "aria-hidden": "true" });
378
+ }
379
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "size-4 text-muted-foreground", "aria-hidden": "true" });
380
+ }
381
+ function JsonValue({ value }) {
382
+ if (value === void 0) return null;
383
+ const content = typeof value === "string" ? value : JSON.stringify(value, null, 2);
384
+ return /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted p-3 font-mono text-xs text-foreground", children: content });
385
+ }
386
+ function formatDuration(durationMs) {
387
+ if (durationMs < 1e3) return "<1s";
388
+ const totalSeconds = Math.floor(durationMs / 1e3);
389
+ const minutes = Math.floor(totalSeconds / 60);
390
+ const seconds = totalSeconds % 60;
391
+ return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
392
+ }
393
+ function RunStatus({ event }) {
394
+ const messages = useMonkeysLocaleMessages().agentWorkbench;
395
+ const status = event.payload.status;
396
+ if (status !== "stopping" && status !== "stopped") return null;
397
+ return /* @__PURE__ */ jsxRuntime.jsxs(
398
+ "div",
399
+ {
400
+ className: "flex items-center gap-2 text-sm text-muted-foreground",
401
+ role: "status",
402
+ children: [
403
+ status === "stopping" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleStop, { className: "size-4", "aria-hidden": "true" }),
404
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: status === "stopping" ? messages.run.stopping : messages.run.stoppedAfter({
405
+ duration: formatDuration(event.payload.durationMs ?? 0)
406
+ }) })
407
+ ]
408
+ }
409
+ );
410
+ }
411
+ function AgentWorkbenchActivity({
412
+ viewModel,
413
+ hiddenToolCallIds,
414
+ hideReasoning = false,
415
+ hideStoppedRun = false,
416
+ className,
417
+ classNames,
418
+ onApprovalDecision,
419
+ onArtifactOpen
420
+ }) {
421
+ const messages = useMonkeysLocaleMessages().agentWorkbench;
422
+ if (!viewModel) return null;
423
+ const activity = createAgentWorkbenchActivityModel(viewModel);
424
+ const reasoning = hideReasoning ? [] : activity.reasoning;
425
+ const tools = activity.tools.filter(
426
+ (event) => !hiddenToolCallIds?.has(event.payload.toolCallId)
427
+ );
428
+ const approvals = activity.approvals.filter(
429
+ (event) => !event.payload.toolCallId || !hiddenToolCallIds?.has(event.payload.toolCallId)
430
+ );
431
+ const usage = activity.usage?.payload;
432
+ const contextWindow = typeof usage?.contextWindow === "number" && usage.contextWindow > 0 ? usage.contextWindow : void 0;
433
+ const showRun = activity.run?.payload.status === "stopping" || activity.run?.payload.status === "stopped" && !hideStoppedRun;
434
+ const hasActivity = reasoning.length > 0 || activity.plans.length > 0 || activity.tasks.length > 0 || tools.length > 0 || approvals.length > 0 || activity.artifacts.length > 0 || showRun || contextWindow !== void 0;
435
+ if (!hasActivity) return null;
436
+ return /* @__PURE__ */ jsxRuntime.jsxs(
437
+ "section",
438
+ {
439
+ className: cn("space-y-3", classNames?.root, className),
440
+ "aria-label": messages.label,
441
+ "data-agent-workbench-mode": activity.mode,
442
+ "data-agent-workbench-status": activity.status,
443
+ children: [
444
+ reasoning.map((event) => /* @__PURE__ */ jsxRuntime.jsx(
445
+ ActivityDetails,
446
+ {
447
+ icon: lucideReact.Circle,
448
+ title: messages.reasoning,
449
+ open: event.payload.status === "streaming",
450
+ streaming: event.payload.status === "streaming",
451
+ className: classNames?.item,
452
+ triggerClassName: classNames?.trigger,
453
+ contentClassName: classNames?.content,
454
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap text-muted-foreground", children: event.payload.text })
455
+ },
456
+ event.payload.reasoningId
457
+ )),
458
+ activity.plans.map((event) => /* @__PURE__ */ jsxRuntime.jsx(
459
+ ActivityDetails,
460
+ {
461
+ icon: lucideReact.Circle,
462
+ title: event.payload.title || messages.plan,
463
+ open: event.payload.status === "running",
464
+ streaming: event.payload.status === "running",
465
+ className: classNames?.item,
466
+ triggerClassName: classNames?.trigger,
467
+ contentClassName: classNames?.content,
468
+ children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "space-y-2", children: event.payload.steps.map((step) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-2", children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { status: step.status }),
470
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: step.title })
471
+ ] }, step.id)) })
472
+ },
473
+ event.payload.planId
474
+ )),
475
+ activity.tasks.map((event) => /* @__PURE__ */ jsxRuntime.jsx(
476
+ ActivityDetails,
477
+ {
478
+ icon: lucideReact.Circle,
479
+ title: event.payload.title,
480
+ open: event.payload.status === "running",
481
+ streaming: event.payload.status === "running",
482
+ className: classNames?.item,
483
+ triggerClassName: classNames?.trigger,
484
+ contentClassName: classNames?.content,
485
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { status: event.payload.status }),
487
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "whitespace-pre-wrap text-muted-foreground", children: event.payload.detail || messages.taskNoDetail })
488
+ ] })
489
+ },
490
+ event.payload.taskId
491
+ )),
492
+ tools.map((event) => /* @__PURE__ */ jsxRuntime.jsx(
493
+ ActivityDetails,
494
+ {
495
+ icon: lucideReact.TerminalSquare,
496
+ title: event.payload.toolName,
497
+ open: event.payload.status === "failed",
498
+ streaming: event.payload.status === "pending" || event.payload.status === "running",
499
+ className: classNames?.item,
500
+ triggerClassName: classNames?.trigger,
501
+ contentClassName: classNames?.content,
502
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
503
+ event.payload.input !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
504
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium text-muted-foreground", children: messages.tool.input }),
505
+ /* @__PURE__ */ jsxRuntime.jsx(JsonValue, { value: event.payload.input })
506
+ ] }) : null,
507
+ event.payload.output !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
508
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium text-muted-foreground", children: messages.tool.output }),
509
+ /* @__PURE__ */ jsxRuntime.jsx(JsonValue, { value: event.payload.output })
510
+ ] }) : null,
511
+ event.payload.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive-text", role: "alert", children: event.payload.error }) : null
512
+ ] })
513
+ },
514
+ event.payload.toolCallId
515
+ )),
516
+ approvals.map((event) => {
517
+ const requested = event.payload.status === "requested";
518
+ const approved = event.payload.status === "approved";
519
+ return /* @__PURE__ */ jsxRuntime.jsx(
520
+ "article",
521
+ {
522
+ className: cn(
523
+ "rounded-lg border border-border bg-card p-3 text-card-foreground",
524
+ classNames?.approval
525
+ ),
526
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
527
+ requested ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock3, { className: "mt-0.5 size-4 shrink-0", "aria-hidden": "true" }) : approved ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "mt-0.5 size-4 shrink-0 text-primary", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "mt-0.5 size-4 shrink-0 text-destructive-text", "aria-hidden": "true" }),
528
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
529
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-medium", children: event.payload.title }),
530
+ event.payload.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: event.payload.description }) : null,
531
+ event.payload.requestedAction !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxRuntime.jsx(JsonValue, { value: event.payload.requestedAction }) }) : null,
532
+ requested ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
533
+ /* @__PURE__ */ jsxRuntime.jsx(
534
+ "button",
535
+ {
536
+ type: "button",
537
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
538
+ disabled: !onApprovalDecision,
539
+ onClick: () => onApprovalDecision?.({
540
+ approvalId: event.payload.approvalId,
541
+ approved: true
542
+ }),
543
+ children: messages.approval.approve
544
+ }
545
+ ),
546
+ /* @__PURE__ */ jsxRuntime.jsx(
547
+ "button",
548
+ {
549
+ type: "button",
550
+ className: "rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
551
+ disabled: !onApprovalDecision,
552
+ onClick: () => onApprovalDecision?.({
553
+ approvalId: event.payload.approvalId,
554
+ approved: false
555
+ }),
556
+ children: messages.approval.reject
557
+ }
558
+ )
559
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: approved ? messages.approval.approved : messages.approval.rejected })
560
+ ] })
561
+ ] })
562
+ },
563
+ event.payload.approvalId
564
+ );
565
+ }),
566
+ activity.artifacts.map((event) => {
567
+ const canOpen = Boolean(event.payload.url && onArtifactOpen);
568
+ return /* @__PURE__ */ jsxRuntime.jsxs(
569
+ "article",
570
+ {
571
+ className: cn(
572
+ "flex items-center gap-3 rounded-lg border border-border bg-card p-3 text-card-foreground",
573
+ classNames?.artifact
574
+ ),
575
+ children: [
576
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutput, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
577
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
578
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-sm font-medium", children: event.payload.name }),
579
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: messages.artifact[event.payload.status] })
580
+ ] }),
581
+ event.payload.url ? /* @__PURE__ */ jsxRuntime.jsx(
582
+ "button",
583
+ {
584
+ type: "button",
585
+ className: "rounded-md p-2 text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
586
+ "aria-label": messages.artifact.open({
587
+ name: event.payload.name
588
+ }),
589
+ disabled: !canOpen,
590
+ onClick: () => {
591
+ if (!event.payload.url) return;
592
+ onArtifactOpen?.({
593
+ artifactId: event.payload.artifactId,
594
+ name: event.payload.name,
595
+ url: event.payload.url
596
+ });
597
+ },
598
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "size-4", "aria-hidden": "true" })
599
+ }
600
+ ) : null
601
+ ]
602
+ },
603
+ event.payload.artifactId
604
+ );
605
+ }),
606
+ showRun && activity.run ? /* @__PURE__ */ jsxRuntime.jsx(RunStatus, { event: activity.run }) : null,
607
+ usage && contextWindow !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
608
+ "div",
609
+ {
610
+ className: cn("flex justify-end", classNames?.usage),
611
+ "aria-label": messages.usage.label,
612
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full border border-border bg-muted px-2.5 py-1 text-xs text-muted-foreground", children: messages.usage.context({
613
+ used: usage.contextTokens ?? usage.totalTokens ?? 0,
614
+ total: contextWindow
615
+ }) })
616
+ }
617
+ ) : null
618
+ ]
619
+ }
620
+ );
621
+ }
622
+
623
+ // src/components/agent-workbench/details-model.ts
624
+ var WORKSPACE_CAPABILITIES = {
625
+ diff: "diff",
626
+ "workspace-file": "workspaceFiles",
627
+ terminal: "terminal",
628
+ "test-result": "testResults",
629
+ artifact: "artifacts"
630
+ };
631
+ function latestBy2(events, eventType, key) {
632
+ const latest = /* @__PURE__ */ new Map();
633
+ for (const event of events) {
634
+ if (event.eventType !== eventType) continue;
635
+ const typedEvent = event;
636
+ latest.set(key(typedEvent), typedEvent);
637
+ }
638
+ return [...latest.values()].sort(
639
+ (left, right) => left.sequence - right.sequence
640
+ );
641
+ }
642
+ function projectTerminals(events) {
643
+ const terminals = /* @__PURE__ */ new Map();
644
+ for (const event of events) {
645
+ const current = terminals.get(event.payload.terminalId) ?? {
646
+ terminalId: event.payload.terminalId,
647
+ stdin: "",
648
+ stdout: "",
649
+ stderr: "",
650
+ status: "",
651
+ sequence: event.sequence
652
+ };
653
+ const stream = event.payload.stream;
654
+ terminals.set(event.payload.terminalId, {
655
+ ...current,
656
+ ...stream === "status" ? { status: event.payload.chunk } : { [stream]: `${current[stream]}${event.payload.chunk}` },
657
+ ...event.payload.exitCode === void 0 ? {} : { exitCode: event.payload.exitCode },
658
+ sequence: event.sequence
659
+ });
660
+ }
661
+ return [...terminals.values()].sort(
662
+ (left, right) => left.sequence - right.sequence
663
+ );
664
+ }
665
+ function createAgentWorkbenchDetailsModel(viewModel) {
666
+ const capabilities = viewModel.snapshot.capabilities;
667
+ const workspaceEvents = viewModel.events.filter((event) => {
668
+ const capability = WORKSPACE_CAPABILITIES[event.eventType];
669
+ return capability ? capabilities[capability] === true : false;
670
+ });
671
+ const run = [...viewModel.events].reverse().find(
672
+ (event) => event.eventType === "status"
673
+ );
674
+ const currentRunId = run?.runId;
675
+ const summary = [...viewModel.events].reverse().find(
676
+ (event) => event.eventType === "summary" && capabilities.summary === true && (!currentRunId || event.runId === currentRunId)
677
+ );
678
+ return {
679
+ mode: viewModel.snapshot.mode,
680
+ status: viewModel.status,
681
+ sessionId: viewModel.sessionId,
682
+ resumable: capabilities.resume === true && viewModel.resumable,
683
+ summary,
684
+ error: [...viewModel.events].reverse().find(
685
+ (event) => event.eventType === "error"
686
+ ),
687
+ run,
688
+ workspace: {
689
+ diffs: latestBy2(workspaceEvents, "diff", (event) => event.payload.path),
690
+ files: latestBy2(
691
+ workspaceEvents,
692
+ "workspace-file",
693
+ (event) => event.payload.path
694
+ ),
695
+ terminals: projectTerminals(
696
+ workspaceEvents.filter(
697
+ (event) => event.eventType === "terminal"
698
+ )
699
+ ),
700
+ tests: latestBy2(
701
+ workspaceEvents,
702
+ "test-result",
703
+ (event) => event.payload.testId
704
+ ),
705
+ artifacts: latestBy2(
706
+ workspaceEvents,
707
+ "artifact",
708
+ (event) => event.payload.artifactId
709
+ )
710
+ }
711
+ };
712
+ }
713
+ function formatDuration2(durationMs) {
714
+ if (durationMs === void 0) return "-";
715
+ const seconds = Math.max(0, Math.round(durationMs / 1e3));
716
+ if (seconds < 60) return `${seconds}s`;
717
+ return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
718
+ }
719
+ function formatDate(value, locale) {
720
+ if (!value) return "-";
721
+ const date = new Date(value);
722
+ if (Number.isNaN(date.getTime())) return "-";
723
+ return new Intl.DateTimeFormat(locale, {
724
+ dateStyle: "medium",
725
+ timeStyle: "short"
726
+ }).format(date);
727
+ }
728
+ function Count({ value }) {
729
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-semibold text-muted-foreground", children: value });
730
+ }
731
+ function DetailsSection({
732
+ title,
733
+ count,
734
+ icon: Icon,
735
+ className,
736
+ children
737
+ }) {
738
+ if (count === 0) return null;
739
+ return /* @__PURE__ */ jsxRuntime.jsxs(
740
+ "details",
741
+ {
742
+ className: cn(
743
+ "group rounded-lg border border-border bg-card text-card-foreground",
744
+ className
745
+ ),
746
+ open: true,
747
+ children: [
748
+ /* @__PURE__ */ jsxRuntime.jsxs("summary", { className: "flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden", children: [
749
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }),
750
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: title }),
751
+ /* @__PURE__ */ jsxRuntime.jsx(Count, { value: count }),
752
+ /* @__PURE__ */ jsxRuntime.jsx(
753
+ lucideReact.ChevronDown,
754
+ {
755
+ className: "size-4 text-muted-foreground transition-transform group-open:rotate-180",
756
+ "aria-hidden": "true"
757
+ }
758
+ )
759
+ ] }),
760
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border p-3", children })
761
+ ]
762
+ }
763
+ );
764
+ }
765
+ function StatusIcon2({ status }) {
766
+ if (status === "completed" || status === "passed") {
767
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { className: "size-4 text-primary", "aria-hidden": "true" });
768
+ }
769
+ if (status === "failed") {
770
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "size-4 text-destructive-text", "aria-hidden": "true" });
771
+ }
772
+ if (status === "running") {
773
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock3, { className: "size-4 animate-pulse", "aria-hidden": "true" });
774
+ }
775
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "size-4 text-muted-foreground", "aria-hidden": "true" });
776
+ }
777
+ function StateContent({ state }) {
778
+ const messages = useMonkeysLocaleMessages().agentWorkbench.details;
779
+ const error = state === "error";
780
+ return /* @__PURE__ */ jsxRuntime.jsxs(
781
+ "div",
782
+ {
783
+ className: "flex min-h-48 flex-col items-center justify-center gap-2 px-6 text-center",
784
+ role: error ? "alert" : state === "loading" ? "status" : void 0,
785
+ "aria-busy": state === "loading" || void 0,
786
+ children: [
787
+ state === "loading" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "size-5 animate-spin text-muted-foreground", "aria-hidden": "true" }) : error ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "size-5 text-destructive-text", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutput, { className: "size-5 text-muted-foreground", "aria-hidden": "true" }),
788
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium", children: messages.state[state].title }),
789
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: messages.state[state].description })
790
+ ]
791
+ }
792
+ );
793
+ }
794
+ function SummaryPanel({
795
+ model,
796
+ onIntent
797
+ }) {
798
+ const messages = useMonkeysLocaleMessages().agentWorkbench.details;
799
+ const locale = useMonkeysLocale().locale;
800
+ const summary = model.summary;
801
+ const run = model.run?.payload;
802
+ const error = model.error;
803
+ const retryable = model.status === "failed" && error?.payload.retryable;
804
+ const canResume = model.resumable && ["stopped", "completed", "failed"].includes(model.status);
805
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
806
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-lg border border-border bg-muted/40 p-3", children: [
807
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon2, { status: model.status }),
809
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: messages.status[model.status] })
810
+ ] }),
811
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "mt-3 grid grid-cols-2 gap-3 text-xs", children: [
812
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
813
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "text-muted-foreground", children: messages.duration }),
814
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mt-0.5 font-medium", children: formatDuration2(run?.durationMs) })
815
+ ] }),
816
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
817
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "text-muted-foreground", children: messages.updated }),
818
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mt-0.5 truncate font-medium", children: formatDate(
819
+ run?.stoppedAt ?? run?.completedAt ?? run?.failedAt,
820
+ locale
821
+ ) })
822
+ ] })
823
+ ] }),
824
+ error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 rounded-md border border-destructive/30 bg-destructive/5 p-2.5 text-sm text-destructive-text", role: "alert", children: error.payload.message }) : null,
825
+ retryable || canResume ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
826
+ retryable ? /* @__PURE__ */ jsxRuntime.jsx(
827
+ "button",
828
+ {
829
+ type: "button",
830
+ className: "rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",
831
+ disabled: !onIntent,
832
+ onClick: () => onIntent?.({ type: "retry", eventId: error.eventId }),
833
+ children: messages.actions.retry
834
+ }
835
+ ) : null,
836
+ canResume ? /* @__PURE__ */ jsxRuntime.jsx(
837
+ "button",
838
+ {
839
+ type: "button",
840
+ className: "rounded-md bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring",
841
+ disabled: !onIntent,
842
+ onClick: () => onIntent?.({ type: "resume", sessionId: model.sessionId }),
843
+ children: messages.actions.resume
844
+ }
845
+ ) : null
846
+ ] }) : null
847
+ ] }),
848
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-lg border border-border bg-card p-3 text-card-foreground", children: [
849
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
850
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: messages.summary }),
851
+ summary?.payload.text ? /* @__PURE__ */ jsxRuntime.jsx(
852
+ "button",
853
+ {
854
+ type: "button",
855
+ className: "rounded-md p-1.5 text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
856
+ "aria-label": messages.actions.copySummary,
857
+ disabled: !onIntent,
858
+ onClick: () => onIntent?.({
859
+ type: "copy-summary",
860
+ summaryId: summary.payload.summaryId,
861
+ text: summary.payload.text
862
+ }),
863
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "size-4", "aria-hidden": "true" })
864
+ }
865
+ ) : null
866
+ ] }),
867
+ summary?.payload.status === "failed" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2", children: [
868
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive-text", role: "alert", children: messages.summaryFailed }),
869
+ /* @__PURE__ */ jsxRuntime.jsxs(
870
+ "button",
871
+ {
872
+ type: "button",
873
+ className: "inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs font-medium outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",
874
+ disabled: !onIntent,
875
+ onClick: () => onIntent?.({ type: "retry-summary", eventId: summary.eventId }),
876
+ children: [
877
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { className: "size-3.5", "aria-hidden": "true" }),
878
+ messages.actions.retrySummary
879
+ ]
880
+ }
881
+ )
882
+ ] }) : summary?.payload.text ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-3 text-sm", children: [
883
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap text-muted-foreground", children: summary.payload.text }),
884
+ summary.payload.highlights.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
885
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-xs font-medium", children: messages.highlights }),
886
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1 list-disc space-y-1 pl-5 text-muted-foreground", children: summary.payload.highlights.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: item }, item)) })
887
+ ] }) : null,
888
+ summary.payload.pendingItems.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
889
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-xs font-medium", children: messages.pendingItems }),
890
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1 list-disc space-y-1 pl-5 text-muted-foreground", children: summary.payload.pendingItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: item }, item)) })
891
+ ] }) : null
892
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: messages.summaryEmpty })
893
+ ] })
894
+ ] });
895
+ }
896
+ function WorkspacePanel({
897
+ model,
898
+ sectionClassName,
899
+ codeClassName
900
+ }) {
901
+ const messages = useMonkeysLocaleMessages().agentWorkbench.details.workspace;
902
+ const workspace = model.workspace;
903
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
904
+ /* @__PURE__ */ jsxRuntime.jsx(
905
+ DetailsSection,
906
+ {
907
+ title: messages.diffs,
908
+ count: workspace.diffs.length,
909
+ icon: lucideReact.FileCode2,
910
+ className: sectionClassName,
911
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: workspace.diffs.map((event) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
912
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2 text-xs", children: [
913
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: event.payload.path }),
914
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-muted-foreground", children: messages.diffStatus[event.payload.status] })
915
+ ] }),
916
+ event.payload.patch ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: cn("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs", codeClassName), children: event.payload.patch }) : null
917
+ ] }, event.payload.path)) })
918
+ }
919
+ ),
920
+ /* @__PURE__ */ jsxRuntime.jsx(
921
+ DetailsSection,
922
+ {
923
+ title: messages.files,
924
+ count: workspace.files.length,
925
+ icon: lucideReact.Files,
926
+ className: sectionClassName,
927
+ children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2 text-xs", children: workspace.files.map((event) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-2", children: [
928
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutput, { className: "size-3.5 text-muted-foreground", "aria-hidden": "true" }),
929
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: event.payload.path }),
930
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: messages.fileOperation[event.payload.operation] })
931
+ ] }, event.payload.path)) })
932
+ }
933
+ ),
934
+ /* @__PURE__ */ jsxRuntime.jsx(
935
+ DetailsSection,
936
+ {
937
+ title: messages.terminals,
938
+ count: workspace.terminals.length,
939
+ icon: lucideReact.TerminalSquare,
940
+ className: sectionClassName,
941
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: workspace.terminals.map((terminal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
942
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between gap-2 text-xs font-medium", children: [
943
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: terminal.terminalId }),
944
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: terminal.exitCode === void 0 ? terminal.status : messages.exitCode({ code: terminal.exitCode }) })
945
+ ] }),
946
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: cn("mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs", codeClassName), children: [terminal.stdin, terminal.stdout, terminal.stderr].filter(Boolean).join("\n") })
947
+ ] }, terminal.terminalId)) })
948
+ }
949
+ ),
950
+ /* @__PURE__ */ jsxRuntime.jsx(
951
+ DetailsSection,
952
+ {
953
+ title: messages.tests,
954
+ count: workspace.tests.length,
955
+ icon: lucideReact.TestTube2,
956
+ className: sectionClassName,
957
+ children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2 text-xs", children: workspace.tests.map((event) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
958
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
959
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon2, { status: event.payload.status }),
960
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: event.payload.name }),
961
+ event.payload.durationMs === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: formatDuration2(event.payload.durationMs) })
962
+ ] }),
963
+ event.payload.output ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: cn("mt-2 max-h-48 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs", codeClassName), children: event.payload.output }) : null
964
+ ] }, event.payload.testId)) })
965
+ }
966
+ ),
967
+ /* @__PURE__ */ jsxRuntime.jsx(
968
+ DetailsSection,
969
+ {
970
+ title: messages.artifacts,
971
+ count: workspace.artifacts.length,
972
+ icon: lucideReact.FileOutput,
973
+ className: sectionClassName,
974
+ children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2 text-xs", children: workspace.artifacts.map((event) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-center gap-2", children: [
975
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutput, { className: "size-3.5 text-muted-foreground", "aria-hidden": "true" }),
976
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: event.payload.name }),
977
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: event.payload.kind })
978
+ ] }, event.payload.artifactId)) })
979
+ }
980
+ )
981
+ ] });
982
+ }
983
+ function AgentWorkbenchTaskDetails({
984
+ viewModel,
985
+ state = "ready",
986
+ activeTab = "summary",
987
+ className,
988
+ classNames,
989
+ onActiveTabChange,
990
+ onIntent
991
+ }) {
992
+ const messages = useMonkeysLocaleMessages().agentWorkbench.details;
993
+ if (state !== "ready") {
994
+ return /* @__PURE__ */ jsxRuntime.jsx("aside", { className: cn("flex h-full min-h-0 flex-col border-l border-border bg-background", classNames?.root, className), children: /* @__PURE__ */ jsxRuntime.jsx(StateContent, { state }) });
995
+ }
996
+ if (!viewModel) {
997
+ return /* @__PURE__ */ jsxRuntime.jsx("aside", { className: cn("flex h-full min-h-0 flex-col border-l border-border bg-background", classNames?.root, className), children: /* @__PURE__ */ jsxRuntime.jsx(StateContent, { state: "empty" }) });
998
+ }
999
+ const model = createAgentWorkbenchDetailsModel(viewModel);
1000
+ const workspaceCount = Object.values(model.workspace).reduce(
1001
+ (total, items) => total + items.length,
1002
+ 0
1003
+ );
1004
+ const workspaceAvailable = workspaceCount > 0;
1005
+ const resolvedTab = activeTab === "workspace" && !workspaceAvailable ? "summary" : activeTab;
1006
+ const tabs = [
1007
+ { id: "summary", label: messages.tabs.summary, count: model.summary ? 1 : 0 },
1008
+ ...workspaceAvailable ? [{ id: "workspace", label: messages.tabs.workspace, count: workspaceCount }] : []
1009
+ ];
1010
+ const tabId = (tab) => `agent-workbench-details-${viewModel.sessionId}-${tab}`.replace(
1011
+ /[^a-zA-Z0-9_-]/g,
1012
+ "-"
1013
+ );
1014
+ const onTabKeyDown = (event, index) => {
1015
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
1016
+ event.preventDefault();
1017
+ const nextIndex = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + tabs.length) % tabs.length;
1018
+ onActiveTabChange?.(tabs[nextIndex].id);
1019
+ };
1020
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1021
+ "aside",
1022
+ {
1023
+ className: cn(
1024
+ "flex h-full min-h-0 min-w-0 flex-col border-l border-border bg-background text-foreground",
1025
+ classNames?.root,
1026
+ className
1027
+ ),
1028
+ "data-agent-workbench-mode": model.mode,
1029
+ children: [
1030
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cn("flex shrink-0 items-center gap-2 border-b border-border px-4 py-3", classNames?.header), children: [
1031
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "truncate text-sm font-semibold", children: messages.title }),
1033
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 truncate text-xs text-muted-foreground", children: messages.description })
1034
+ ] }),
1035
+ onIntent ? /* @__PURE__ */ jsxRuntime.jsx(
1036
+ "button",
1037
+ {
1038
+ type: "button",
1039
+ className: "rounded-md p-2 text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
1040
+ "aria-label": messages.actions.close,
1041
+ onClick: () => onIntent({ type: "close" }),
1042
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-4", "aria-hidden": "true" })
1043
+ }
1044
+ ) : null
1045
+ ] }),
1046
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex shrink-0 gap-1 border-b border-border px-3 py-2", classNames?.tabs), role: "tablist", "aria-label": messages.tabs.label, children: tabs.map((tab, index) => /* @__PURE__ */ jsxRuntime.jsxs(
1047
+ "button",
1048
+ {
1049
+ id: tabId(tab.id),
1050
+ type: "button",
1051
+ role: "tab",
1052
+ "aria-selected": resolvedTab === tab.id,
1053
+ "aria-controls": `${tabId(tab.id)}-panel`,
1054
+ tabIndex: resolvedTab === tab.id ? 0 : -1,
1055
+ className: cn(
1056
+ "inline-flex min-w-0 flex-1 items-center justify-center gap-1 rounded-md px-2 py-1.5 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring",
1057
+ resolvedTab === tab.id ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-muted hover:text-foreground"
1058
+ ),
1059
+ onClick: () => onActiveTabChange?.(tab.id),
1060
+ onKeyDown: (event) => onTabKeyDown(event, index),
1061
+ children: [
1062
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: tab.label }),
1063
+ /* @__PURE__ */ jsxRuntime.jsx(Count, { value: tab.count })
1064
+ ]
1065
+ },
1066
+ tab.id
1067
+ )) }),
1068
+ /* @__PURE__ */ jsxRuntime.jsx(
1069
+ "div",
1070
+ {
1071
+ id: `${tabId(resolvedTab)}-panel`,
1072
+ role: "tabpanel",
1073
+ "aria-labelledby": tabId(resolvedTab),
1074
+ tabIndex: 0,
1075
+ className: cn("min-h-0 flex-1 overflow-y-auto p-3 outline-none", classNames?.body),
1076
+ children: resolvedTab === "summary" ? /* @__PURE__ */ jsxRuntime.jsx(SummaryPanel, { model, onIntent }) : /* @__PURE__ */ jsxRuntime.jsx(
1077
+ WorkspacePanel,
1078
+ {
1079
+ model,
1080
+ sectionClassName: classNames?.section,
1081
+ codeClassName: classNames?.code
1082
+ }
1083
+ )
1084
+ }
1085
+ )
1086
+ ]
1087
+ }
1088
+ );
1089
+ }
1090
+
1091
+ exports.AgentWorkbenchActivity = AgentWorkbenchActivity;
1092
+ exports.AgentWorkbenchTaskDetails = AgentWorkbenchTaskDetails;
1093
+ exports.createAgentWorkbenchActivityModel = createAgentWorkbenchActivityModel;
1094
+ exports.createAgentWorkbenchDetailsModel = createAgentWorkbenchDetailsModel;
1095
+ //# sourceMappingURL=index.js.map
1096
+ //# sourceMappingURL=index.js.map