@truefoundry/trueforge-ui 0.3.0-rc.0 → 0.3.0-rc.10

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 (115) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/README.md +35 -12
  3. package/dist/AgentCodeSnippets-RJBB4DDE.js +89 -0
  4. package/dist/AgentCodeSnippets-RJBB4DDE.js.map +1 -0
  5. package/dist/AgentMetricChart-UPGSJ2WP.js +15 -0
  6. package/dist/AgentOverview-U5WIQXZN.js +169 -0
  7. package/dist/AgentOverview-U5WIQXZN.js.map +1 -0
  8. package/dist/AgentSessionEventTimeline-GRGIQTRE.js +88 -0
  9. package/dist/AgentSessionEventTimeline-GRGIQTRE.js.map +1 -0
  10. package/dist/AgentSessionEventTimelineChart-GNF4VOUT.js +591 -0
  11. package/dist/AgentSessionEventTimelineChart-GNF4VOUT.js.map +1 -0
  12. package/dist/AgentSessions-5OTF2BUW.js +323 -0
  13. package/dist/AgentSessions-5OTF2BUW.js.map +1 -0
  14. package/dist/{ConnectorSettings-FXQ5B7TN.js → ConnectorSettings-HDKGLDCY.js} +163 -125
  15. package/dist/ConnectorSettings-HDKGLDCY.js.map +1 -0
  16. package/dist/{DockLayout-LBNQJZNF.js → DockLayout-D2FPQCAL.js} +11 -10
  17. package/dist/{DockLayout-LBNQJZNF.js.map → DockLayout-D2FPQCAL.js.map} +1 -1
  18. package/dist/DrawerLayout-HUV7RAWL.js +186 -0
  19. package/dist/DrawerLayout-HUV7RAWL.js.map +1 -0
  20. package/dist/{ModelSettings-4L4LOQJA.js → ModelSettings-VNQ7HPKH.js} +23 -27
  21. package/dist/ModelSettings-VNQ7HPKH.js.map +1 -0
  22. package/dist/OpenUiFenceBlock-KPZFLUSC.js +9 -0
  23. package/dist/OpenUiFenceBlock-KPZFLUSC.js.map +1 -0
  24. package/dist/{SandboxSettings-Z4ZG6ZX4.js → SandboxSettings-ZLXGMFBF.js} +18 -20
  25. package/dist/SandboxSettings-ZLXGMFBF.js.map +1 -0
  26. package/dist/SchedulesPage-QKYI2Z3A.js +15 -0
  27. package/dist/SchedulesPage-QKYI2Z3A.js.map +1 -0
  28. package/dist/{SettingsBuilder-WF7ZWKQW.js → SettingsBuilder-RVVYXOJW.js} +27 -23
  29. package/dist/SettingsBuilder-RVVYXOJW.js.map +1 -0
  30. package/dist/ShellRouteSync-SJXFKUAJ.js +390 -0
  31. package/dist/ShellRouteSync-SJXFKUAJ.js.map +1 -0
  32. package/dist/SidebarLayout-KYA76FQ7.js +330 -0
  33. package/dist/SidebarLayout-KYA76FQ7.js.map +1 -0
  34. package/dist/{SkillSettings-3EPPC3IT.js → SkillSettings-7OHT7FPI.js} +25 -21
  35. package/dist/SkillSettings-7OHT7FPI.js.map +1 -0
  36. package/dist/{TrueForgeUIWithRouter-NZ4FGPE4.js → TrueForgeUIWithRouter-LKG4XLW6.js} +14 -10
  37. package/dist/{TrueForgeUIWithRouter-NZ4FGPE4.js.map → TrueForgeUIWithRouter-LKG4XLW6.js.map} +1 -1
  38. package/dist/{WidgetLayout-3QZ357FL.js → WidgetLayout-W2RGGOQ3.js} +17 -13
  39. package/dist/WidgetLayout-W2RGGOQ3.js.map +1 -0
  40. package/dist/chunk-2GIZY3JJ.js +1062 -0
  41. package/dist/chunk-2GIZY3JJ.js.map +1 -0
  42. package/dist/chunk-2QTH6JHX.js +217 -0
  43. package/dist/chunk-2QTH6JHX.js.map +1 -0
  44. package/dist/{chunk-FJ5RSSMA.js → chunk-3ZW74FHC.js} +118 -164
  45. package/dist/chunk-3ZW74FHC.js.map +1 -0
  46. package/dist/chunk-67ZO7Z2W.js +184 -0
  47. package/dist/chunk-67ZO7Z2W.js.map +1 -0
  48. package/dist/{chunk-CFLVPV5M.js → chunk-7AAO4UDQ.js} +8 -2
  49. package/dist/chunk-7AAO4UDQ.js.map +1 -0
  50. package/dist/{chunk-B52K63AW.js → chunk-CG75X77Q.js} +2 -2
  51. package/dist/chunk-DJUFS2BW.js +27 -0
  52. package/dist/chunk-DJUFS2BW.js.map +1 -0
  53. package/dist/chunk-DPPOEFBD.js +517 -0
  54. package/dist/chunk-DPPOEFBD.js.map +1 -0
  55. package/dist/chunk-EPAL2HD5.js +1629 -0
  56. package/dist/chunk-EPAL2HD5.js.map +1 -0
  57. package/dist/chunk-GG23N2GW.js +15018 -0
  58. package/dist/chunk-GG23N2GW.js.map +1 -0
  59. package/dist/chunk-JCL3Q7RW.js +587 -0
  60. package/dist/chunk-JCL3Q7RW.js.map +1 -0
  61. package/dist/chunk-JKEBMGLH.js +682 -0
  62. package/dist/chunk-JKEBMGLH.js.map +1 -0
  63. package/dist/chunk-KSGNKS2D.js +296 -0
  64. package/dist/chunk-KSGNKS2D.js.map +1 -0
  65. package/dist/{chunk-WREC7D54.js → chunk-PCI6VMB5.js} +268 -48
  66. package/dist/chunk-PCI6VMB5.js.map +1 -0
  67. package/dist/chunk-PQ7VWBQQ.js +121 -0
  68. package/dist/chunk-PQ7VWBQQ.js.map +1 -0
  69. package/dist/chunk-RDXBMTP5.js +32 -0
  70. package/dist/chunk-RDXBMTP5.js.map +1 -0
  71. package/dist/chunk-T6QQV5LK.js +238 -0
  72. package/dist/chunk-T6QQV5LK.js.map +1 -0
  73. package/dist/chunk-Y6S4OVVQ.js +16 -0
  74. package/dist/chunk-Y6S4OVVQ.js.map +1 -0
  75. package/dist/{createTrueFoundryServer-B72bU-J7.d.ts → createTrueFoundryServer-B_FYhSdn.d.ts} +18 -4
  76. package/dist/index.d.ts +1287 -46
  77. package/dist/index.js +266 -63
  78. package/dist/index.js.map +1 -1
  79. package/dist/plugins/trueforge-agent-server-adapter/index.d.ts +590 -11
  80. package/dist/plugins/trueforge-agent-server-adapter/index.js +607 -204
  81. package/dist/plugins/trueforge-agent-server-adapter/index.js.map +1 -1
  82. package/dist/styles.css +1 -1
  83. package/package.json +10 -8
  84. package/dist/ConnectorSettings-FXQ5B7TN.js.map +0 -1
  85. package/dist/DrawerLayout-Q6UK4VMI.js +0 -159
  86. package/dist/DrawerLayout-Q6UK4VMI.js.map +0 -1
  87. package/dist/ModelSettings-4L4LOQJA.js.map +0 -1
  88. package/dist/OpenUiFenceBlock-6UIIAVBX.js +0 -9
  89. package/dist/SandboxSettings-Z4ZG6ZX4.js.map +0 -1
  90. package/dist/SettingsBuilder-WF7ZWKQW.js.map +0 -1
  91. package/dist/ShellRouteSync-T4WLY57Q.js +0 -172
  92. package/dist/ShellRouteSync-T4WLY57Q.js.map +0 -1
  93. package/dist/SidebarLayout-3WZ3CVON.js +0 -256
  94. package/dist/SidebarLayout-3WZ3CVON.js.map +0 -1
  95. package/dist/SkillSettings-3EPPC3IT.js.map +0 -1
  96. package/dist/WidgetLayout-3QZ357FL.js.map +0 -1
  97. package/dist/chunk-36KOSC2J.js +0 -567
  98. package/dist/chunk-36KOSC2J.js.map +0 -1
  99. package/dist/chunk-3S6KHO7H.js +0 -2121
  100. package/dist/chunk-3S6KHO7H.js.map +0 -1
  101. package/dist/chunk-7L63OK3O.js +0 -91
  102. package/dist/chunk-7L63OK3O.js.map +0 -1
  103. package/dist/chunk-CFLVPV5M.js.map +0 -1
  104. package/dist/chunk-FJ5RSSMA.js.map +0 -1
  105. package/dist/chunk-OSV3HI5M.js +0 -6891
  106. package/dist/chunk-OSV3HI5M.js.map +0 -1
  107. package/dist/chunk-WQULF5AT.js +0 -460
  108. package/dist/chunk-WQULF5AT.js.map +0 -1
  109. package/dist/chunk-WREC7D54.js.map +0 -1
  110. package/dist/chunk-YIWUG6MC.js +0 -101
  111. package/dist/chunk-YIWUG6MC.js.map +0 -1
  112. package/dist/chunk-ZXOADNF3.js +0 -75
  113. package/dist/chunk-ZXOADNF3.js.map +0 -1
  114. /package/dist/{OpenUiFenceBlock-6UIIAVBX.js.map → AgentMetricChart-UPGSJ2WP.js.map} +0 -0
  115. /package/dist/{chunk-B52K63AW.js.map → chunk-CG75X77Q.js.map} +0 -0
