@truefoundry/trueforge-ui 0.0.0 → 0.1.0-rc.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +340 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +17 -0
  4. package/README.md +640 -3
  5. package/dist/ConnectorSettings-CLBEWGQJ.js +898 -0
  6. package/dist/ConnectorSettings-CLBEWGQJ.js.map +1 -0
  7. package/dist/DockLayout-WRF7EQLD.js +35 -0
  8. package/dist/DockLayout-WRF7EQLD.js.map +1 -0
  9. package/dist/DrawerLayout-X2UXYTOS.js +156 -0
  10. package/dist/DrawerLayout-X2UXYTOS.js.map +1 -0
  11. package/dist/ModelSettings-IJ55QJQO.js +1082 -0
  12. package/dist/ModelSettings-IJ55QJQO.js.map +1 -0
  13. package/dist/OpenUiFenceBlock-SLLZSTMJ.js +9 -0
  14. package/dist/OpenUiFenceBlock-SLLZSTMJ.js.map +1 -0
  15. package/dist/SandboxSettings-S5XGZWOL.js +505 -0
  16. package/dist/SandboxSettings-S5XGZWOL.js.map +1 -0
  17. package/dist/SettingsBuilder-64Y33NP3.js +128 -0
  18. package/dist/SettingsBuilder-64Y33NP3.js.map +1 -0
  19. package/dist/SidebarLayout-M7HEOZVK.js +236 -0
  20. package/dist/SidebarLayout-M7HEOZVK.js.map +1 -0
  21. package/dist/SkillSettings-MXK4ZEI7.js +389 -0
  22. package/dist/SkillSettings-MXK4ZEI7.js.map +1 -0
  23. package/dist/WidgetLayout-7MDOKLHU.js +101 -0
  24. package/dist/WidgetLayout-7MDOKLHU.js.map +1 -0
  25. package/dist/assistant-ui.d.ts +1 -0
  26. package/dist/assistant-ui.js +9 -0
  27. package/dist/assistant-ui.js.map +1 -0
  28. package/dist/chunk-42GF723P.js +24 -0
  29. package/dist/chunk-42GF723P.js.map +1 -0
  30. package/dist/chunk-CFLVPV5M.js +29 -0
  31. package/dist/chunk-CFLVPV5M.js.map +1 -0
  32. package/dist/chunk-M6MHLVSO.js +8 -0
  33. package/dist/chunk-M6MHLVSO.js.map +1 -0
  34. package/dist/chunk-NBMP2XNL.js +89 -0
  35. package/dist/chunk-NBMP2XNL.js.map +1 -0
  36. package/dist/chunk-UBOFEI77.js +567 -0
  37. package/dist/chunk-UBOFEI77.js.map +1 -0
  38. package/dist/chunk-UHGSHDBM.js +633 -0
  39. package/dist/chunk-UHGSHDBM.js.map +1 -0
  40. package/dist/chunk-UXZOL5GO.js +2088 -0
  41. package/dist/chunk-UXZOL5GO.js.map +1 -0
  42. package/dist/chunk-WFC3W4C3.js +73 -0
  43. package/dist/chunk-WFC3W4C3.js.map +1 -0
  44. package/dist/chunk-XSHXH6EI.js +6800 -0
  45. package/dist/chunk-XSHXH6EI.js.map +1 -0
  46. package/dist/createTrueFoundryServer-B72bU-J7.d.ts +28 -0
  47. package/dist/index.d.ts +1569 -0
  48. package/dist/index.js +781 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/plugins/trueforge-agent-server-adapter/index.d.ts +479 -0
  51. package/dist/plugins/trueforge-agent-server-adapter/index.js +830 -0
  52. package/dist/plugins/trueforge-agent-server-adapter/index.js.map +1 -0
  53. package/dist/styles.css +2 -0
  54. package/package.json +129 -6
  55. package/index.js +0 -1
