@truefoundry/trueforge-ui 0.1.0 → 0.2.1
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/CHANGELOG.md +34 -15
- package/README.md +38 -38
- package/dist/{ConnectorSettings-H37ZFC6Z.js → ConnectorSettings-XEO5ZQO5.js} +8 -6
- package/dist/{ConnectorSettings-H37ZFC6Z.js.map → ConnectorSettings-XEO5ZQO5.js.map} +1 -1
- package/dist/{DockLayout-KEMFRWIR.js → DockLayout-F2KYSY4U.js} +10 -8
- package/dist/{DockLayout-KEMFRWIR.js.map → DockLayout-F2KYSY4U.js.map} +1 -1
- package/dist/{DrawerLayout-ZVWCKEIS.js → DrawerLayout-FJ7XC2FU.js} +12 -9
- package/dist/{DrawerLayout-ZVWCKEIS.js.map → DrawerLayout-FJ7XC2FU.js.map} +1 -1
- package/dist/{ModelSettings-QJMYHCMD.js → ModelSettings-2QB7LE22.js} +8 -6
- package/dist/{ModelSettings-QJMYHCMD.js.map → ModelSettings-2QB7LE22.js.map} +1 -1
- package/dist/OpenUiFenceBlock-3EFPY4JW.js +9 -0
- package/dist/{SandboxSettings-BUBMLW7Q.js → SandboxSettings-QDDIPRBP.js} +8 -6
- package/dist/{SandboxSettings-BUBMLW7Q.js.map → SandboxSettings-QDDIPRBP.js.map} +1 -1
- package/dist/{SettingsBuilder-26XSGIHK.js → SettingsBuilder-4NF3Y7UZ.js} +10 -8
- package/dist/{SettingsBuilder-26XSGIHK.js.map → SettingsBuilder-4NF3Y7UZ.js.map} +1 -1
- package/dist/ShellRouteSync-T4WLY57Q.js +172 -0
- package/dist/ShellRouteSync-T4WLY57Q.js.map +1 -0
- package/dist/{SidebarLayout-F3XFXW7B.js → SidebarLayout-KX6RSJTP.js} +12 -9
- package/dist/{SidebarLayout-F3XFXW7B.js.map → SidebarLayout-KX6RSJTP.js.map} +1 -1
- package/dist/{SkillSettings-IRMGDFRG.js → SkillSettings-5EETEEDI.js} +8 -6
- package/dist/{SkillSettings-IRMGDFRG.js.map → SkillSettings-5EETEEDI.js.map} +1 -1
- package/dist/TrueForgeUIWithRouter-IAQQTD5V.js +30 -0
- package/dist/TrueForgeUIWithRouter-IAQQTD5V.js.map +1 -0
- package/dist/{WidgetLayout-SZMABKIR.js → WidgetLayout-S6EK62TZ.js} +10 -8
- package/dist/{WidgetLayout-SZMABKIR.js.map → WidgetLayout-S6EK62TZ.js.map} +1 -1
- package/dist/chunk-72LC2M3R.js +567 -0
- package/dist/chunk-72LC2M3R.js.map +1 -0
- package/dist/chunk-EKVN6QSO.js +493 -0
- package/dist/chunk-EKVN6QSO.js.map +1 -0
- package/dist/chunk-FXCYLEFB.js +64 -0
- package/dist/chunk-FXCYLEFB.js.map +1 -0
- package/dist/chunk-IFLE7OMM.js +527 -0
- package/dist/chunk-IFLE7OMM.js.map +1 -0
- package/dist/{chunk-HT5HKQXE.js → chunk-JRRCAKEP.js} +2 -2
- package/dist/{chunk-7EEOWDLE.js → chunk-PTYEOSHT.js} +10 -8
- package/dist/{chunk-7EEOWDLE.js.map → chunk-PTYEOSHT.js.map} +1 -1
- package/dist/{chunk-H7DR64W3.js → chunk-UACLSDNL.js} +39 -94
- package/dist/chunk-UACLSDNL.js.map +1 -0
- package/dist/{chunk-QGNLP2EE.js → chunk-UU7C5DQ3.js} +18 -8
- package/dist/chunk-UU7C5DQ3.js.map +1 -0
- package/dist/chunk-WQULF5AT.js +460 -0
- package/dist/chunk-WQULF5AT.js.map +1 -0
- package/dist/{chunk-LRQHHZDX.js → chunk-X6U2Q7X5.js} +7 -5
- package/dist/{chunk-LRQHHZDX.js.map → chunk-X6U2Q7X5.js.map} +1 -1
- package/dist/chunk-YIWUG6MC.js +101 -0
- package/dist/chunk-YIWUG6MC.js.map +1 -0
- package/dist/index.d.ts +57 -9
- package/dist/index.js +41 -428
- package/dist/index.js.map +1 -1
- package/dist/plugins/trueforge-agent-server-adapter/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -6
- package/dist/OpenUiFenceBlock-XFBUGPKQ.js +0 -9
- package/dist/chunk-DTF7ZMUJ.js +0 -567
- package/dist/chunk-DTF7ZMUJ.js.map +0 -1
- package/dist/chunk-H7DR64W3.js.map +0 -1
- package/dist/chunk-QGNLP2EE.js.map +0 -1
- package/dist/chunk-XAZ5HJXV.js +0 -862
- package/dist/chunk-XAZ5HJXV.js.map +0 -1
- /package/dist/{OpenUiFenceBlock-XFBUGPKQ.js.map → OpenUiFenceBlock-3EFPY4JW.js.map} +0 -0
- /package/dist/{chunk-HT5HKQXE.js.map → chunk-JRRCAKEP.js.map} +0 -0
package/dist/chunk-XAZ5HJXV.js
DELETED
|
@@ -1,862 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ThemeContext,
|
|
3
|
-
cn
|
|
4
|
-
} from "./chunk-DTF7ZMUJ.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
|
-
BookOpen,
|
|
16
|
-
Bot,
|
|
17
|
-
Box,
|
|
18
|
-
Brain,
|
|
19
|
-
Check,
|
|
20
|
-
ChevronDown,
|
|
21
|
-
ChevronLeft,
|
|
22
|
-
ChevronRight,
|
|
23
|
-
CircleAlert,
|
|
24
|
-
CircleCheck,
|
|
25
|
-
CircleX,
|
|
26
|
-
Clock,
|
|
27
|
-
Code2,
|
|
28
|
-
Copy,
|
|
29
|
-
Cpu,
|
|
30
|
-
Download,
|
|
31
|
-
Ellipsis,
|
|
32
|
-
ExternalLink,
|
|
33
|
-
File,
|
|
34
|
-
Github,
|
|
35
|
-
History,
|
|
36
|
-
Info,
|
|
37
|
-
Lightbulb,
|
|
38
|
-
ListChecks,
|
|
39
|
-
ListFilter,
|
|
40
|
-
ListOrdered,
|
|
41
|
-
Loader2,
|
|
42
|
-
Lock,
|
|
43
|
-
LogOut,
|
|
44
|
-
Maximize2,
|
|
45
|
-
Menu,
|
|
46
|
-
Minimize2,
|
|
47
|
-
Moon,
|
|
48
|
-
PanelLeftClose,
|
|
49
|
-
PanelLeftOpen,
|
|
50
|
-
Paperclip,
|
|
51
|
-
Pencil,
|
|
52
|
-
Play,
|
|
53
|
-
Plug,
|
|
54
|
-
Plus,
|
|
55
|
-
RotateCw,
|
|
56
|
-
Save,
|
|
57
|
-
Search,
|
|
58
|
-
Settings,
|
|
59
|
-
Sparkle,
|
|
60
|
-
SquarePen,
|
|
61
|
-
Sun,
|
|
62
|
-
Terminal,
|
|
63
|
-
Trash2,
|
|
64
|
-
TriangleAlert,
|
|
65
|
-
Wrench,
|
|
66
|
-
X
|
|
67
|
-
} from "lucide-react";
|
|
68
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
69
|
-
function Broom({ size = 24, ...props }) {
|
|
70
|
-
return /* @__PURE__ */ jsxs(
|
|
71
|
-
"svg",
|
|
72
|
-
{
|
|
73
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
-
width: size,
|
|
75
|
-
height: size,
|
|
76
|
-
viewBox: "0 0 24 24",
|
|
77
|
-
fill: "none",
|
|
78
|
-
stroke: "currentColor",
|
|
79
|
-
strokeWidth: "2",
|
|
80
|
-
strokeLinecap: "round",
|
|
81
|
-
strokeLinejoin: "round",
|
|
82
|
-
...props,
|
|
83
|
-
children: [
|
|
84
|
-
/* @__PURE__ */ jsx("path", { d: "M13.5 10.5 22 2" }),
|
|
85
|
-
/* @__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" }),
|
|
86
|
-
/* @__PURE__ */ jsx("path", { d: "m5 18 2-2" }),
|
|
87
|
-
/* @__PURE__ */ jsx("path", { d: "m7.699 10.7 5.602 5.601" })
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
var registry = /* @__PURE__ */ new Map();
|
|
93
|
-
function registerIcons(icons) {
|
|
94
|
-
for (const [name, icon] of Object.entries(icons)) {
|
|
95
|
-
registry.set(name, icon);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function resolveIconName(icon) {
|
|
99
|
-
if (typeof icon === "string") return icon;
|
|
100
|
-
return icon[icon.length - 1] ?? "";
|
|
101
|
-
}
|
|
102
|
-
var defaults = {
|
|
103
|
-
paperclip: Paperclip,
|
|
104
|
-
"arrow-up": ArrowUp,
|
|
105
|
-
"arrow-down": ArrowDown,
|
|
106
|
-
"arrow-left": ArrowLeft,
|
|
107
|
-
xmark: X,
|
|
108
|
-
check: Check,
|
|
109
|
-
pencil: Pencil,
|
|
110
|
-
play: Play,
|
|
111
|
-
"square-pen": SquarePen,
|
|
112
|
-
"rotate-right": RotateCw,
|
|
113
|
-
broom: Broom,
|
|
114
|
-
ellipsis: Ellipsis,
|
|
115
|
-
trash: Trash2,
|
|
116
|
-
"box-archive": Archive,
|
|
117
|
-
"clock-rotate-left": History,
|
|
118
|
-
"circle-exclamation": CircleAlert,
|
|
119
|
-
info: Info,
|
|
120
|
-
"triangle-exclamation": TriangleAlert,
|
|
121
|
-
"chevron-down": ChevronDown,
|
|
122
|
-
"chevron-left": ChevronLeft,
|
|
123
|
-
"chevron-right": ChevronRight,
|
|
124
|
-
loader: Loader2,
|
|
125
|
-
file: File,
|
|
126
|
-
clone: Copy,
|
|
127
|
-
copy: Copy,
|
|
128
|
-
bars: Menu,
|
|
129
|
-
"panel-left-close": PanelLeftClose,
|
|
130
|
-
"panel-left-open": PanelLeftOpen,
|
|
131
|
-
plus: Plus,
|
|
132
|
-
sun: Sun,
|
|
133
|
-
moon: Moon,
|
|
134
|
-
settings: Settings,
|
|
135
|
-
"log-out": LogOut,
|
|
136
|
-
search: Search,
|
|
137
|
-
clock: Clock,
|
|
138
|
-
"circle-check": CircleCheck,
|
|
139
|
-
"circle-xmark": CircleX,
|
|
140
|
-
"oauth-success": CircleCheck,
|
|
141
|
-
"oauth-error": CircleX,
|
|
142
|
-
"oauth-loading": Loader2,
|
|
143
|
-
"welcome-sparkle": Sparkle,
|
|
144
|
-
robot: Bot,
|
|
145
|
-
"book-open": BookOpen,
|
|
146
|
-
funnel: ListFilter,
|
|
147
|
-
plug: Plug,
|
|
148
|
-
"list-check": ListChecks,
|
|
149
|
-
lock: Lock,
|
|
150
|
-
lightbulb: Lightbulb,
|
|
151
|
-
wrench: Wrench,
|
|
152
|
-
cpu: Cpu,
|
|
153
|
-
cube: Box,
|
|
154
|
-
"list-ol": ListOrdered,
|
|
155
|
-
download: Download,
|
|
156
|
-
save: Save,
|
|
157
|
-
brain: Brain,
|
|
158
|
-
terminal: Terminal,
|
|
159
|
-
code: Code2,
|
|
160
|
-
expand: Maximize2,
|
|
161
|
-
"expand-alt": Maximize2,
|
|
162
|
-
compress: Minimize2,
|
|
163
|
-
"external-link": ExternalLink,
|
|
164
|
-
github: Github
|
|
165
|
-
};
|
|
166
|
-
for (const [name, icon] of Object.entries(defaults)) {
|
|
167
|
-
registry.set(name, icon);
|
|
168
|
-
}
|
|
169
|
-
function lookupIcon(name, themeIcons) {
|
|
170
|
-
if (themeIcons && name in themeIcons) {
|
|
171
|
-
return themeIcons[name];
|
|
172
|
-
}
|
|
173
|
-
return registry.get(name);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// src/icons/Icon.tsx
|
|
177
|
-
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
178
|
-
function isComponent(entry) {
|
|
179
|
-
if (typeof entry === "function") return true;
|
|
180
|
-
return typeof entry === "object" && entry !== null && !isValidElement(entry) && !Array.isArray(entry) && "$$typeof" in entry;
|
|
181
|
-
}
|
|
182
|
-
function renderEntry(entry, props) {
|
|
183
|
-
if (isComponent(entry)) {
|
|
184
|
-
const { size, className, style, ...aria } = props;
|
|
185
|
-
return createElement(entry, {
|
|
186
|
-
className: cn("inline-block shrink-0", className),
|
|
187
|
-
style,
|
|
188
|
-
size,
|
|
189
|
-
width: size,
|
|
190
|
-
height: size,
|
|
191
|
-
"aria-hidden": aria["aria-label"] ? void 0 : aria["aria-hidden"] ?? true,
|
|
192
|
-
"aria-label": aria["aria-label"],
|
|
193
|
-
...aria["data-testid"] === void 0 ? {} : { "data-testid": aria["data-testid"] },
|
|
194
|
-
role: aria["aria-label"] ? "img" : void 0
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return entry;
|
|
198
|
-
}
|
|
199
|
-
function Icon({ name, className, style, size = "1em", ...aria }) {
|
|
200
|
-
const themeIcons = useContext(ThemeContext)?.icons;
|
|
201
|
-
const resolved = resolveIconName(name);
|
|
202
|
-
const entry = lookupIcon(resolved, themeIcons);
|
|
203
|
-
if (!entry) return null;
|
|
204
|
-
return /* @__PURE__ */ jsx2(Fragment, { children: renderEntry(entry, { className, style, size, ...aria }) });
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// src/atoms/primitives/Spinner.tsx
|
|
208
|
-
import "react";
|
|
209
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
210
|
-
function Spinner({ size = 16, className, ...props }) {
|
|
211
|
-
const r = size / 2 * 0.75;
|
|
212
|
-
const cx = size / 2;
|
|
213
|
-
const circumference = 2 * Math.PI * r;
|
|
214
|
-
return /* @__PURE__ */ jsx3(
|
|
215
|
-
"svg",
|
|
216
|
-
{
|
|
217
|
-
role: "status",
|
|
218
|
-
"aria-label": "Loading",
|
|
219
|
-
width: size,
|
|
220
|
-
height: size,
|
|
221
|
-
viewBox: `0 0 ${size} ${size}`,
|
|
222
|
-
fill: "none",
|
|
223
|
-
className: cn("animate-spin", className),
|
|
224
|
-
...props,
|
|
225
|
-
children: /* @__PURE__ */ jsx3(
|
|
226
|
-
"circle",
|
|
227
|
-
{
|
|
228
|
-
cx,
|
|
229
|
-
cy: cx,
|
|
230
|
-
r,
|
|
231
|
-
stroke: "currentColor",
|
|
232
|
-
strokeWidth: 2,
|
|
233
|
-
strokeLinecap: "round",
|
|
234
|
-
strokeDasharray: `${circumference * 0.75} ${circumference * 0.25}`,
|
|
235
|
-
opacity: 0.8
|
|
236
|
-
}
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// src/atoms/lib/buttonClasses.ts
|
|
243
|
-
var variantClasses = {
|
|
244
|
-
default: "bg-primary-button-bg text-primary-button-text shadow hover:bg-primary-button-hover",
|
|
245
|
-
secondary: "border border-input-border bg-secondary-button-bg text-secondary-button-text shadow-sm hover:bg-secondary-button-hover",
|
|
246
|
-
ghost: "bg-ghost-button-bg text-ghost-button-text hover:bg-ghost-button-hover",
|
|
247
|
-
destructive: "bg-failure-bg text-failure-text shadow-sm hover:bg-failure-bg/90",
|
|
248
|
-
outline: "border border-input-border bg-secondary-button-bg text-secondary-button-text shadow-sm hover:bg-secondary-button-hover"
|
|
249
|
-
};
|
|
250
|
-
var sizeClasses = {
|
|
251
|
-
default: "h-9 px-4 py-2 text-sm",
|
|
252
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
253
|
-
lg: "h-10 rounded-md px-8 text-base",
|
|
254
|
-
icon: "h-8 w-8"
|
|
255
|
-
};
|
|
256
|
-
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";
|
|
257
|
-
function auiButtonClass({
|
|
258
|
-
variant = "default",
|
|
259
|
-
size = "default",
|
|
260
|
-
className
|
|
261
|
-
} = {}) {
|
|
262
|
-
return cn(baseClasses, variantClasses[variant], sizeClasses[size], className);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// src/server/ServerContext.tsx
|
|
266
|
-
import { createContext, useCallback, useContext as useContext2, useEffect, useMemo, useRef, useState } from "react";
|
|
267
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
268
|
-
var ServerContext = createContext(null);
|
|
269
|
-
var ServerCapabilitiesContext = createContext(null);
|
|
270
|
-
function ServerProvider({ server, children }) {
|
|
271
|
-
const [capabilities, setCapabilities] = useState(null);
|
|
272
|
-
const cancelActiveRequestRef = useRef(null);
|
|
273
|
-
const refreshCapabilities = useCallback(() => {
|
|
274
|
-
cancelActiveRequestRef.current?.();
|
|
275
|
-
let cancelled = false;
|
|
276
|
-
cancelActiveRequestRef.current = () => {
|
|
277
|
-
cancelled = true;
|
|
278
|
-
};
|
|
279
|
-
void server.getCapabilities().then((response) => {
|
|
280
|
-
if (!cancelled) setCapabilities(response.data);
|
|
281
|
-
}).catch(() => {
|
|
282
|
-
});
|
|
283
|
-
}, [server]);
|
|
284
|
-
useEffect(() => {
|
|
285
|
-
setCapabilities(null);
|
|
286
|
-
refreshCapabilities();
|
|
287
|
-
return () => {
|
|
288
|
-
cancelActiveRequestRef.current?.();
|
|
289
|
-
};
|
|
290
|
-
}, [refreshCapabilities]);
|
|
291
|
-
const capabilitiesValue = useMemo(
|
|
292
|
-
() => ({ capabilities, refresh: refreshCapabilities }),
|
|
293
|
-
[capabilities, refreshCapabilities]
|
|
294
|
-
);
|
|
295
|
-
return /* @__PURE__ */ jsx4(ServerContext.Provider, { value: server, children: /* @__PURE__ */ jsx4(ServerCapabilitiesContext.Provider, { value: capabilitiesValue, children }) });
|
|
296
|
-
}
|
|
297
|
-
function useServer() {
|
|
298
|
-
const server = useContext2(ServerContext);
|
|
299
|
-
if (server == null) {
|
|
300
|
-
throw new Error("useServer must be used within a ServerProvider.");
|
|
301
|
-
}
|
|
302
|
-
return server;
|
|
303
|
-
}
|
|
304
|
-
function useOptionalServer() {
|
|
305
|
-
return useContext2(ServerContext);
|
|
306
|
-
}
|
|
307
|
-
function useServerCapabilities() {
|
|
308
|
-
return useContext2(ServerCapabilitiesContext)?.capabilities ?? null;
|
|
309
|
-
}
|
|
310
|
-
function useOptionalRefreshServerCapabilities() {
|
|
311
|
-
return useContext2(ServerCapabilitiesContext)?.refresh ?? null;
|
|
312
|
-
}
|
|
313
|
-
function useCatalogServer() {
|
|
314
|
-
const server = useServer();
|
|
315
|
-
if (server.catalog == null) {
|
|
316
|
-
throw new Error("useCatalogServer requires AgentUIServer.catalog. Pass catalog to createTrueFoundryServer.");
|
|
317
|
-
}
|
|
318
|
-
return server.catalog;
|
|
319
|
-
}
|
|
320
|
-
function useOptionalCatalogServer() {
|
|
321
|
-
return useOptionalServer()?.catalog ?? null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// src/server/ShellModeContext.tsx
|
|
325
|
-
import { createContext as createContext2, useCallback as useCallback2, useContext as useContext3, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
326
|
-
|
|
327
|
-
// src/server/draftSpecPreferences.ts
|
|
328
|
-
var DRAFT_SPEC_PREFERENCES_STORAGE_KEY = "tfy-aui-draft-spec-preferences";
|
|
329
|
-
function isObject(value) {
|
|
330
|
-
return typeof value === "object" && value !== null;
|
|
331
|
-
}
|
|
332
|
-
function isMountList(value) {
|
|
333
|
-
return Array.isArray(value) && value.every(isObject);
|
|
334
|
-
}
|
|
335
|
-
function isAgentSpec(value) {
|
|
336
|
-
if (!isObject(value)) return false;
|
|
337
|
-
const model = Reflect.get(value, "model");
|
|
338
|
-
if (!isObject(model) || typeof Reflect.get(model, "name") !== "string") return false;
|
|
339
|
-
const params = Reflect.get(model, "params");
|
|
340
|
-
if (params !== void 0 && !isObject(params)) return false;
|
|
341
|
-
const skills = Reflect.get(value, "skills");
|
|
342
|
-
if (skills !== void 0 && !isMountList(skills)) return false;
|
|
343
|
-
const mcpServers = Reflect.get(value, "mcpServers");
|
|
344
|
-
if (mcpServers !== void 0 && !isMountList(mcpServers)) return false;
|
|
345
|
-
const config = Reflect.get(value, "config");
|
|
346
|
-
return config === void 0 || isObject(config);
|
|
347
|
-
}
|
|
348
|
-
function isStoredDraftSpecPreferences(value) {
|
|
349
|
-
return isObject(value) && Reflect.get(value, "version") === 1 && isAgentSpec(Reflect.get(value, "spec"));
|
|
350
|
-
}
|
|
351
|
-
function selectDraftSpecPreferences(spec) {
|
|
352
|
-
return {
|
|
353
|
-
model: spec.model,
|
|
354
|
-
...spec.skills !== void 0 ? { skills: spec.skills } : {},
|
|
355
|
-
...spec.mcpServers !== void 0 ? { mcpServers: spec.mcpServers } : {},
|
|
356
|
-
...spec.config !== void 0 ? { config: spec.config } : {}
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
function readDraftSpecPreferences() {
|
|
360
|
-
if (typeof window === "undefined") return null;
|
|
361
|
-
try {
|
|
362
|
-
const stored = JSON.parse(window.localStorage.getItem(DRAFT_SPEC_PREFERENCES_STORAGE_KEY) ?? "null");
|
|
363
|
-
return isStoredDraftSpecPreferences(stored) ? stored.spec : null;
|
|
364
|
-
} catch {
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
function writeDraftSpecPreferences(spec) {
|
|
369
|
-
if (typeof window === "undefined") return;
|
|
370
|
-
try {
|
|
371
|
-
const stored = {
|
|
372
|
-
version: 1,
|
|
373
|
-
spec: selectDraftSpecPreferences(spec)
|
|
374
|
-
};
|
|
375
|
-
window.localStorage.setItem(DRAFT_SPEC_PREFERENCES_STORAGE_KEY, JSON.stringify(stored));
|
|
376
|
-
} catch {
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// src/server/ShellModeContext.tsx
|
|
381
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
382
|
-
var DEFAULT_AGENT_CONFIG = {
|
|
383
|
-
mode: "AgentLibraryWithComposer"
|
|
384
|
-
};
|
|
385
|
-
var ShellModeContext = createContext2(null);
|
|
386
|
-
var FALLBACK_MUTABLE_SPEC = {
|
|
387
|
-
model: { name: "openai-main/gpt-4.1" }
|
|
388
|
-
};
|
|
389
|
-
function mutableSeedFromConfig(config) {
|
|
390
|
-
if (config.mode === "AgentComposer" || config.mode === "AgentLibraryWithComposer") {
|
|
391
|
-
return config.defaultAgentSpec ?? FALLBACK_MUTABLE_SPEC;
|
|
392
|
-
}
|
|
393
|
-
return FALLBACK_MUTABLE_SPEC;
|
|
394
|
-
}
|
|
395
|
-
function initialMode(config, mutableSeed) {
|
|
396
|
-
switch (config.mode) {
|
|
397
|
-
case "SingleAgent":
|
|
398
|
-
return {
|
|
399
|
-
status: "active",
|
|
400
|
-
isMutable: false,
|
|
401
|
-
agentId: config.name,
|
|
402
|
-
agentName: config.name,
|
|
403
|
-
locked: true
|
|
404
|
-
};
|
|
405
|
-
case "AgentLibrary":
|
|
406
|
-
return { status: "idle" };
|
|
407
|
-
case "AgentComposer":
|
|
408
|
-
case "AgentLibraryWithComposer":
|
|
409
|
-
return {
|
|
410
|
-
status: "active",
|
|
411
|
-
isMutable: true,
|
|
412
|
-
agentSpec: mutableSeed,
|
|
413
|
-
locked: false
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
function libraryAgentId(agent) {
|
|
418
|
-
return agent.agentId ?? agent.name;
|
|
419
|
-
}
|
|
420
|
-
function ShellModeProvider({
|
|
421
|
-
agentConfig = DEFAULT_AGENT_CONFIG,
|
|
422
|
-
initialSettingsOpen = false,
|
|
423
|
-
children
|
|
424
|
-
}) {
|
|
425
|
-
const capabilities = useServerCapabilities();
|
|
426
|
-
const refreshCapabilities = useOptionalRefreshServerCapabilities();
|
|
427
|
-
const rememberedSpecRef = useRef2(readDraftSpecPreferences());
|
|
428
|
-
const mutableSeedRef = useRef2(rememberedSpecRef.current ?? mutableSeedFromConfig(agentConfig));
|
|
429
|
-
if (rememberedSpecRef.current == null && (agentConfig.mode === "AgentComposer" || agentConfig.mode === "AgentLibraryWithComposer") && agentConfig.defaultAgentSpec != null) {
|
|
430
|
-
mutableSeedRef.current = agentConfig.defaultAgentSpec;
|
|
431
|
-
}
|
|
432
|
-
const mutableSeed = mutableSeedRef.current;
|
|
433
|
-
const isLibraryEnabled = agentConfig.mode === "AgentLibrary" || agentConfig.mode === "AgentLibraryWithComposer";
|
|
434
|
-
const isComposerEnabled = agentConfig.mode === "AgentComposer" || agentConfig.mode === "AgentLibraryWithComposer";
|
|
435
|
-
const isNewChatEnabled = agentConfig.mode !== "AgentLibrary";
|
|
436
|
-
const locked = agentConfig.mode === "SingleAgent";
|
|
437
|
-
const [mode, setMode] = useState2(() => initialMode(agentConfig, mutableSeed));
|
|
438
|
-
const [mutableEpoch, setMutableEpoch] = useState2(0);
|
|
439
|
-
const [clearEpoch, setClearEpoch] = useState2(0);
|
|
440
|
-
const [agentsListEpoch, setAgentsListEpoch] = useState2(0);
|
|
441
|
-
const [settingsOpenState, setSettingsOpenState] = useState2(initialSettingsOpen);
|
|
442
|
-
const [settingsSection, setSettingsSection] = useState2("models");
|
|
443
|
-
const [historyAgentFilter, setHistoryAgentFilter] = useState2(null);
|
|
444
|
-
const [pendingSessionId, setPendingSessionId] = useState2(void 0);
|
|
445
|
-
const settingsEnabled = capabilities?.settings?.enabled !== false;
|
|
446
|
-
const settingsOpen = settingsEnabled && settingsOpenState;
|
|
447
|
-
const setSettingsOpen = useCallback2(
|
|
448
|
-
(open, section) => {
|
|
449
|
-
if (section !== void 0) {
|
|
450
|
-
setSettingsSection(section);
|
|
451
|
-
}
|
|
452
|
-
setSettingsOpenState(settingsEnabled && open);
|
|
453
|
-
},
|
|
454
|
-
[settingsEnabled]
|
|
455
|
-
);
|
|
456
|
-
useEffect2(() => {
|
|
457
|
-
if (!settingsEnabled) {
|
|
458
|
-
setSettingsOpenState(false);
|
|
459
|
-
}
|
|
460
|
-
}, [settingsEnabled]);
|
|
461
|
-
const invalidateAgentsList = useCallback2(() => {
|
|
462
|
-
setAgentsListEpoch((n) => n + 1);
|
|
463
|
-
}, []);
|
|
464
|
-
const lockedAgentName = agentConfig.mode === "SingleAgent" ? agentConfig.name : "";
|
|
465
|
-
const effectiveMode = useMemo2(() => {
|
|
466
|
-
if (!locked) return mode;
|
|
467
|
-
return {
|
|
468
|
-
status: "active",
|
|
469
|
-
isMutable: false,
|
|
470
|
-
agentId: lockedAgentName,
|
|
471
|
-
agentName: lockedAgentName,
|
|
472
|
-
locked: true
|
|
473
|
-
};
|
|
474
|
-
}, [locked, lockedAgentName, mode]);
|
|
475
|
-
const listSessionsAgentId = useMemo2(() => {
|
|
476
|
-
if (locked) return lockedAgentName;
|
|
477
|
-
if (!isLibraryEnabled) return void 0;
|
|
478
|
-
return historyAgentFilter ?? void 0;
|
|
479
|
-
}, [locked, lockedAgentName, isLibraryEnabled, historyAgentFilter]);
|
|
480
|
-
const bumpEpoch = useCallback2((isMutable) => {
|
|
481
|
-
if (isMutable) setMutableEpoch((n) => n + 1);
|
|
482
|
-
else setClearEpoch((n) => n + 1);
|
|
483
|
-
}, []);
|
|
484
|
-
const selectLibraryAgent = useCallback2(
|
|
485
|
-
(req) => {
|
|
486
|
-
if (req.isMutable) {
|
|
487
|
-
if (!isComposerEnabled) return;
|
|
488
|
-
setSettingsOpen(false);
|
|
489
|
-
setPendingSessionId(void 0);
|
|
490
|
-
setMode({
|
|
491
|
-
status: "active",
|
|
492
|
-
isMutable: true,
|
|
493
|
-
agentId: req.agentId,
|
|
494
|
-
agentName: req.agentName,
|
|
495
|
-
agentSpec: req.agentSpec ?? mutableSeedRef.current,
|
|
496
|
-
locked: false
|
|
497
|
-
});
|
|
498
|
-
bumpEpoch(true);
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
if (!isLibraryEnabled) return;
|
|
502
|
-
const agentName = req.agentName ?? req.agentId;
|
|
503
|
-
if (agentName == null) return;
|
|
504
|
-
setSettingsOpen(false);
|
|
505
|
-
setPendingSessionId(void 0);
|
|
506
|
-
setMode({
|
|
507
|
-
status: "active",
|
|
508
|
-
isMutable: false,
|
|
509
|
-
agentId: req.agentId ?? agentName,
|
|
510
|
-
agentName,
|
|
511
|
-
locked: false
|
|
512
|
-
});
|
|
513
|
-
bumpEpoch(false);
|
|
514
|
-
},
|
|
515
|
-
[isComposerEnabled, isLibraryEnabled, bumpEpoch, setSettingsOpen]
|
|
516
|
-
);
|
|
517
|
-
const bindMutableAgent = useCallback2(
|
|
518
|
-
(req) => {
|
|
519
|
-
if (!isComposerEnabled) return;
|
|
520
|
-
setMode((prev) => {
|
|
521
|
-
if (prev.status !== "active" || !prev.isMutable) return prev;
|
|
522
|
-
return {
|
|
523
|
-
status: "active",
|
|
524
|
-
isMutable: true,
|
|
525
|
-
agentId: req.agentId,
|
|
526
|
-
agentName: req.agentName,
|
|
527
|
-
agentSpec: req.agentSpec,
|
|
528
|
-
locked: false
|
|
529
|
-
};
|
|
530
|
-
});
|
|
531
|
-
},
|
|
532
|
-
[isComposerEnabled]
|
|
533
|
-
);
|
|
534
|
-
const selectAgent = useCallback2(
|
|
535
|
-
(name) => {
|
|
536
|
-
selectLibraryAgent({ isMutable: false, agentId: name, agentName: name });
|
|
537
|
-
},
|
|
538
|
-
[selectLibraryAgent]
|
|
539
|
-
);
|
|
540
|
-
const openDraft = useCallback2(() => {
|
|
541
|
-
if (!isComposerEnabled) return;
|
|
542
|
-
refreshCapabilities?.();
|
|
543
|
-
selectLibraryAgent({ isMutable: true, agentSpec: mutableSeedRef.current });
|
|
544
|
-
}, [isComposerEnabled, refreshCapabilities, selectLibraryAgent]);
|
|
545
|
-
const rememberDraftSpec = useCallback2((agentSpec) => {
|
|
546
|
-
const preferences = selectDraftSpecPreferences(agentSpec);
|
|
547
|
-
rememberedSpecRef.current = preferences;
|
|
548
|
-
mutableSeedRef.current = preferences;
|
|
549
|
-
writeDraftSpecPreferences(preferences);
|
|
550
|
-
}, []);
|
|
551
|
-
const openHistorySession = useCallback2(
|
|
552
|
-
({
|
|
553
|
-
sessionId,
|
|
554
|
-
agentName,
|
|
555
|
-
isMutable: isMutableOpt
|
|
556
|
-
}) => {
|
|
557
|
-
setSettingsOpen(false);
|
|
558
|
-
setPendingSessionId(sessionId);
|
|
559
|
-
const isMutable = isMutableOpt ?? agentName == null;
|
|
560
|
-
if (isMutable) {
|
|
561
|
-
if (!isComposerEnabled) return;
|
|
562
|
-
setMode({
|
|
563
|
-
status: "active",
|
|
564
|
-
isMutable: true,
|
|
565
|
-
agentSpec: mutableSeedRef.current,
|
|
566
|
-
locked: false
|
|
567
|
-
});
|
|
568
|
-
bumpEpoch(true);
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
if (locked) {
|
|
572
|
-
if (agentName == null || lockedAgentName !== agentName) return;
|
|
573
|
-
} else if (!isLibraryEnabled) {
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
setMode({
|
|
577
|
-
status: "active",
|
|
578
|
-
isMutable: false,
|
|
579
|
-
locked: false,
|
|
580
|
-
...agentName != null ? { agentId: agentName, agentName } : {}
|
|
581
|
-
});
|
|
582
|
-
bumpEpoch(false);
|
|
583
|
-
},
|
|
584
|
-
[isLibraryEnabled, isComposerEnabled, locked, lockedAgentName, bumpEpoch, setSettingsOpen]
|
|
585
|
-
);
|
|
586
|
-
const clearChat = useCallback2(() => {
|
|
587
|
-
if (effectiveMode.status === "idle") return;
|
|
588
|
-
setPendingSessionId(void 0);
|
|
589
|
-
if (effectiveMode.isMutable) {
|
|
590
|
-
setMode({
|
|
591
|
-
status: "active",
|
|
592
|
-
isMutable: true,
|
|
593
|
-
agentId: effectiveMode.agentId,
|
|
594
|
-
agentName: effectiveMode.agentName,
|
|
595
|
-
agentSpec: effectiveMode.agentSpec ?? mutableSeedRef.current,
|
|
596
|
-
locked: false
|
|
597
|
-
});
|
|
598
|
-
bumpEpoch(true);
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
bumpEpoch(false);
|
|
602
|
-
}, [effectiveMode, bumpEpoch]);
|
|
603
|
-
const runtimeKey = useMemo2(() => {
|
|
604
|
-
if (effectiveMode.status === "idle") return "idle";
|
|
605
|
-
if (effectiveMode.isMutable) {
|
|
606
|
-
return `mut:${pendingSessionId ?? ""}:${mutableEpoch}`;
|
|
607
|
-
}
|
|
608
|
-
const id = effectiveMode.agentId ?? effectiveMode.agentName ?? "";
|
|
609
|
-
return `immut:${id}:${pendingSessionId ?? ""}:${clearEpoch}`;
|
|
610
|
-
}, [effectiveMode, mutableEpoch, clearEpoch, pendingSessionId]);
|
|
611
|
-
const value = useMemo2(
|
|
612
|
-
() => ({
|
|
613
|
-
mode: effectiveMode,
|
|
614
|
-
agentConfigMode: agentConfig.mode,
|
|
615
|
-
isLibraryEnabled,
|
|
616
|
-
isComposerEnabled,
|
|
617
|
-
isNewChatEnabled,
|
|
618
|
-
settingsOpen,
|
|
619
|
-
settingsSection,
|
|
620
|
-
setSettingsOpen,
|
|
621
|
-
selectLibraryAgent,
|
|
622
|
-
bindMutableAgent,
|
|
623
|
-
selectAgent,
|
|
624
|
-
openDraft,
|
|
625
|
-
rememberDraftSpec,
|
|
626
|
-
openHistorySession,
|
|
627
|
-
clearChat,
|
|
628
|
-
runtimeKey,
|
|
629
|
-
historyAgentFilter,
|
|
630
|
-
setHistoryAgentFilter,
|
|
631
|
-
listSessionsAgentId,
|
|
632
|
-
pendingSessionId,
|
|
633
|
-
agentsListEpoch,
|
|
634
|
-
invalidateAgentsList
|
|
635
|
-
}),
|
|
636
|
-
[
|
|
637
|
-
effectiveMode,
|
|
638
|
-
agentConfig.mode,
|
|
639
|
-
isLibraryEnabled,
|
|
640
|
-
isComposerEnabled,
|
|
641
|
-
isNewChatEnabled,
|
|
642
|
-
settingsOpen,
|
|
643
|
-
settingsSection,
|
|
644
|
-
setSettingsOpen,
|
|
645
|
-
selectLibraryAgent,
|
|
646
|
-
bindMutableAgent,
|
|
647
|
-
selectAgent,
|
|
648
|
-
openDraft,
|
|
649
|
-
rememberDraftSpec,
|
|
650
|
-
openHistorySession,
|
|
651
|
-
clearChat,
|
|
652
|
-
runtimeKey,
|
|
653
|
-
historyAgentFilter,
|
|
654
|
-
listSessionsAgentId,
|
|
655
|
-
pendingSessionId,
|
|
656
|
-
agentsListEpoch,
|
|
657
|
-
invalidateAgentsList
|
|
658
|
-
]
|
|
659
|
-
);
|
|
660
|
-
return /* @__PURE__ */ jsx5(ShellModeContext.Provider, { value, children });
|
|
661
|
-
}
|
|
662
|
-
function useShellMode() {
|
|
663
|
-
const ctx = useContext3(ShellModeContext);
|
|
664
|
-
if (ctx == null) {
|
|
665
|
-
throw new Error("useShellMode must be used within a ShellModeProvider.");
|
|
666
|
-
}
|
|
667
|
-
return ctx;
|
|
668
|
-
}
|
|
669
|
-
function useOptionalShellMode() {
|
|
670
|
-
return useContext3(ShellModeContext);
|
|
671
|
-
}
|
|
672
|
-
function shellIsMutable(mode) {
|
|
673
|
-
return mode.status === "active" && mode.isMutable;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// src/utils/getErrorMessage.ts
|
|
677
|
-
function isRecord(value) {
|
|
678
|
-
return value != null && typeof value === "object";
|
|
679
|
-
}
|
|
680
|
-
function readNonEmptyString(value) {
|
|
681
|
-
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
682
|
-
}
|
|
683
|
-
function messageFromErrorShaped(value) {
|
|
684
|
-
if (!isRecord(value)) return void 0;
|
|
685
|
-
const direct = readNonEmptyString(value.message);
|
|
686
|
-
if (direct != null) return direct;
|
|
687
|
-
if (isRecord(value.error)) {
|
|
688
|
-
return readNonEmptyString(value.error.message);
|
|
689
|
-
}
|
|
690
|
-
return void 0;
|
|
691
|
-
}
|
|
692
|
-
function stringifyError(error) {
|
|
693
|
-
if (typeof error === "string") return error;
|
|
694
|
-
if (isRecord(error)) {
|
|
695
|
-
try {
|
|
696
|
-
return JSON.stringify(error);
|
|
697
|
-
} catch {
|
|
698
|
-
return Object.prototype.toString.call(error);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
return String(error);
|
|
702
|
-
}
|
|
703
|
-
function getErrorMessage(error, fallback) {
|
|
704
|
-
if (typeof error === "string") {
|
|
705
|
-
const trimmed = error.trim();
|
|
706
|
-
if (trimmed !== "") return error;
|
|
707
|
-
return fallback ?? error;
|
|
708
|
-
}
|
|
709
|
-
if (isRecord(error) && "body" in error) {
|
|
710
|
-
const fromBody = messageFromErrorShaped(error.body);
|
|
711
|
-
if (fromBody != null) return fromBody;
|
|
712
|
-
if (error.body != null) {
|
|
713
|
-
if (typeof error.body === "string") {
|
|
714
|
-
const trimmed = error.body.trim();
|
|
715
|
-
if (trimmed !== "") return error.body;
|
|
716
|
-
} else {
|
|
717
|
-
return stringifyError(error.body);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
const fromShape = messageFromErrorShaped(error);
|
|
722
|
-
if (fromShape != null) return fromShape;
|
|
723
|
-
if (fallback != null) return fallback;
|
|
724
|
-
return stringifyError(error);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// src/atoms/lib/CompactLayoutContext.tsx
|
|
728
|
-
import { createContext as createContext3, useContext as useContext4 } from "react";
|
|
729
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
730
|
-
var CompactLayoutContext = createContext3(false);
|
|
731
|
-
function CompactLayoutProvider({ children }) {
|
|
732
|
-
return /* @__PURE__ */ jsx6(CompactLayoutContext.Provider, { value: true, children });
|
|
733
|
-
}
|
|
734
|
-
function useCompactLayout() {
|
|
735
|
-
return useContext4(CompactLayoutContext);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// src/atoms/draft/DraftCatalogProvider.tsx
|
|
739
|
-
import { createContext as createContext4, useCallback as useCallback3, useContext as useContext5, useEffect as useEffect3, useMemo as useMemo3, useState as useState3 } from "react";
|
|
740
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
741
|
-
var DraftCatalogContext = createContext4(null);
|
|
742
|
-
var IDLE_ENSURE = () => void 0;
|
|
743
|
-
var IDLE_REFRESH = async () => void 0;
|
|
744
|
-
function DraftCatalogProvider({ children }) {
|
|
745
|
-
const server = useOptionalServer();
|
|
746
|
-
const existing = useContext5(DraftCatalogContext);
|
|
747
|
-
if (existing?.server === server) {
|
|
748
|
-
return children;
|
|
749
|
-
}
|
|
750
|
-
return /* @__PURE__ */ jsx7(DraftCatalogStore, { server, children });
|
|
751
|
-
}
|
|
752
|
-
function DraftCatalogStore({ server, children }) {
|
|
753
|
-
const [requestEpoch, setRequestEpoch] = useState3(null);
|
|
754
|
-
const [models, setModels] = useState3([]);
|
|
755
|
-
const [skills, setSkills] = useState3([]);
|
|
756
|
-
const [connectors, setConnectors] = useState3([]);
|
|
757
|
-
const [completedEpoch, setCompletedEpoch] = useState3(null);
|
|
758
|
-
const [loading, setLoading] = useState3(false);
|
|
759
|
-
const [error, setError] = useState3(null);
|
|
760
|
-
const ensureLoaded = useCallback3(() => {
|
|
761
|
-
setRequestEpoch((current) => current ?? 0);
|
|
762
|
-
}, []);
|
|
763
|
-
const refresh = useCallback3(() => {
|
|
764
|
-
setRequestEpoch((current) => (current ?? -1) + 1);
|
|
765
|
-
}, []);
|
|
766
|
-
const refreshConnectors = useCallback3(async () => {
|
|
767
|
-
if (!server) return;
|
|
768
|
-
setLoading(true);
|
|
769
|
-
setError(null);
|
|
770
|
-
try {
|
|
771
|
-
const nextConnectors = await server.getMcp();
|
|
772
|
-
setConnectors(nextConnectors);
|
|
773
|
-
} catch (reason) {
|
|
774
|
-
setError(getErrorMessage(reason, "Failed to load connectors."));
|
|
775
|
-
} finally {
|
|
776
|
-
setLoading(false);
|
|
777
|
-
}
|
|
778
|
-
}, [server]);
|
|
779
|
-
useEffect3(() => {
|
|
780
|
-
if (requestEpoch === null || !server) return;
|
|
781
|
-
let cancelled = false;
|
|
782
|
-
setLoading(true);
|
|
783
|
-
setError(null);
|
|
784
|
-
void Promise.allSettled([server.getModels(), server.getSkills(), server.getMcp()]).then(([modelsResult, skillsResult, mcpResult]) => {
|
|
785
|
-
if (cancelled) return;
|
|
786
|
-
const errors = [];
|
|
787
|
-
if (modelsResult.status === "fulfilled") {
|
|
788
|
-
setModels(modelsResult.value);
|
|
789
|
-
} else {
|
|
790
|
-
errors.push(getErrorMessage(modelsResult.reason, "Failed to load models."));
|
|
791
|
-
}
|
|
792
|
-
if (skillsResult.status === "fulfilled") {
|
|
793
|
-
setSkills(skillsResult.value);
|
|
794
|
-
} else {
|
|
795
|
-
errors.push(getErrorMessage(skillsResult.reason, "Failed to load skills."));
|
|
796
|
-
}
|
|
797
|
-
if (mcpResult.status === "fulfilled") {
|
|
798
|
-
setConnectors(mcpResult.value);
|
|
799
|
-
} else {
|
|
800
|
-
errors.push(getErrorMessage(mcpResult.reason, "Failed to load connectors."));
|
|
801
|
-
}
|
|
802
|
-
setError(errors[0] ?? null);
|
|
803
|
-
}).finally(() => {
|
|
804
|
-
if (!cancelled) {
|
|
805
|
-
setCompletedEpoch(requestEpoch);
|
|
806
|
-
setLoading(false);
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
return () => {
|
|
810
|
-
cancelled = true;
|
|
811
|
-
};
|
|
812
|
-
}, [requestEpoch, server]);
|
|
813
|
-
const loaded = requestEpoch !== null && completedEpoch === requestEpoch;
|
|
814
|
-
const value = useMemo3(
|
|
815
|
-
() => ({ server, models, skills, connectors, loaded, loading, error, ensureLoaded, refresh, refreshConnectors }),
|
|
816
|
-
[server, models, skills, connectors, loaded, loading, error, ensureLoaded, refresh, refreshConnectors]
|
|
817
|
-
);
|
|
818
|
-
return /* @__PURE__ */ jsx7(DraftCatalogContext.Provider, { value, children });
|
|
819
|
-
}
|
|
820
|
-
function useDraftCatalog() {
|
|
821
|
-
const ctx = useContext5(DraftCatalogContext);
|
|
822
|
-
if (ctx == null) {
|
|
823
|
-
return {
|
|
824
|
-
models: [],
|
|
825
|
-
skills: [],
|
|
826
|
-
connectors: [],
|
|
827
|
-
loaded: false,
|
|
828
|
-
loading: false,
|
|
829
|
-
error: null,
|
|
830
|
-
ensureLoaded: IDLE_ENSURE,
|
|
831
|
-
refresh: IDLE_ENSURE,
|
|
832
|
-
refreshConnectors: IDLE_REFRESH
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
return ctx;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
export {
|
|
839
|
-
registerIcons,
|
|
840
|
-
Icon,
|
|
841
|
-
Spinner,
|
|
842
|
-
auiButtonClass,
|
|
843
|
-
ServerProvider,
|
|
844
|
-
useServer,
|
|
845
|
-
useOptionalServer,
|
|
846
|
-
useServerCapabilities,
|
|
847
|
-
useOptionalRefreshServerCapabilities,
|
|
848
|
-
useCatalogServer,
|
|
849
|
-
useOptionalCatalogServer,
|
|
850
|
-
DEFAULT_AGENT_CONFIG,
|
|
851
|
-
libraryAgentId,
|
|
852
|
-
ShellModeProvider,
|
|
853
|
-
useShellMode,
|
|
854
|
-
useOptionalShellMode,
|
|
855
|
-
shellIsMutable,
|
|
856
|
-
getErrorMessage,
|
|
857
|
-
CompactLayoutProvider,
|
|
858
|
-
useCompactLayout,
|
|
859
|
-
DraftCatalogProvider,
|
|
860
|
-
useDraftCatalog
|
|
861
|
-
};
|
|
862
|
-
//# sourceMappingURL=chunk-XAZ5HJXV.js.map
|