@@ -1,42 +1,96 @@
1
+ import {
2
+ WidgetVisibilityProvider
3
+ } from "./chunk-DJUFS2BW.js";
1
4
  import {
2
5
  CustomActionRenderersProvider,
3
6
  notifyComposerBusyFailure
4
7
  } from "./chunk-BSIPI3KV.js";
5
8
  import {
6
- useAuiState
7
- } from "./chunk-M6MHLVSO.js";
9
+ ResolvedRoutesProvider
10
+ } from "./chunk-Y6S4OVVQ.js";
8
11
  import {
12
+ IS_CREATE_AGENT_METADATA_KEY,
13
+ isCreateAgentMetadataValue,
14
+ sessionIsCreateAgent
15
+ } from "./chunk-RDXBMTP5.js";
16
+ import {
17
+ ActiveSessionPermissionsProvider,
18
+ AgentConfigInstructionsProvider,
19
+ CurrentUserProvider,
9
20
  SlotsProvider,
10
21
  ToasterProvider,
11
22
  modelPatchWithReasoningEffort,
23
+ mountName,
24
+ useThemeMode,
12
25
  useToaster
13
- } from "./chunk-OSV3HI5M.js";
26
+ } from "./chunk-GG23N2GW.js";
14
27
  import {
15
28
  DraftCatalogProvider,
16
- Spinner,
17
- getErrorMessage,
18
29
  useDraftCatalog
19
- } from "./chunk-FJ5RSSMA.js";
30
+ } from "./chunk-3ZW74FHC.js";
20
31
  import {
21
32
  DEFAULT_AGENT_CONFIG,
22
33
  ServerProvider,
23
34
  ShellModeProvider,
35
+ getErrorMessage,
36
+ isSessionsChromeEnabled,
37
+ readSessionShareSearch,
38
+ useOptionalAgentSessionsServer,
39
+ useOptionalShellMode,
24
40
  useServerCapabilities,
25
41
  useShellMode,
26
42
  withCapabilitiesSandbox
27
- } from "./chunk-WQULF5AT.js";
43
+ } from "./chunk-2GIZY3JJ.js";
44
+ import {
45
+ useAui,
46
+ useAuiState
47
+ } from "./chunk-M6MHLVSO.js";
28
48
  import {
29
49
  cn
30
- } from "./chunk-36KOSC2J.js";
50
+ } from "./chunk-JCL3Q7RW.js";
31
51
 