@@ -0,0 +1,633 @@
1
+ import {
2
+ ThemeContext,
3
+ cn
4
+ } from "./chunk-UBOFEI77.js";
5
+
6
+ // src/icons/Icon.tsx
7
+ import { createElement, isValidElement, useContext } from "react";
8
+
9
+ // src/icons/IconRegistry.tsx
10
+ import {
11
+ Archive,
12
+ ArrowDown,
13
+ ArrowLeft,
14
+ ArrowUp,
15
+ Bot,
16
+ Box,
17
+ Brain,
18
+ Check,
19
+ ChevronDown,
20
+ ChevronLeft,
21
+ ChevronRight,
22
+ CircleAlert,
23
+ CircleCheck,
24
+ CircleX,
25
+ Clock,
26
+ Code2,
27
+ Copy,
28
+ Cpu,
29
+ Download,
30
+ Ellipsis,
31
+ ExternalLink,
32
+ File,
33
+ Github,
34
+ History,
35
+ Info,
36
+ Lightbulb,
37
+ ListChecks,
38
+ ListFilter,
39
+ ListOrdered,
40
+ Loader2,
41
+ Lock,
42
+ LogOut,
43
+ Maximize2,
44
+ Menu,
45
+ Minimize2,
46
+ Moon,
47
+ PanelLeftClose,
48
+ PanelLeftOpen,
49
+ Paperclip,
50
+ Pencil,
51
+ Play,
52
+ Plug,
53
+ Plus,
54
+ RotateCw,
55
+ Save,
56
+ Search,
57
+ Settings,
58
+ Sparkle,
59
+ SquarePen,
60
+ Sun,
61
+ Terminal,
62
+ Trash2,
63
+ Wrench,
64
+ X
65
+ } from "lucide-react";
66
+ import { jsx, jsxs } from "react/jsx-runtime";
67
+ function Broom({ size = 24, ...props }) {
68
+ return /* @__PURE__ */ jsxs(
69
+ "svg",
70
+ {
71
+ xmlns: "http://www.w3.org/2000/svg",
72
+ width: size,
73
+ height: size,
74
+ viewBox: "0 0 24 24",
75
+ fill: "none",
76
+ stroke: "currentColor",
77
+ strokeWidth: "2",
78
+ strokeLinecap: "round",
79
+ strokeLinejoin: "round",
80
+ ...props,
81
+ children: [
82
+ /* @__PURE__ */ jsx("path", { d: "M13.5 10.5 22 2" }),
83
+ /* @__PURE__ */ jsx("path", { d: "M14.734 13.841a2 2 0 00-.314-2.42L12.58 9.58a2 2 0 00-2.421-.314l-7.657 4.461A1 1 0 002.3 15.3l6.403 6.403a1 1 0 001.571-.204z" }),
84
+ /* @__PURE__ */ jsx("path", { d: "m5 18 2-2" }),
85
+ /* @__PURE__ */ jsx("path", { d: "m7.699 10.7 5.602 5.601" })
86
+ ]
87
+ }
88
+ );
89
+ }
90
+ var registry = /* @__PURE__ */ new Map();
91
+ function registerIcons(icons) {
92
+ for (const [name, icon] of Object.entries(icons)) {
93
+ registry.set(name, icon);
94
+ }
95
+ }
96
+ function resolveIconName(icon) {
97
+ if (typeof icon === "string") return icon;
98
+ return icon[icon.length - 1] ?? "";
99
+ }
100
+ var defaults = {
101
+ paperclip: Paperclip,
102
+ "arrow-up": ArrowUp,
103
+ "arrow-down": ArrowDown,
104
+ "arrow-left": ArrowLeft,
105
+ xmark: X,
106
+ check: Check,
107
+ pencil: Pencil,
108
+ play: Play,
109
+ "square-pen": SquarePen,
110
+ "rotate-right": RotateCw,
111
+ broom: Broom,
112
+ ellipsis: Ellipsis,
113
+ trash: Trash2,
114
+ "box-archive": Archive,
115
+ "clock-rotate-left": History,
116
+ "circle-exclamation": CircleAlert,
117
+ "chevron-down": ChevronDown,
118
+ "chevron-left": ChevronLeft,
119
+ "chevron-right": ChevronRight,
120
+ loader: Loader2,
121
+ file: File,
122
+ clone: Copy,
123
+ copy: Copy,
124
+ bars: Menu,
125
+ "panel-left-close": PanelLeftClose,
126
+ "panel-left-open": PanelLeftOpen,
127
+ plus: Plus,
128
+ sun: Sun,
129
+ moon: Moon,
130
+ settings: Settings,
131
+ "log-out": LogOut,
132
+ search: Search,
133
+ clock: Clock,
134
+ "circle-check": CircleCheck,
135
+ "circle-xmark": CircleX,
136
+ "oauth-success": CircleCheck,
137
+ "oauth-error": CircleX,
138
+ "oauth-loading": Loader2,
139
+ "welcome-sparkle": Sparkle,
140
+ robot: Bot,
141
+ funnel: ListFilter,
142
+ plug: Plug,
143
+ "list-check": ListChecks,
144
+ lock: Lock,
145
+ lightbulb: Lightbulb,
146
+ wrench: Wrench,
147
+ cpu: Cpu,
148
+ cube: Box,
149
+ "list-ol": ListOrdered,
150
+ download: Download,
151
+ save: Save,
152
+ brain: Brain,
153
+ terminal: Terminal,
154
+ code: Code2,
155
+ expand: Maximize2,
156
+ "expand-alt": Maximize2,
157
+ compress: Minimize2,
158
+ "external-link": ExternalLink,
159
+ github: Github,
160
+ info: Info
161
+ };
162
+ for (const [name, icon] of Object.entries(defaults)) {
163
+ registry.set(name, icon);
164
+ }
165
+ function lookupIcon(name, themeIcons) {
166
+ if (themeIcons && name in themeIcons) {
167
+ return themeIcons[name];
168
+ }
169
+ return registry.get(name);
170
+ }
171
+
172
+ // src/icons/Icon.tsx
173
+ import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
174
+ function isComponent(entry) {
175
+ if (typeof entry === "function") return true;
176
+ return typeof entry === "object" && entry !== null && !isValidElement(entry) && !Array.isArray(entry) && "$$typeof" in entry;
177
+ }
178
+ function renderEntry(entry, props) {
179
+ if (isComponent(entry)) {
180
+ const { size, className, style, ...aria } = props;
181
+ return createElement(entry, {
182
+ className: cn("inline-block shrink-0", className),
183
+ style,
184
+ size,
185
+ width: size,
186
+ height: size,
187
+ "aria-hidden": aria["aria-label"] ? void 0 : aria["aria-hidden"] ?? true,
188
+ "aria-label": aria["aria-label"],
189
+ ...aria["data-testid"] === void 0 ? {} : { "data-testid": aria["data-testid"] },
190
+ role: aria["aria-label"] ? "img" : void 0
191
+ });
192
+ }
193
+ return entry;
194
+ }
195
+ function Icon({ name, className, style, size = "1em", ...aria }) {
196
+ const themeIcons = useContext(ThemeContext)?.icons;
197
+ const resolved = resolveIconName(name);
198
+ const entry = lookupIcon(resolved, themeIcons);
199
+ if (!entry) return null;
200
+ return /* @__PURE__ */ jsx2(Fragment, { children: renderEntry(entry, { className, style, size, ...aria }) });
201
+ }
202
+
203
+ // src/atoms/primitives/Spinner.tsx
204
+ import "react";
205
+ import { jsx as jsx3 } from "react/jsx-runtime";
206
+ function Spinner({ size = 16, className, ...props }) {
207
+ const r = size / 2 * 0.75;
208
+ const cx = size / 2;
209
+ const circumference = 2 * Math.PI * r;
210
+ return /* @__PURE__ */ jsx3(
211
+ "svg",
212
+ {
213
+ role: "status",
214
+ "aria-label": "Loading",
215
+ width: size,
216
+ height: size,
217
+ viewBox: `0 0 ${size} ${size}`,
218
+ fill: "none",
219
+ className: cn("animate-spin", className),
220
+ ...props,
221
+ children: /* @__PURE__ */ jsx3(
222
+ "circle",
223
+ {
224
+ cx,
225
+ cy: cx,
226
+ r,
227
+ stroke: "currentColor",
228
+ strokeWidth: 2,
229
+ strokeLinecap: "round",
230
+ strokeDasharray: `${circumference * 0.75} ${circumference * 0.25}`,
231
+ opacity: 0.8
232
+ }
233
+ )
234
+ }
235
+ );
236
+ }
237
+
238
+ // src/atoms/lib/buttonClasses.ts
239
+ var variantClasses = {
240
+ default: "bg-primary-button-bg text-primary-button-text shadow hover:bg-primary-button-hover",
241
+ secondary: "border border-input-border bg-secondary-button-bg text-secondary-button-text shadow-sm hover:bg-secondary-button-hover",
242
+ ghost: "bg-ghost-button-bg text-ghost-button-text hover:bg-ghost-button-hover",
243
+ destructive: "bg-failure-bg text-failure-text shadow-sm hover:bg-failure-bg/90",
244
+ outline: "border border-input-border bg-secondary-button-bg text-secondary-button-text shadow-sm hover:bg-secondary-button-hover"
245
+ };
246
+ var sizeClasses = {
247
+ default: "h-9 px-4 py-2 text-sm",
248
+ sm: "h-8 rounded-md px-3 text-xs",
249
+ lg: "h-10 rounded-md px-8 text-base",
250
+ icon: "h-8 w-8"
251
+ };
252
+ var baseClasses = "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:cursor-not-allowed disabled:opacity-50";
253
+ function auiButtonClass({
254
+ variant = "default",
255
+ size = "default",
256
+ className
257
+ } = {}) {
258
+ return cn(baseClasses, variantClasses[variant], sizeClasses[size], className);
259
+ }
260
+
261
+ // src/server/ServerContext.tsx
262
+ import { createContext, useCallback, useContext as useContext2, useEffect, useMemo, useRef, useState } from "react";
263
+ import { jsx as jsx4 } from "react/jsx-runtime";
264
+ var ServerContext = createContext(null);
265
+ var ServerCapabilitiesContext = createContext(null);
266
+ function ServerProvider({ server, children }) {
267
+ const [capabilities, setCapabilities] = useState(null);
268
+ const cancelActiveRequestRef = useRef(null);
269
+ const refreshCapabilities = useCallback(() => {
270
+ cancelActiveRequestRef.current?.();
271
+ let cancelled = false;
272
+ cancelActiveRequestRef.current = () => {
273
+ cancelled = true;
274
+ };
275
+ void server.getCapabilities().then((response) => {
276
+ if (!cancelled) setCapabilities(response.data);
277
+ }).catch(() => {
278
+ });
279
+ }, [server]);
280
+ useEffect(() => {
281
+ setCapabilities(null);
282
+ refreshCapabilities();
283
+ return () => {
284
+ cancelActiveRequestRef.current?.();
285
+ };
286
+ }, [refreshCapabilities]);
287
+ const capabilitiesValue = useMemo(
288
+ () => ({ capabilities, refresh: refreshCapabilities }),
289
+ [capabilities, refreshCapabilities]
290
+ );
291
+ return /* @__PURE__ */ jsx4(ServerContext.Provider, { value: server, children: /* @__PURE__ */ jsx4(ServerCapabilitiesContext.Provider, { value: capabilitiesValue, children }) });
292
+ }
293
+ function useServer() {
294
+ const server = useContext2(ServerContext);
295
+ if (server == null) {
296
+ throw new Error("useServer must be used within a ServerProvider.");
297
+ }
298
+ return server;
299
+ }
300
+ function useOptionalServer() {
301
+ return useContext2(ServerContext);
302
+ }
303
+ function useServerCapabilities() {
304
+ return useContext2(ServerCapabilitiesContext)?.capabilities ?? null;
305
+ }
306
+ function useOptionalRefreshServerCapabilities() {
307
+ return useContext2(ServerCapabilitiesContext)?.refresh ?? null;
308
+ }
309
+ function useCatalogServer() {
310
+ const server = useServer();
311
+ if (server.catalog == null) {
312
+ throw new Error("useCatalogServer requires AgentUIServer.catalog. Pass catalog to createTrueFoundryServer.");
313
+ }
314
+ return server.catalog;
315
+ }
316
+ function useOptionalCatalogServer() {
317
+ return useOptionalServer()?.catalog ?? null;
318
+ }
319
+
320
+ // src/server/ShellModeContext.tsx
321
+ import { createContext as createContext2, useCallback as useCallback2, useContext as useContext3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
322
+ import { jsx as jsx5 } from "react/jsx-runtime";
323
+ var DEFAULT_AGENT_CONFIG = {
324
+ mode: "AgentLibraryWithComposer"
325
+ };
326
+ var ShellModeContext = createContext2(null);
327
+ var FALLBACK_MUTABLE_SPEC = {
328
+ model: { name: "openai-main/gpt-4.1" }
329
+ };
330
+ function mutableSeedFromConfig(config) {
331
+ if (config.mode === "AgentComposer" || config.mode === "AgentLibraryWithComposer") {
332
+ return config.defaultAgentSpec ?? FALLBACK_MUTABLE_SPEC;
333
+ }
334
+ return FALLBACK_MUTABLE_SPEC;
335
+ }
336
+ function initialMode(config, mutableSeed) {
337
+ switch (config.mode) {
338
+ case "SingleAgent":
339
+ return {
340
+ status: "active",
341
+ isMutable: false,
342
+ agentId: config.name,
343
+ agentName: config.name,
344
+ locked: true
345
+ };
346
+ case "AgentLibrary":
347
+ return { status: "idle" };
348
+ case "AgentComposer":
349
+ case "AgentLibraryWithComposer":
350
+ return {
351
+ status: "active",
352
+ isMutable: true,
353
+ agentSpec: mutableSeed,
354
+ locked: false
355
+ };
356
+ }
357
+ }
358
+ function libraryAgentId(agent) {
359
+ return agent.agentId ?? agent.name;
360
+ }
361
+ function ShellModeProvider({
362
+ agentConfig = DEFAULT_AGENT_CONFIG,
363
+ initialSettingsOpen = false,
364
+ children
365
+ }) {
366
+ const capabilities = useServerCapabilities();
367
+ const refreshCapabilities = useOptionalRefreshServerCapabilities();
368
+ const mutableSeedRef = useRef2(mutableSeedFromConfig(agentConfig));
369
+ if ((agentConfig.mode === "AgentComposer" || agentConfig.mode === "AgentLibraryWithComposer") && agentConfig.defaultAgentSpec != null) {
370
+ mutableSeedRef.current = agentConfig.defaultAgentSpec;
371
+ }
372
+ const mutableSeed = mutableSeedRef.current;
373
+ const isLibraryEnabled = agentConfig.mode === "AgentLibrary" || agentConfig.mode === "AgentLibraryWithComposer";
374
+ const isComposerEnabled = agentConfig.mode === "AgentComposer" || agentConfig.mode === "AgentLibraryWithComposer";
375
+ const isNewChatEnabled = agentConfig.mode !== "AgentLibrary";
376
+ const locked = agentConfig.mode === "SingleAgent";
377
+ const [mode, setMode] = useState2(() => initialMode(agentConfig, mutableSeed));
378
+ const [mutableEpoch, setMutableEpoch] = useState2(0);
379
+ const [clearEpoch, setClearEpoch] = useState2(0);
380
+ const [agentsListEpoch, setAgentsListEpoch] = useState2(0);
381
+ const [settingsOpenState, setSettingsOpenState] = useState2(initialSettingsOpen);
382
+ const [historyAgentFilter, setHistoryAgentFilter] = useState2(null);
383
+ const [pendingSessionId, setPendingSessionId] = useState2(void 0);
384
+ const settingsEnabled = capabilities?.settings?.enabled !== false;
385
+ const settingsOpen = settingsEnabled && settingsOpenState;
386
+ const setSettingsOpen = useCallback2(
387
+ (open) => {
388
+ setSettingsOpenState(settingsEnabled && open);
389
+ },
390
+ [settingsEnabled]
391
+ );
392
+ useEffect2(() => {
393
+ if (!settingsEnabled) {
394
+ setSettingsOpenState(false);
395
+ }
396
+ }, [settingsEnabled]);
397
+ const invalidateAgentsList = useCallback2(() => {
398
+ setAgentsListEpoch((n) => n + 1);
399
+ }, []);
400
+ const lockedAgentName = agentConfig.mode === "SingleAgent" ? agentConfig.name : "";
401
+ const effectiveMode = useMemo2(() => {
402
+ if (!locked) return mode;
403
+ return {
404
+ status: "active",
405
+ isMutable: false,
406
+ agentId: lockedAgentName,
407
+ agentName: lockedAgentName,
408
+ locked: true
409
+ };
410
+ }, [locked, lockedAgentName, mode]);
411
+ const listSessionsAgentId = useMemo2(() => {
412
+ if (locked) return lockedAgentName;
413
+ if (!isLibraryEnabled) return void 0;
414
+ return historyAgentFilter ?? void 0;
415
+ }, [locked, lockedAgentName, isLibraryEnabled, historyAgentFilter]);
416
+ const bumpEpoch = useCallback2((isMutable) => {
417
+ if (isMutable) setMutableEpoch((n) => n + 1);
418
+ else setClearEpoch((n) => n + 1);
419
+ }, []);
420
+ const selectLibraryAgent = useCallback2(
421
+ (req) => {
422
+ if (req.isMutable) {
423
+ if (!isComposerEnabled) return;
424
+ setSettingsOpen(false);
425
+ setPendingSessionId(void 0);
426
+ setMode({
427
+ status: "active",
428
+ isMutable: true,
429
+ agentId: req.agentId,
430
+ agentName: req.agentName,
431
+ agentSpec: req.agentSpec ?? mutableSeedRef.current,
432
+ locked: false
433
+ });
434
+ bumpEpoch(true);
435
+ return;
436
+ }
437
+ if (!isLibraryEnabled) return;
438
+ const agentName = req.agentName ?? req.agentId;
439
+ if (agentName == null) return;
440
+ setSettingsOpen(false);
441
+ setPendingSessionId(void 0);
442
+ setMode({
443
+ status: "active",
444
+ isMutable: false,
445
+ agentId: req.agentId ?? agentName,
446
+ agentName,
447
+ locked: false
448
+ });
449
+ bumpEpoch(false);
450
+ },
451
+ [isComposerEnabled, isLibraryEnabled, bumpEpoch, setSettingsOpen]
452
+ );
453
+ const bindMutableAgent = useCallback2(
454
+ (req) => {
455
+ if (!isComposerEnabled) return;
456
+ setMode((prev) => {
457
+ if (prev.status !== "active" || !prev.isMutable) return prev;
458
+ return {
459
+ status: "active",
460
+ isMutable: true,
461
+ agentId: req.agentId,
462
+ agentName: req.agentName,
463
+ agentSpec: req.agentSpec,
464
+ locked: false
465
+ };
466
+ });
467
+ },
468
+ [isComposerEnabled]
469
+ );
470
+ const selectAgent = useCallback2(
471
+ (name) => {
472
+ selectLibraryAgent({ isMutable: false, agentId: name, agentName: name });
473
+ },
474
+ [selectLibraryAgent]
475
+ );
476
+ const openDraft = useCallback2(() => {
477
+ if (!isComposerEnabled) return;
478
+ refreshCapabilities?.();
479
+ selectLibraryAgent({ isMutable: true, agentSpec: mutableSeedRef.current });
480
+ }, [isComposerEnabled, refreshCapabilities, selectLibraryAgent]);
481
+ const openHistorySession = useCallback2(
482
+ ({
483
+ sessionId,
484
+ agentName,
485
+ isMutable: isMutableOpt
486
+ }) => {
487
+ setSettingsOpen(false);
488
+ setPendingSessionId(sessionId);
489
+ const isMutable = isMutableOpt ?? agentName == null;
490
+ if (isMutable) {
491
+ if (!isComposerEnabled) return;
492
+ setMode({
493
+ status: "active",
494
+ isMutable: true,
495
+ agentSpec: mutableSeedRef.current,
496
+ locked: false
497
+ });
498
+ bumpEpoch(true);
499
+ return;
500
+ }
501
+ if (locked) {
502
+ if (agentName == null || lockedAgentName !== agentName) return;
503
+ } else if (!isLibraryEnabled) {
504
+ return;
505
+ }
506
+ setMode({
507
+ status: "active",
508
+ isMutable: false,
509
+ locked: false,
510
+ ...agentName != null ? { agentId: agentName, agentName } : {}
511
+ });
512
+ bumpEpoch(false);
513
+ },
514
+ [isLibraryEnabled, isComposerEnabled, locked, lockedAgentName, bumpEpoch, setSettingsOpen]
515
+ );
516
+ const clearChat = useCallback2(() => {
517
+ if (effectiveMode.status === "idle") return;
518
+ setPendingSessionId(void 0);
519
+ if (effectiveMode.isMutable) {
520
+ setMode({
521
+ status: "active",
522
+ isMutable: true,
523
+ agentId: effectiveMode.agentId,
524
+ agentName: effectiveMode.agentName,
525
+ agentSpec: effectiveMode.agentSpec ?? mutableSeedRef.current,
526
+ locked: false
527
+ });
528
+ bumpEpoch(true);
529
+ return;
530
+ }
531
+ bumpEpoch(false);
532
+ }, [effectiveMode, bumpEpoch]);
533
+ const runtimeKey = useMemo2(() => {
534
+ if (effectiveMode.status === "idle") return "idle";
535
+ if (effectiveMode.isMutable) {
536
+ return `mut:${pendingSessionId ?? ""}:${mutableEpoch}`;
537
+ }
538
+ const id = effectiveMode.agentId ?? effectiveMode.agentName ?? "";
539
+ return `immut:${id}:${pendingSessionId ?? ""}:${clearEpoch}`;
540
+ }, [effectiveMode, mutableEpoch, clearEpoch, pendingSessionId]);
541
+ const value = useMemo2(
542
+ () => ({
543
+ mode: effectiveMode,
544
+ agentConfigMode: agentConfig.mode,
545
+ isLibraryEnabled,
546
+ isComposerEnabled,
547
+ isNewChatEnabled,
548
+ settingsOpen,
549
+ setSettingsOpen,
550
+ selectLibraryAgent,
551
+ bindMutableAgent,
552
+ selectAgent,
553
+ openDraft,
554
+ openHistorySession,
555
+ clearChat,
556
+ runtimeKey,
557
+ historyAgentFilter,
558
+ setHistoryAgentFilter,
559
+ listSessionsAgentId,
560
+ pendingSessionId,
561
+ agentsListEpoch,
562
+ invalidateAgentsList
563
+ }),
564
+ [
565
+ effectiveMode,
566
+ agentConfig.mode,
567
+ isLibraryEnabled,
568
+ isComposerEnabled,
569
+ isNewChatEnabled,
570
+ settingsOpen,
571
+ setSettingsOpen,
572
+ selectLibraryAgent,
573
+ bindMutableAgent,
574
+ selectAgent,
575
+ openDraft,
576
+ openHistorySession,
577
+ clearChat,
578
+ runtimeKey,
579
+ historyAgentFilter,
580
+ listSessionsAgentId,
581
+ pendingSessionId,
582
+ agentsListEpoch,
583
+ invalidateAgentsList
584
+ ]
585
+ );
586
+ return /* @__PURE__ */ jsx5(ShellModeContext.Provider, { value, children });
587
+ }
588
+ function useShellMode() {
589
+ const ctx = useContext3(ShellModeContext);
590
+ if (ctx == null) {
591
+ throw new Error("useShellMode must be used within a ShellModeProvider.");
592
+ }
593
+ return ctx;
594
+ }
595
+ function useOptionalShellMode() {
596
+ return useContext3(ShellModeContext);
597
+ }
598
+ function shellIsMutable(mode) {
599
+ return mode.status === "active" && mode.isMutable;
600
+ }
601
+
602
+ // src/atoms/lib/CompactLayoutContext.tsx
603
+ import { createContext as createContext3, useContext as useContext4 } from "react";
604
+ import { jsx as jsx6 } from "react/jsx-runtime";
605
+ var CompactLayoutContext = createContext3(false);
606
+ function CompactLayoutProvider({ children }) {
607
+ return /* @__PURE__ */ jsx6(CompactLayoutContext.Provider, { value: true, children });
608
+ }
609
+ function useCompactLayout() {
610
+ return useContext4(CompactLayoutContext);
611
+ }
612
+
613
+ export {
614
+ registerIcons,
615
+ Icon,
616
+ Spinner,
617
+ auiButtonClass,
618
+ ServerProvider,
619
+ useServer,
620
+ useOptionalServer,
621
+ useServerCapabilities,
622
+ useCatalogServer,
623
+ useOptionalCatalogServer,
624
+ DEFAULT_AGENT_CONFIG,
625
+ libraryAgentId,
626
+ ShellModeProvider,
627
+ useShellMode,
628
+ useOptionalShellMode,
629
+ shellIsMutable,
630
+ CompactLayoutProvider,
631
+ useCompactLayout
632
+ };
633
+ //# sourceMappingURL=chunk-UHGSHDBM.js.map