@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/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
AssistantTextContainer,
|
|
7
7
|
ComposerAttachmentPickerContainer,
|
|
8
8
|
ComposerAttachmentsContainer,
|
|
9
|
-
ComposerBusyProvider,
|
|
10
9
|
ComposerContainer,
|
|
11
10
|
HistoryLoaderContainer,
|
|
12
11
|
McpAuthContainer,
|
|
@@ -22,11 +21,18 @@ import {
|
|
|
22
21
|
UserEditComposerContainer,
|
|
23
22
|
UserMessageContainer,
|
|
24
23
|
computeAgentStepsSplit,
|
|
25
|
-
notifyComposerBusyFailure,
|
|
26
24
|
threadHasPendingMcpAuth,
|
|
27
|
-
useComposerBusyState,
|
|
28
25
|
useComposerPauseView
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-UACLSDNL.js";
|
|
27
|
+
import {
|
|
28
|
+
ServerInitLoader,
|
|
29
|
+
TrueForgeUIShell,
|
|
30
|
+
TrueFoundryChatProvider
|
|
31
|
+
} from "./chunk-EKVN6QSO.js";
|
|
32
|
+
import {
|
|
33
|
+
ComposerBusyProvider,
|
|
34
|
+
useComposerBusyState
|
|
35
|
+
} from "./chunk-FXCYLEFB.js";
|
|
30
36
|
import {
|
|
31
37
|
useAui,
|
|
32
38
|
useAuiState
|
|
@@ -101,7 +107,6 @@ import {
|
|
|
101
107
|
UserMessageEdit,
|
|
102
108
|
WelcomeScreen,
|
|
103
109
|
defaultSlots,
|
|
104
|
-
modelPatchWithReasoningEffort,
|
|
105
110
|
preloadMarkdownOpenUI,
|
|
106
111
|
useBrandName,
|
|
107
112
|
useMCPAuth,
|
|
@@ -109,41 +114,41 @@ import {
|
|
|
109
114
|
useThemeMode,
|
|
110
115
|
useToaster,
|
|
111
116
|
useToasterOptional
|
|
112
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-UU7C5DQ3.js";
|
|
113
118
|
import {
|
|
114
|
-
DEFAULT_AGENT_CONFIG,
|
|
115
119
|
DraftCatalogProvider,
|
|
116
120
|
Icon,
|
|
121
|
+
getErrorMessage,
|
|
122
|
+
registerIcons,
|
|
123
|
+
useDraftCatalog
|
|
124
|
+
} from "./chunk-IFLE7OMM.js";
|
|
125
|
+
import {
|
|
126
|
+
DEFAULT_AGENT_CONFIG,
|
|
117
127
|
ServerProvider,
|
|
118
128
|
ShellModeProvider,
|
|
119
|
-
Spinner,
|
|
120
|
-
getErrorMessage,
|
|
121
129
|
libraryAgentId,
|
|
122
|
-
registerIcons,
|
|
123
130
|
shellIsMutable,
|
|
124
131
|
useCatalogServer,
|
|
125
|
-
useDraftCatalog,
|
|
126
132
|
useOptionalCatalogServer,
|
|
127
133
|
useOptionalServer,
|
|
128
134
|
useOptionalShellMode,
|
|
129
135
|
useServer,
|
|
130
136
|
useServerCapabilities,
|
|
131
137
|
useShellMode
|
|
132
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-WQULF5AT.js";
|
|
133
139
|
import {
|
|
134
140
|
OpenUiFenceBlock
|
|
135
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-JRRCAKEP.js";
|
|
136
142
|
import {
|
|
137
143
|
PRESETS,
|
|
138
144
|
ThemeProvider,
|
|
139
|
-
cn,
|
|
140
145
|
resolvePresetTokens,
|
|
141
146
|
useBrand,
|
|
142
147
|
useContentClassNames,
|
|
143
148
|
useOptionalContentClassNames,
|
|
144
149
|
useTheme,
|
|
145
150
|
useThemeIcons
|
|
146
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-72LC2M3R.js";
|
|
147
152
|
|
|
148
153
|
// src/icons/agent-2.svg
|
|
149
154
|
import * as React from "react";
|
|
@@ -304,422 +309,30 @@ function ToolGroupContainer({ children, group }) {
|
|
|
304
309
|
);
|
|
305
310
|
}
|
|
306
311
|
|
|
307
|
-
// src/containers/
|
|
308
|
-
import { lazy, Suspense
|
|
309
|
-
|
|
310
|
-
// src/atoms/draft/DraftSpecPreferenceBridge.tsx
|
|
311
|
-
import { useTrueFoundryAgentSpec, useTrueFoundryUpdateAgentSpec } from "@truefoundry/assistant-ui-runtime";
|
|
312
|
-
import { useEffect as useEffect2 } from "react";
|
|
313
|
-
function mountName(mount) {
|
|
314
|
-
const name = Reflect.get(mount, "name");
|
|
315
|
-
return typeof name === "string" ? name : null;
|
|
316
|
-
}
|
|
317
|
-
function filterMounts(mounts, availableNames) {
|
|
318
|
-
if (mounts === void 0) return void 0;
|
|
319
|
-
const filtered = mounts.filter((mount) => {
|
|
320
|
-
const name = mountName(mount);
|
|
321
|
-
return name !== null && availableNames.has(name);
|
|
322
|
-
});
|
|
323
|
-
return filtered.length === mounts.length ? mounts : filtered;
|
|
324
|
-
}
|
|
325
|
-
function reconcileDraftSpecPreferences({
|
|
326
|
-
agentSpec,
|
|
327
|
-
models,
|
|
328
|
-
skills,
|
|
329
|
-
connectors,
|
|
330
|
-
skillsEnabled
|
|
331
|
-
}) {
|
|
332
|
-
const update = {};
|
|
333
|
-
const selectedModel = agentSpec.model.name.trim();
|
|
334
|
-
if (!models.some((model) => model.name === selectedModel)) {
|
|
335
|
-
const fallback = models[0];
|
|
336
|
-
if (fallback !== void 0) {
|
|
337
|
-
update.model = modelPatchWithReasoningEffort(
|
|
338
|
-
fallback.name,
|
|
339
|
-
agentSpec.model.params,
|
|
340
|
-
fallback.properties.reasoningEfforts
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
const nextMcpServers = filterMounts(agentSpec.mcpServers, new Set(connectors.map((connector) => connector.name)));
|
|
345
|
-
if (nextMcpServers !== agentSpec.mcpServers) {
|
|
346
|
-
update.mcpServers = nextMcpServers;
|
|
347
|
-
}
|
|
348
|
-
if (skillsEnabled === false) {
|
|
349
|
-
if (agentSpec.skills !== void 0 && agentSpec.skills.length > 0) {
|
|
350
|
-
update.skills = [];
|
|
351
|
-
}
|
|
352
|
-
} else {
|
|
353
|
-
const nextSkills = filterMounts(agentSpec.skills, new Set(skills.map((skill) => skill.name)));
|
|
354
|
-
if (nextSkills !== agentSpec.skills) {
|
|
355
|
-
update.skills = nextSkills;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return update;
|
|
359
|
-
}
|
|
360
|
-
function DraftSpecPreferenceBridge() {
|
|
361
|
-
const { mode, pendingSessionId, rememberDraftSpec } = useShellMode();
|
|
362
|
-
const { agentSpec } = useTrueFoundryAgentSpec();
|
|
363
|
-
const updateAgentSpec = useTrueFoundryUpdateAgentSpec();
|
|
364
|
-
const capabilities = useServerCapabilities();
|
|
365
|
-
const { models, skills, connectors, loaded, error, ensureLoaded } = useDraftCatalog();
|
|
366
|
-
const isPlainDraft = mode.status === "active" && mode.isMutable && mode.agentId == null && pendingSessionId == null;
|
|
367
|
-
useEffect2(() => {
|
|
368
|
-
if (isPlainDraft) ensureLoaded();
|
|
369
|
-
}, [ensureLoaded, isPlainDraft]);
|
|
370
|
-
useEffect2(() => {
|
|
371
|
-
if (isPlainDraft && agentSpec != null) {
|
|
372
|
-
rememberDraftSpec(agentSpec);
|
|
373
|
-
}
|
|
374
|
-
}, [agentSpec, isPlainDraft, rememberDraftSpec]);
|
|
375
|
-
useEffect2(() => {
|
|
376
|
-
if (!isPlainDraft || agentSpec == null || updateAgentSpec == null || !loaded || error != null) return;
|
|
377
|
-
const update = reconcileDraftSpecPreferences({
|
|
378
|
-
agentSpec,
|
|
379
|
-
models,
|
|
380
|
-
skills,
|
|
381
|
-
connectors,
|
|
382
|
-
skillsEnabled: capabilities?.skill.enabled
|
|
383
|
-
});
|
|
384
|
-
if (Object.keys(update).length > 0) {
|
|
385
|
-
updateAgentSpec(update);
|
|
386
|
-
}
|
|
387
|
-
}, [
|
|
388
|
-
agentSpec,
|
|
389
|
-
capabilities?.skill.enabled,
|
|
390
|
-
connectors,
|
|
391
|
-
error,
|
|
392
|
-
isPlainDraft,
|
|
393
|
-
loaded,
|
|
394
|
-
models,
|
|
395
|
-
skills,
|
|
396
|
-
updateAgentSpec
|
|
397
|
-
]);
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// src/containers/TrueFoundryChatProvider.tsx
|
|
402
|
-
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
403
|
-
import {
|
|
404
|
-
trueFoundryAttachmentAdapter,
|
|
405
|
-
useTrueFoundryAgentRuntime
|
|
406
|
-
} from "@truefoundry/assistant-ui-runtime";
|
|
407
|
-
import { useCallback, useMemo } from "react";
|
|
312
|
+
// src/containers/TrueForgeUI.tsx
|
|
313
|
+
import { lazy, Suspense } from "react";
|
|
408
314
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
listSessionsAgentId,
|
|
414
|
-
initialSessionId,
|
|
415
|
-
adapters,
|
|
416
|
-
onError,
|
|
417
|
-
children
|
|
418
|
-
}) {
|
|
419
|
-
const { showError } = useToaster();
|
|
420
|
-
const reportError = onError ?? showError;
|
|
421
|
-
const resolvedOnError = useCallback(
|
|
422
|
-
(error) => {
|
|
423
|
-
notifyComposerBusyFailure();
|
|
424
|
-
reportError(error);
|
|
425
|
-
},
|
|
426
|
-
[reportError]
|
|
427
|
-
);
|
|
428
|
-
const runtime = useTrueFoundryAgentRuntime({
|
|
429
|
-
server,
|
|
430
|
-
agent,
|
|
431
|
-
agentName,
|
|
432
|
-
listSessionsAgentId,
|
|
433
|
-
initialSessionId,
|
|
434
|
-
onError: resolvedOnError,
|
|
435
|
-
adapters: {
|
|
436
|
-
...adapters,
|
|
437
|
-
attachments: adapters?.attachments ?? trueFoundryAttachmentAdapter
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
return /* @__PURE__ */ jsx11(AssistantRuntimeProvider, { runtime, children });
|
|
441
|
-
}
|
|
442
|
-
function TrueFoundryChatProvider(props) {
|
|
443
|
-
const { server, initialSessionId, adapters, onError, children, agent, agentName, listSessionsAgentId } = props;
|
|
444
|
-
const stableServer = useMemo(() => server, [server]);
|
|
445
|
-
return /* @__PURE__ */ jsx11(ToasterProvider, { children: /* @__PURE__ */ jsx11(
|
|
446
|
-
ChatRuntimeScope,
|
|
447
|
-
{
|
|
448
|
-
server: stableServer,
|
|
449
|
-
agent,
|
|
450
|
-
agentName,
|
|
451
|
-
listSessionsAgentId,
|
|
452
|
-
initialSessionId,
|
|
453
|
-
adapters,
|
|
454
|
-
onError,
|
|
455
|
-
children
|
|
456
|
-
}
|
|
457
|
-
) });
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// src/containers/useResolvedServer.ts
|
|
461
|
-
import { createTrueFoundryAgentUIServer } from "@truefoundry/assistant-ui-runtime/plugins/truefoundry-agent-server-adapter";
|
|
462
|
-
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
463
|
-
var DEFAULT_CAPABILITIES = {
|
|
464
|
-
data: {
|
|
465
|
-
sandbox: { enabled: true },
|
|
466
|
-
skill: { enabled: true },
|
|
467
|
-
settings: { enabled: true }
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
function isBuiltInConfig(config) {
|
|
471
|
-
return typeof config === "object" && config !== null && "type" in config && (config.type === "truefoundry" || config.type === "trueforge");
|
|
472
|
-
}
|
|
473
|
-
function hasGetCapabilities(server) {
|
|
474
|
-
return typeof Reflect.get(server, "getCapabilities") === "function";
|
|
475
|
-
}
|
|
476
|
-
function toAgentUIServer(server, catalog) {
|
|
477
|
-
const getCapabilities = hasGetCapabilities(server) ? () => server.getCapabilities() : async () => DEFAULT_CAPABILITIES;
|
|
478
|
-
const withCapabilities = { ...server, getCapabilities };
|
|
479
|
-
const withCatalog = catalog != null ? { ...withCapabilities, catalog } : withCapabilities;
|
|
480
|
-
if (!isAgentUIServer(withCatalog)) {
|
|
481
|
-
throw new Error("TrueforgeUI: runtime adapter returned an incomplete AgentUIServer");
|
|
482
|
-
}
|
|
483
|
-
return withCatalog;
|
|
484
|
-
}
|
|
485
|
-
function isAgentUIServer(value) {
|
|
486
|
-
return typeof Reflect.get(value, "createSession") === "function" && typeof Reflect.get(value, "listSessions") === "function" && typeof Reflect.get(value, "getSession") === "function" && typeof Reflect.get(value, "updateSession") === "function" && typeof Reflect.get(value, "createTurn") === "function" && typeof Reflect.get(value, "cancelSession") === "function" && typeof Reflect.get(value, "listTurns") === "function" && typeof Reflect.get(value, "getTurn") === "function" && typeof Reflect.get(value, "listEvents") === "function" && typeof Reflect.get(value, "getCapabilities") === "function" && typeof Reflect.get(value, "getModels") === "function" && typeof Reflect.get(value, "getSkills") === "function" && typeof Reflect.get(value, "getMcp") === "function" && typeof Reflect.get(value, "searchAgents") === "function" && typeof Reflect.get(value, "saveAgent") === "function";
|
|
487
|
-
}
|
|
488
|
-
function useResolvedServer(config, onError) {
|
|
489
|
-
const builtIn = isBuiltInConfig(config) ? config : null;
|
|
490
|
-
const directServer = isBuiltInConfig(config) ? null : config;
|
|
491
|
-
const type = builtIn?.type;
|
|
492
|
-
const apiKey = builtIn?.type === "truefoundry" ? builtIn.apiKey : "";
|
|
493
|
-
const controlPlaneURL = builtIn?.type === "truefoundry" ? builtIn.controlPlaneURL : "";
|
|
494
|
-
const gatewayPlaneURL = builtIn?.type === "truefoundry" ? builtIn.gatewayPlaneURL ?? "" : "";
|
|
495
|
-
const trueforgeBaseUrl = builtIn?.type === "trueforge" ? builtIn.baseUrl ?? "" : "";
|
|
496
|
-
const trueforgeToken = builtIn?.type === "trueforge" ? builtIn.token ?? "" : "";
|
|
497
|
-
const trueforgeFetch = builtIn?.type === "trueforge" ? builtIn.fetch : void 0;
|
|
498
|
-
const catalog = builtIn?.catalog;
|
|
499
|
-
const [state, setState] = useState3(() => {
|
|
500
|
-
if (directServer) {
|
|
501
|
-
return { status: "ready", server: directServer, error: null };
|
|
502
|
-
}
|
|
503
|
-
return { status: "loading", server: null, error: null };
|
|
504
|
-
});
|
|
505
|
-
useEffect3(() => {
|
|
506
|
-
if (directServer) {
|
|
507
|
-
setState({ status: "ready", server: directServer, error: null });
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
let cancelled = false;
|
|
511
|
-
setState({ status: "loading", server: null, error: null });
|
|
512
|
-
const resolve = async () => {
|
|
513
|
-
if (type === "trueforge") {
|
|
514
|
-
const { createTrueForgeAgentUIServer } = await import("./plugins/trueforge-agent-server-adapter/index.js");
|
|
515
|
-
return createTrueForgeAgentUIServer({
|
|
516
|
-
...trueforgeBaseUrl ? { baseUrl: trueforgeBaseUrl } : {},
|
|
517
|
-
...trueforgeToken ? { token: trueforgeToken } : {},
|
|
518
|
-
...trueforgeFetch !== void 0 ? { fetch: trueforgeFetch } : {},
|
|
519
|
-
...catalog != null ? { catalog } : {}
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
const runtimeServer = await createTrueFoundryAgentUIServer({
|
|
523
|
-
apiKey,
|
|
524
|
-
cpURL: controlPlaneURL,
|
|
525
|
-
...gatewayPlaneURL ? { gatewayURL: gatewayPlaneURL } : {}
|
|
526
|
-
});
|
|
527
|
-
return toAgentUIServer(runtimeServer, catalog);
|
|
528
|
-
};
|
|
529
|
-
void resolve().then((server) => {
|
|
530
|
-
if (cancelled) return;
|
|
531
|
-
try {
|
|
532
|
-
setState({
|
|
533
|
-
status: "ready",
|
|
534
|
-
server: type === "trueforge" ? toAgentUIServer(server, void 0) : server,
|
|
535
|
-
error: null
|
|
536
|
-
});
|
|
537
|
-
} catch (error) {
|
|
538
|
-
onError?.(error);
|
|
539
|
-
setState({ status: "error", server: null, error });
|
|
540
|
-
}
|
|
541
|
-
}).catch((error) => {
|
|
542
|
-
if (cancelled) return;
|
|
543
|
-
onError?.(error);
|
|
544
|
-
setState({ status: "error", server: null, error });
|
|
545
|
-
});
|
|
546
|
-
return () => {
|
|
547
|
-
cancelled = true;
|
|
548
|
-
};
|
|
549
|
-
}, [
|
|
550
|
-
type,
|
|
551
|
-
directServer,
|
|
552
|
-
apiKey,
|
|
553
|
-
controlPlaneURL,
|
|
554
|
-
gatewayPlaneURL,
|
|
555
|
-
trueforgeBaseUrl,
|
|
556
|
-
trueforgeToken,
|
|
557
|
-
trueforgeFetch,
|
|
558
|
-
catalog,
|
|
559
|
-
onError
|
|
560
|
-
]);
|
|
561
|
-
return state;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// src/containers/TrueforgeUI.tsx
|
|
565
|
-
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
566
|
-
var SidebarLayout = lazy(() => import("./SidebarLayout-F3XFXW7B.js").then((m) => ({ default: m.SidebarLayout })));
|
|
567
|
-
var DrawerLayout = lazy(() => import("./DrawerLayout-ZVWCKEIS.js").then((m) => ({ default: m.DrawerLayout })));
|
|
568
|
-
var DockLayout = lazy(() => import("./DockLayout-KEMFRWIR.js").then((m) => ({ default: m.DockLayout })));
|
|
569
|
-
var WidgetLayout = lazy(() => import("./WidgetLayout-SZMABKIR.js").then((m) => ({ default: m.WidgetLayout })));
|
|
570
|
-
function LayoutFallback({ className }) {
|
|
571
|
-
return /* @__PURE__ */ jsx12(
|
|
572
|
-
"div",
|
|
573
|
-
{
|
|
574
|
-
className,
|
|
575
|
-
style: {
|
|
576
|
-
height: "100%",
|
|
577
|
-
minHeight: "12rem",
|
|
578
|
-
background: "linear-gradient(90deg, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 25%, color-mix(in oklab, var(--secondary-bg) 25%, transparent) 50%, color-mix(in oklab, var(--secondary-bg) 55%, transparent) 75%)",
|
|
579
|
-
backgroundSize: "200% 100%",
|
|
580
|
-
animation: "tfy-aui-pulse 1.2s ease-in-out infinite"
|
|
581
|
-
},
|
|
582
|
-
"aria-hidden": true
|
|
583
|
-
}
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
function ServerInitLoader({ className }) {
|
|
587
|
-
return /* @__PURE__ */ jsxs6(
|
|
588
|
-
"div",
|
|
589
|
-
{
|
|
590
|
-
role: "status",
|
|
591
|
-
"aria-live": "polite",
|
|
592
|
-
"aria-busy": "true",
|
|
593
|
-
className: cn(
|
|
594
|
-
"flex h-full min-h-48 w-full flex-1 items-center justify-center bg-primary-bg text-text-secondary",
|
|
595
|
-
className
|
|
596
|
-
),
|
|
597
|
-
children: [
|
|
598
|
-
/* @__PURE__ */ jsx12(Spinner, { size: 28, className: "text-text-primary" }),
|
|
599
|
-
/* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Loading" })
|
|
600
|
-
]
|
|
601
|
-
}
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
function ServerInitError({ error, className }) {
|
|
605
|
-
const message = getErrorMessage(error, "Failed to initialize server");
|
|
606
|
-
return /* @__PURE__ */ jsx12(
|
|
607
|
-
"div",
|
|
608
|
-
{
|
|
609
|
-
role: "alert",
|
|
610
|
-
className: cn(
|
|
611
|
-
"flex h-full min-h-48 items-center justify-center bg-primary-bg px-6 text-center text-sm text-failure-bg",
|
|
612
|
-
className
|
|
613
|
-
),
|
|
614
|
-
children: message
|
|
615
|
-
}
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
function isBuiltInLayout(layout) {
|
|
619
|
-
return layout === "sidebar" || layout === "drawer" || layout === "dock" || layout === "widget";
|
|
620
|
-
}
|
|
621
|
-
function BuiltInLayoutView({ layout, className }) {
|
|
622
|
-
switch (layout) {
|
|
623
|
-
case "sidebar":
|
|
624
|
-
return /* @__PURE__ */ jsx12(SidebarLayout, { className });
|
|
625
|
-
case "drawer":
|
|
626
|
-
return /* @__PURE__ */ jsx12(DrawerLayout, { className });
|
|
627
|
-
case "dock":
|
|
628
|
-
return /* @__PURE__ */ jsx12(DockLayout, { className });
|
|
629
|
-
case "widget":
|
|
630
|
-
return /* @__PURE__ */ jsx12(WidgetLayout, { className });
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
function LayoutChildren({ layout, className }) {
|
|
634
|
-
if (isBuiltInLayout(layout)) {
|
|
635
|
-
return /* @__PURE__ */ jsx12(Suspense, { fallback: /* @__PURE__ */ jsx12(LayoutFallback, { className }), children: /* @__PURE__ */ jsx12(BuiltInLayoutView, { layout, className }) });
|
|
636
|
-
}
|
|
637
|
-
const HostLayout = layout;
|
|
638
|
-
return /* @__PURE__ */ jsx12(HostLayout, { className });
|
|
639
|
-
}
|
|
640
|
-
function ChatProviderFromShell({
|
|
641
|
-
children,
|
|
642
|
-
initialSessionId: hostInitialSessionId,
|
|
643
|
-
...providerRest
|
|
644
|
-
}) {
|
|
645
|
-
const { mode, runtimeKey, listSessionsAgentId, pendingSessionId } = useShellMode();
|
|
646
|
-
const draftDefaultAgentSpec = useMemo2(() => {
|
|
647
|
-
if (mode.status === "active" && mode.isMutable) {
|
|
648
|
-
return mode.agentSpec ?? { model: { name: "openai-main/gpt-4.1" } };
|
|
649
|
-
}
|
|
650
|
-
return { model: { name: "openai-main/gpt-4.1" } };
|
|
651
|
-
}, [runtimeKey]);
|
|
652
|
-
const agent = useMemo2(() => {
|
|
653
|
-
if (mode.status === "idle") {
|
|
654
|
-
return {
|
|
655
|
-
mode: "draft",
|
|
656
|
-
defaultAgentSpec: { model: { name: "openai-main/gpt-4.1" } }
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
if (!mode.isMutable) {
|
|
660
|
-
const agentName = mode.agentName ?? mode.agentId ?? pendingSessionId;
|
|
661
|
-
if (agentName == null) {
|
|
662
|
-
return {
|
|
663
|
-
mode: "draft",
|
|
664
|
-
defaultAgentSpec: { model: { name: "openai-main/gpt-4.1" } }
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
return { mode: "named", agentName };
|
|
668
|
-
}
|
|
669
|
-
return {
|
|
670
|
-
mode: "draft",
|
|
671
|
-
defaultAgentSpec: draftDefaultAgentSpec
|
|
672
|
-
};
|
|
673
|
-
}, [mode, draftDefaultAgentSpec, pendingSessionId]);
|
|
674
|
-
return /* @__PURE__ */ jsx12(
|
|
675
|
-
TrueFoundryChatProvider,
|
|
676
|
-
{
|
|
677
|
-
...providerRest,
|
|
678
|
-
agent,
|
|
679
|
-
listSessionsAgentId,
|
|
680
|
-
initialSessionId: pendingSessionId ?? hostInitialSessionId,
|
|
681
|
-
children: /* @__PURE__ */ jsxs6(DraftCatalogProvider, { children: [
|
|
682
|
-
/* @__PURE__ */ jsx12(DraftSpecPreferenceBridge, {}),
|
|
683
|
-
children
|
|
684
|
-
] })
|
|
685
|
-
},
|
|
686
|
-
runtimeKey
|
|
687
|
-
);
|
|
688
|
-
}
|
|
689
|
-
function TrueforgeUI(props) {
|
|
315
|
+
var TrueForgeUIWithRouter = lazy(
|
|
316
|
+
() => import("./TrueForgeUIWithRouter-IAQQTD5V.js").then((m) => ({ default: m.TrueForgeUIWithRouter }))
|
|
317
|
+
);
|
|
318
|
+
function TrueForgeUI(props) {
|
|
690
319
|
const isMcpAuthScreen = typeof window !== "undefined" && new URLSearchParams(window.location.search).get("screenType") === "mcp-auth";
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
function TrueforgeUIShell(props) {
|
|
694
|
-
const {
|
|
695
|
-
layout = "sidebar",
|
|
696
|
-
overrides,
|
|
697
|
-
theme,
|
|
698
|
-
className,
|
|
699
|
-
agentConfig = DEFAULT_AGENT_CONFIG,
|
|
700
|
-
initialSettingsOpen = false,
|
|
701
|
-
server: serverConfig,
|
|
702
|
-
onError,
|
|
703
|
-
...providerRest
|
|
704
|
-
} = props;
|
|
705
|
-
const resolved = useResolvedServer(serverConfig, onError);
|
|
706
|
-
if (resolved.status === "loading") {
|
|
707
|
-
return /* @__PURE__ */ jsx12(SlotsProvider, { overrides, theme, children: /* @__PURE__ */ jsx12(ServerInitLoader, { className }) });
|
|
320
|
+
if (isMcpAuthScreen) {
|
|
321
|
+
return /* @__PURE__ */ jsx11(SlotsProvider, { overrides: props.overrides, theme: props.theme, children: /* @__PURE__ */ jsx11(PostMcpOauthScreen_default, {}) });
|
|
708
322
|
}
|
|
709
|
-
|
|
710
|
-
|
|
323
|
+
const { withRouter, ...rest } = props;
|
|
324
|
+
if (withRouter) {
|
|
325
|
+
return /* @__PURE__ */ jsx11(Suspense, { fallback: /* @__PURE__ */ jsx11(ServerInitLoader, { className: props.className }), children: /* @__PURE__ */ jsx11(TrueForgeUIWithRouter, { ...rest }) });
|
|
711
326
|
}
|
|
712
|
-
|
|
713
|
-
const layoutTree = /* @__PURE__ */ jsx12(LayoutChildren, { layout, className });
|
|
714
|
-
return /* @__PURE__ */ jsx12(SlotsProvider, { overrides, theme, children: /* @__PURE__ */ jsx12(ServerProvider, { server, children: /* @__PURE__ */ jsx12(ShellModeProvider, { agentConfig, initialSettingsOpen, children: /* @__PURE__ */ jsx12(ChatProviderFromShell, { server, onError, ...providerRest, children: layoutTree }) }) }) });
|
|
327
|
+
return /* @__PURE__ */ jsx11(TrueForgeUIShell, { ...rest });
|
|
715
328
|
}
|
|
716
329
|
|
|
717
330
|
// src/index.ts
|
|
718
331
|
import {
|
|
719
332
|
mergeAgentSpec,
|
|
720
|
-
trueFoundryAttachmentAdapter
|
|
721
|
-
useTrueFoundryAgentRuntime
|
|
722
|
-
useTrueFoundryAgentSpec
|
|
333
|
+
trueFoundryAttachmentAdapter,
|
|
334
|
+
useTrueFoundryAgentRuntime,
|
|
335
|
+
useTrueFoundryAgentSpec,
|
|
723
336
|
useTrueFoundryCancel,
|
|
724
337
|
useTrueFoundryDownloadSandboxFile,
|
|
725
338
|
useTrueFoundryHistoryPagination,
|
|
@@ -727,7 +340,7 @@ import {
|
|
|
727
340
|
useTrueFoundryRespondToToolApproval,
|
|
728
341
|
useTrueFoundryToolResponses,
|
|
729
342
|
useTrueFoundryTurnId,
|
|
730
|
-
useTrueFoundryUpdateAgentSpec
|
|
343
|
+
useTrueFoundryUpdateAgentSpec
|
|
731
344
|
} from "@truefoundry/assistant-ui-runtime";
|
|
732
345
|
export {
|
|
733
346
|
AgentStepsCard,
|
|
@@ -819,8 +432,8 @@ export {
|
|
|
819
432
|
ToolCallContentBlockContainer,
|
|
820
433
|
ToolGroupCard,
|
|
821
434
|
ToolGroupContainer,
|
|
435
|
+
TrueForgeUI,
|
|
822
436
|
TrueFoundryChatProvider,
|
|
823
|
-
TrueforgeUI,
|
|
824
437
|
USER_MESSAGE_ATTACHMENT_PREVIEW_REM,
|
|
825
438
|
UserEditComposerContainer,
|
|
826
439
|
UserMessageActionBar,
|
|
@@ -838,7 +451,7 @@ export {
|
|
|
838
451
|
resolvePresetTokens,
|
|
839
452
|
shellIsMutable,
|
|
840
453
|
threadHasPendingMcpAuth,
|
|
841
|
-
|
|
454
|
+
trueFoundryAttachmentAdapter,
|
|
842
455
|
useAui,
|
|
843
456
|
useAuiState,
|
|
844
457
|
useBrand,
|
|
@@ -862,8 +475,8 @@ export {
|
|
|
862
475
|
useThemeMode,
|
|
863
476
|
useToaster,
|
|
864
477
|
useToasterOptional,
|
|
865
|
-
|
|
866
|
-
|
|
478
|
+
useTrueFoundryAgentRuntime,
|
|
479
|
+
useTrueFoundryAgentSpec,
|
|
867
480
|
useTrueFoundryCancel,
|
|
868
481
|
useTrueFoundryDownloadSandboxFile,
|
|
869
482
|
useTrueFoundryHistoryPagination,
|
|
@@ -871,6 +484,6 @@ export {
|
|
|
871
484
|
useTrueFoundryRespondToToolApproval,
|
|
872
485
|
useTrueFoundryToolResponses,
|
|
873
486
|
useTrueFoundryTurnId,
|
|
874
|
-
|
|
487
|
+
useTrueFoundryUpdateAgentSpec
|
|
875
488
|
};
|
|
876
489
|
//# sourceMappingURL=index.js.map
|