32
52
  // src/containers/TrueFoundryChatProvider.tsx
33
- import { AssistantRuntimeProvider } from "@assistant-ui/react";
53
+ import { AssistantRuntimeProvider, useAuiState as useAuiState2 } from "@assistant-ui/react";
34
54
  import {
35
55
  trueFoundryAttachmentAdapter,
36
56
  useTrueFoundryAgentRuntime
37
57
  } from "@truefoundry/assistant-ui-runtime";
38
58
  import { useCallback, useMemo } from "react";
39
59
  import { jsx } from "react/jsx-runtime";
60
+ function ActiveSessionPermissionScope({
61
+ locallyCreatedSessionIds,
62
+ children
63
+ }) {
64
+ const remoteId = useAuiState2((state) => state.threadListItem.remoteId);
65
+ return /* @__PURE__ */ jsx(
66
+ ActiveSessionPermissionsProvider,
67
+ {
68
+ sessionId: remoteId,
69
+ assumeManage: remoteId != null && locallyCreatedSessionIds.has(remoteId),
70
+ children
71
+ }
72
+ );
73
+ }
74
+ function runtimeServer({
75
+ server,
76
+ locallyCreatedSessionIds
77
+ }) {
78
+ return {
79
+ ...server,
80
+ async createSession(request) {
81
+ const session = await server.createSession(request);
82
+ locallyCreatedSessionIds.add(session.id);
83
+ return session;
84
+ },
85
+ async listSessions(request) {
86
+ const result = await server.listSessions(request);
87
+ return {
88
+ ...result,
89
+ data: result.data.filter((session) => !sessionIsCreateAgent(session))
90
+ };
91
+ }
92
+ };
93
+ }
40
94
  function ChatRuntimeScope({
41
95
  server,
42
96
  agent,
@@ -49,6 +103,12 @@ function ChatRuntimeScope({
49
103
  }) {
50
104
  const { showError } = useToaster();
51
105
  const reportError = onError ?? showError;
106
+ const localSessionState = useMemo(() => ({ server, ids: /* @__PURE__ */ new Set() }), [server]);
107
+ const locallyCreatedSessionIds = localSessionState.ids;
108
+ const historyServer = useMemo(
109
+ () => runtimeServer({ server, locallyCreatedSessionIds }),
110
+ [locallyCreatedSessionIds, server]
111
+ );
52
112
  const resolvedOnError = useCallback(
53
113
  (error) => {
54
114
  notifyComposerBusyFailure();
@@ -57,10 +117,11 @@ function ChatRuntimeScope({
57
117
  [reportError]
58
118
  );
59
119
  const runtime = useTrueFoundryAgentRuntime({
60
- server,
120
+ server: historyServer,
61
121
  agent,
62
122
  agentName,
63
123
  listSessionsAgentId,
124
+ listSessionsCreatedByMe: true,
64
125
  initialSessionId,
65
126
  onError: resolvedOnError,
66
127
  adapters: {
@@ -68,7 +129,7 @@ function ChatRuntimeScope({
68
129
  attachments: adapters?.attachments ?? trueFoundryAttachmentAdapter
69
130
  }
70
131
  });
71
- return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { runtime, children });
132
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(ActiveSessionPermissionScope, { locallyCreatedSessionIds, children }) });
72
133
  }
73
134
  function TrueFoundryChatProvider(props) {
74
135
  const { server, initialSessionId, adapters, onError, children, agent, agentName, listSessionsAgentId } = props;
@@ -90,13 +151,17 @@ function TrueFoundryChatProvider(props) {
90
151
 
91
152
  // src/containers/TrueForgeUIShell.tsx
92
153
  import { lazy, Suspense, useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
154
+ import { ThinkingOrb } from "thinking-orbs";
93
155
 
94
156
  // src/atoms/draft/DraftSpecPreferenceBridge.tsx
95
157
  import { useTrueFoundryAgentSpec, useTrueFoundryUpdateAgentSpec } from "@truefoundry/assistant-ui-runtime";
96
158
  import { useEffect } from "react";
97
- function mountName(mount) {
98
- const name = Reflect.get(mount, "name");
99
- return typeof name === "string" ? name : null;
159
+ function readDraftSandboxEnabled(spec) {
160
+ if (spec.config === void 0) return void 0;
161
+ const sandbox = Reflect.get(spec.config, "sandbox");
162
+ if (typeof sandbox !== "object" || sandbox === null) return void 0;
163
+ const enabled = Reflect.get(sandbox, "enabled");
164
+ return typeof enabled === "boolean" ? enabled : void 0;
100
165
  }
101
166
  function filterMounts(mounts, availableNames) {
102
167
  if (mounts === void 0) return void 0;
@@ -143,8 +208,30 @@ function reconcileDraftSpecPreferences({
143
208
  }
144
209
  function reconcileDraftSandbox({
145
210
  agentSpec,
146
- sandboxEnabled
211
+ sandboxEnabled,
212
+ kind = "agent"
147
213
  }) {
214
+ if (kind === "chat") {
215
+ if (sandboxEnabled == null) return {};
216
+ const current = readDraftSandboxEnabled(agentSpec);
217
+ if (sandboxEnabled === true && current !== true) {
218
+ return {
219
+ config: {
220
+ ...agentSpec.config,
221
+ sandbox: { ...agentSpec.config?.sandbox, enabled: true }
222
+ }
223
+ };
224
+ }
225
+ if (sandboxEnabled === false && current === true) {
226
+ return {
227
+ config: {
228
+ ...agentSpec.config,
229
+ sandbox: { ...agentSpec.config?.sandbox, enabled: false }
230
+ }
231
+ };
232
+ }
233
+ return {};
234
+ }
148
235
  const nextSpec = withCapabilitiesSandbox(agentSpec, sandboxEnabled);
149
236
  return nextSpec === agentSpec ? {} : { config: nextSpec.config };
150
237
  }
@@ -156,21 +243,22 @@ function DraftSpecPreferenceBridge() {
156
243
  const sandboxEnabled = capabilities?.sandbox.enabled;
157
244
  const { models, skills, connectors, loaded, error, ensureLoaded } = useDraftCatalog();
158
245
  const isPlainDraft = mode.status === "active" && mode.isMutable && mode.agentId == null && pendingSessionId == null;
246
+ const preferenceKind = mode.status === "active" && mode.isMutable && mode.isCreateAgent ? "agent" : "chat";
159
247
  useEffect(() => {
160
248
  if (isPlainDraft) ensureLoaded();
161
249
  }, [ensureLoaded, isPlainDraft]);
162
250
  useEffect(() => {
163
251
  if (isPlainDraft && agentSpec != null) {
164
- rememberDraftSpec(agentSpec);
252
+ rememberDraftSpec(agentSpec, preferenceKind);
165
253
  }
166
- }, [agentSpec, isPlainDraft, rememberDraftSpec]);
254
+ }, [agentSpec, isPlainDraft, preferenceKind, rememberDraftSpec]);
167
255
  useEffect(() => {
168
256
  if (!isPlainDraft || agentSpec == null || updateAgentSpec == null) return;
169
- const update = reconcileDraftSandbox({ agentSpec, sandboxEnabled });
257
+ const update = reconcileDraftSandbox({ agentSpec, sandboxEnabled, kind: preferenceKind });
170
258
  if (Object.keys(update).length > 0) {
171
259
  updateAgentSpec(update);
172
260
  }
173
- }, [agentSpec, isPlainDraft, sandboxEnabled, updateAgentSpec]);
261
+ }, [agentSpec, isPlainDraft, preferenceKind, sandboxEnabled, updateAgentSpec]);
174
262
  useEffect(() => {
175
263
  if (!isPlainDraft || agentSpec == null || updateAgentSpec == null || !loaded || error != null) return;
176
264
  const update = reconcileDraftSpecPreferences({
@@ -197,19 +285,100 @@ function DraftSpecPreferenceBridge() {
197
285
  return null;
198
286
  }
199
287
 
200
- // src/routing/RemoteIdRouteBridge.tsx
288
+ // src/routing/HistorySessionSwitchBridge.tsx
201
289
  import { useEffect as useEffect2 } from "react";
290
+ function HistorySessionSwitchBridge() {
291
+ const shell = useOptionalShellMode();
292
+ const aui = useAui();
293
+ const pendingSessionId = shell?.pendingSessionId;
294
+ const pendingSessionEpoch = shell?.pendingSessionEpoch ?? 0;
295
+ useEffect2(() => {
296
+ if (pendingSessionId == null) return;
297
+ void Promise.resolve(aui.threads().switchToThread(pendingSessionId)).catch(() => void 0);
298
+ }, [aui, pendingSessionId, pendingSessionEpoch]);
299
+ return null;
300
+ }
301
+
302
+ // src/routing/LibrarySessionShareBoot.tsx
303
+ import { useEffect as useEffect3 } from "react";
304
+ function LibrarySessionShareBoot() {
305
+ const { openLibraryAgent, setSessionsOpen } = useShellMode();
306
+ const sessions = useOptionalAgentSessionsServer();
307
+ const sessionsEnabled = isSessionsChromeEnabled({ sessions });
308
+ useEffect3(() => {
309
+ if (!sessionsEnabled) return;
310
+ const share = readSessionShareSearch(window.location.search);
311
+ if (share.view === "sessions") {
312
+ setSessionsOpen(true);
313
+ return;
314
+ }
315
+ if (share.agentId == null) return;
316
+ openLibraryAgent(share.agentId);
317
+ }, [openLibraryAgent, sessionsEnabled, setSessionsOpen]);
318
+ return null;
319
+ }
320
+
321
+ // src/routing/RemoteIdRouteBridge.tsx
322
+ import { useEffect as useEffect4 } from "react";
202
323
  function RemoteIdRouteBridge({ onRemoteIdChange }) {
203
324
  const remoteId = useAuiState((s) => s.threadListItem.remoteId);
204
- useEffect2(() => {
325
+ useEffect4(() => {
205
326
  onRemoteIdChange(remoteId ?? void 0);
206
327
  }, [remoteId, onRemoteIdChange]);
207
328
  return null;
208
329
  }
209
330
 
331
+ // src/server/sessionListCache.ts
332
+ var SESSION_LIST_TTL_MS = 3e4;
333
+ function createSessionListCache() {
334
+ return /* @__PURE__ */ new Map();
335
+ }
336
+ function cacheKey(request) {
337
+ const rest = { ...request };
338
+ delete rest.startTimestamp;
339
+ return JSON.stringify(rest, Object.keys(rest).sort());
340
+ }
341
+ function withSessionListCache({
342
+ server,
343
+ cache
344
+ }) {
345
+ const { deleteSession } = server;
346
+ return {
347
+ ...server,
348
+ listSessions(request) {
349
+ const key = cacheKey(request);
350
+ const now = Date.now();
351
+ const entry = cache.get(key);
352
+ if (entry !== void 0 && now - entry.at < SESSION_LIST_TTL_MS) return entry.page;
353
+ const page = server.listSessions(request);
354
+ cache.set(key, { at: now, page });
355
+ void page.catch(() => {
356
+ if (cache.get(key)?.page === page) cache.delete(key);
357
+ });
358
+ return page;
359
+ },
360
+ async createSession(request) {
361
+ const result = await server.createSession(request);
362
+ cache.clear();
363
+ return result;
364
+ },
365
+ async updateSession(request) {
366
+ const result = await server.updateSession(request);
367
+ cache.clear();
368
+ return result;
369
+ },
370
+ ...deleteSession != null ? {
371
+ deleteSession: async (request) => {
372
+ await deleteSession.call(server, request);
373
+ cache.clear();
374
+ }
375
+ } : {}
376
+ };
377
+ }
378
+
210
379
  // src/containers/useResolvedServer.ts
211
380
  import { createTrueFoundryAgentUIServer } from "@truefoundry/assistant-ui-runtime/plugins/truefoundry-agent-server-adapter";
212
- import { useEffect as useEffect3, useState } from "react";
381
+ import { useEffect as useEffect5, useState } from "react";
213
382
  var DEFAULT_CAPABILITIES = {
214
383
  data: {
215
384
  sandbox: { enabled: true },
@@ -223,14 +392,18 @@ function isBuiltInConfig(config) {
223
392
  function hasGetCapabilities(server) {
224
393
  return typeof Reflect.get(server, "getCapabilities") === "function";
225
394
  }
226
- function toAgentUIServer(server, catalog) {
395
+ function toAgentUIServer(server, catalog, permissions) {
227
396
  const getCapabilities = hasGetCapabilities(server) ? () => server.getCapabilities() : async () => DEFAULT_CAPABILITIES;
228
397
  const withCapabilities = { ...server, getCapabilities };
229
- const withCatalog = catalog != null ? { ...withCapabilities, catalog } : withCapabilities;
230
- if (!isAgentUIServer(withCatalog)) {
398
+ const withOptionalPorts = {
399
+ ...withCapabilities,
400
+ ...catalog == null ? {} : { catalog },
401
+ ...permissions == null ? {} : { permissions }
402
+ };
403
+ if (!isAgentUIServer(withOptionalPorts)) {
231
404
  throw new Error("TrueForgeUI: runtime adapter returned an incomplete AgentUIServer");
232
405
  }
233
- return withCatalog;
406
+ return withOptionalPorts;
234
407
  }
235
408
  function isAgentUIServer(value) {
236
409
  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";
@@ -246,13 +419,14 @@ function useResolvedServer(config, onError) {
246
419
  const trueforgeToken = builtIn?.type === "trueforge" ? builtIn.token ?? "" : "";
247
420
  const trueforgeFetch = builtIn?.type === "trueforge" ? builtIn.fetch : void 0;
248
421
  const catalog = builtIn?.catalog;
422
+ const permissions = builtIn?.permissions;
249
423
  const [state, setState] = useState(() => {
250
424
  if (directServer) {
251
425
  return { status: "ready", server: directServer, error: null };
252
426
  }
253
427
  return { status: "loading", server: null, error: null };
254
428
  });
255
- useEffect3(() => {
429
+ useEffect5(() => {
256
430
  if (directServer) {
257
431
  setState({ status: "ready", server: directServer, error: null });
258
432
  return;
@@ -266,22 +440,23 @@ function useResolvedServer(config, onError) {
266
440
  ...trueforgeBaseUrl ? { baseUrl: trueforgeBaseUrl } : {},
267
441
  ...trueforgeToken ? { token: trueforgeToken } : {},
268
442
  ...trueforgeFetch !== void 0 ? { fetch: trueforgeFetch } : {},
269
- ...catalog != null ? { catalog } : {}
443
+ ...catalog != null ? { catalog } : {},
444
+ ...permissions != null ? { permissions } : {}
270
445
  });
271
446
  }
272
- const runtimeServer = await createTrueFoundryAgentUIServer({
447
+ const runtimeServer2 = await createTrueFoundryAgentUIServer({
273
448
  apiKey,
274
449
  cpURL: controlPlaneURL,
275
450
  ...gatewayPlaneURL ? { gatewayURL: gatewayPlaneURL } : {}
276
451
  });
277
- return toAgentUIServer(runtimeServer, catalog);
452
+ return toAgentUIServer(runtimeServer2, catalog, permissions);
278
453
  };
279
454
  void resolve().then((server) => {
280
455
  if (cancelled) return;
281
456
  try {
282
457
  setState({
283
458
  status: "ready",
284
- server: type === "trueforge" ? toAgentUIServer(server, void 0) : server,
459
+ server: type === "trueforge" ? toAgentUIServer(server, void 0, void 0) : server,
285
460
  error: null
286
461
  });
287
462
  } catch (error) {
@@ -306,6 +481,7 @@ function useResolvedServer(config, onError) {
306
481
  trueforgeToken,
307
482
  trueforgeFetch,
308
483
  catalog,
484
+ permissions,
309
485
  onError
310
486
  ]);
311
487
  return state;
@@ -313,11 +489,11 @@ function useResolvedServer(config, onError) {
313
489
 
314
490
  // src/containers/TrueForgeUIShell.tsx
315
491
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
316
- var SidebarLayout = lazy(() => import("./SidebarLayout-3WZ3CVON.js").then((m) => ({ default: m.SidebarLayout })));
317
- var DrawerLayout = lazy(() => import("./DrawerLayout-Q6UK4VMI.js").then((m) => ({ default: m.DrawerLayout })));
318
- var DockLayout = lazy(() => import("./DockLayout-LBNQJZNF.js").then((m) => ({ default: m.DockLayout })));
319
- var WidgetLayout = lazy(() => import("./WidgetLayout-3QZ357FL.js").then((m) => ({ default: m.WidgetLayout })));
320
- var ShellRouteSync = lazy(() => import("./ShellRouteSync-T4WLY57Q.js").then((m) => ({ default: m.ShellRouteSync })));
492
+ var SidebarLayout = lazy(() => import("./SidebarLayout-KYA76FQ7.js").then((m) => ({ default: m.SidebarLayout })));
493
+ var DrawerLayout = lazy(() => import("./DrawerLayout-HUV7RAWL.js").then((m) => ({ default: m.DrawerLayout })));
494
+ var DockLayout = lazy(() => import("./DockLayout-D2FPQCAL.js").then((m) => ({ default: m.DockLayout })));
495
+ var WidgetLayout = lazy(() => import("./WidgetLayout-W2RGGOQ3.js").then((m) => ({ default: m.WidgetLayout })));
496
+ var ShellRouteSync = lazy(() => import("./ShellRouteSync-SJXFKUAJ.js").then((m) => ({ default: m.ShellRouteSync })));
321
497
  function LayoutFallback({ className }) {
322
498
  return /* @__PURE__ */ jsx2(
323
499
  "div",
@@ -335,20 +511,30 @@ function LayoutFallback({ className }) {
335
511
  );
336
512
  }
337
513
  function ServerInitLoader({ className }) {
338
- return /* @__PURE__ */ jsxs(
514
+ const themeMode = useThemeMode();
515
+ return /* @__PURE__ */ jsx2(
339
516
  "div",
340
517
  {
341
518
  role: "status",
519
+ "aria-label": "Loading",
342
520
  "aria-live": "polite",
343
521
  "aria-busy": "true",
344
522
  className: cn(
345
523
  "flex h-full min-h-48 w-full flex-1 items-center justify-center bg-primary-bg text-text-secondary",
346
524
  className
347
525
  ),
348
- children: [
349
- /* @__PURE__ */ jsx2(Spinner, { size: 28, className: "text-text-primary" }),
350
- /* @__PURE__ */ jsx2("span", { className: "sr-only", children: "Loading" })
351
- ]
526
+ children: /* @__PURE__ */ jsx2(
527
+ ThinkingOrb,
528
+ {
529
+ state: "connecting",
530
+ speed: 1,
531
+ theme: themeMode,
532
+ paused: false,
533
+ "aria-hidden": true,
534
+ size: 64,
535
+ style: { width: "4.5rem", height: "4.5rem" }
536
+ }
537
+ )
352
538
  }
353
539
  );
354
540
  }
@@ -392,9 +578,37 @@ function ChatProviderFromShell({
392
578
  children,
393
579
  initialSessionId: hostInitialSessionId,
394
580
  onRemoteIdChange,
581
+ server,
395
582
  ...providerRest
396
583
  }) {
397
- const { mode, runtimeKey, listSessionsAgentId, pendingSessionId } = useShellMode();
584
+ const { mode, runtimeKey, historyAgentFilter, listSessionsAgentId, pendingSessionId } = useShellMode();
585
+ const isCreateAgent = mode.status === "active" && mode.isMutable && mode.isCreateAgent;
586
+ const [sessionListCache] = useState2(createSessionListCache);
587
+ const serverWithCreateIntent = useMemo2(() => {
588
+ return {
589
+ ...server,
590
+ createSession: (request) => {
591
+ if (request.agentSpec === void 0) {
592
+ return server.createSession(request);
593
+ }
594
+ const withMetadata = {
595
+ ...request,
596
+ metadata: {
597
+ [IS_CREATE_AGENT_METADATA_KEY]: isCreateAgentMetadataValue(isCreateAgent)
598
+ }
599
+ };
600
+ return server.createSession(withMetadata);
601
+ }
602
+ };
603
+ }, [server, isCreateAgent]);
604
+ const cachedRuntimeServer = useMemo2(
605
+ () => withSessionListCache({ server: serverWithCreateIntent, cache: sessionListCache }),
606
+ [serverWithCreateIntent, sessionListCache]
607
+ );
608
+ const runtimeServer2 = useMemo2(() => {
609
+ if (historyAgentFilter == null || historyAgentFilter.agentId != null) return cachedRuntimeServer;
610
+ return { ...cachedRuntimeServer, listSessions: async () => ({ data: [] }) };
611
+ }, [cachedRuntimeServer, historyAgentFilter]);
398
612
  const draftDefaultAgentSpec = useMemo2(() => {
399
613
  if (mode.status === "active" && mode.isMutable) {
400
614
  return mode.agentSpec ?? { model: { name: "openai-main/gpt-4.1" } };
@@ -423,21 +637,23 @@ function ChatProviderFromShell({
423
637
  defaultAgentSpec: draftDefaultAgentSpec
424
638
  };
425
639
  }, [mode, draftDefaultAgentSpec, pendingSessionId]);
426
- return /* @__PURE__ */ jsx2(
640
+ return /* @__PURE__ */ jsx2(DraftCatalogProvider, { children: /* @__PURE__ */ jsx2(
427
641
  TrueFoundryChatProvider,
428
642
  {
429
643
  ...providerRest,
644
+ server: runtimeServer2,
430
645
  agent,
431
646
  listSessionsAgentId,
432
647
  initialSessionId: pendingSessionId ?? hostInitialSessionId,
433
- children: /* @__PURE__ */ jsxs(DraftCatalogProvider, { children: [
648
+ children: /* @__PURE__ */ jsxs(AgentConfigInstructionsProvider, { children: [
434
649
  /* @__PURE__ */ jsx2(DraftSpecPreferenceBridge, {}),
650
+ /* @__PURE__ */ jsx2(HistorySessionSwitchBridge, {}),
435
651
  onRemoteIdChange != null ? /* @__PURE__ */ jsx2(RemoteIdRouteBridge, { onRemoteIdChange }) : null,
436
652
  children
437
653
  ] })
438
654
  },
439
655
  runtimeKey
440
- );
656
+ ) });
441
657
  }
442
658
  function TrueForgeUIShell(props) {
443
659
  const {
@@ -450,6 +666,7 @@ function TrueForgeUIShell(props) {
450
666
  server: serverConfig,
451
667
  onError,
452
668
  customActionRenderers,
669
+ currentUser,
453
670
  resolvedRoutes,
454
671
  routes: _routes,
455
672
  ...providerRest
@@ -465,7 +682,8 @@ function TrueForgeUIShell(props) {
465
682
  }
466
683
  const server = resolved.server;
467
684
  const layoutTree = /* @__PURE__ */ jsx2(LayoutChildren, { layout, className });
468
- return /* @__PURE__ */ jsx2(SlotsProvider, { overrides, theme, children: /* @__PURE__ */ jsx2(CustomActionRenderersProvider, { renderers: customActionRenderers, children: /* @__PURE__ */ jsx2(ServerProvider, { server, children: /* @__PURE__ */ jsxs(ShellModeProvider, { agentConfig, initialSettingsOpen, children: [
685
+ const shellTree = /* @__PURE__ */ jsxs(ShellModeProvider, { agentConfig, initialSettingsOpen, children: [
686
+ /* @__PURE__ */ jsx2(LibrarySessionShareBoot, {}),
469
687
  resolvedRoutes != null ? /* @__PURE__ */ jsx2(Suspense, { fallback: null, children: /* @__PURE__ */ jsx2(
470
688
  ShellRouteSync,
471
689
  {
@@ -484,7 +702,9 @@ function TrueForgeUIShell(props) {
484
702
  children: layoutTree
485
703
  }
486
704
  )
487
- ] }) }) }) });
705
+ ] });
706
+ const visibilityTree = layout === "widget" ? /* @__PURE__ */ jsx2(WidgetVisibilityProvider, { children: shellTree }) : shellTree;
707
+ return /* @__PURE__ */ jsx2(SlotsProvider, { overrides, theme, children: /* @__PURE__ */ jsx2(CurrentUserProvider, { currentUser, children: /* @__PURE__ */ jsx2(CustomActionRenderersProvider, { renderers: customActionRenderers, children: /* @__PURE__ */ jsx2(ServerProvider, { server, children: resolvedRoutes != null ? /* @__PURE__ */ jsx2(ResolvedRoutesProvider, { routes: resolvedRoutes, children: visibilityTree }) : visibilityTree }) }) }) });
488
708
  }
489
709
 
490
710
  export {
@@ -492,4 +712,4 @@ export {
492
712
  ServerInitLoader,
493
713
  TrueForgeUIShell
494
714
  };
495
- //# sourceMappingURL=chunk-WREC7D54.js.map
715
+ //# sourceMappingURL=chunk-PCI6VMB5.js.map