@truefoundry/trueforge-ui 0.3.0-rc.9 → 0.3.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +190 -4
  2. package/dist/{AgentCodeSnippets-ARHIK2T6.js → AgentCodeSnippets-DAZWEBJS.js} +7 -7
  3. package/dist/AgentMetricChart-VDIE3S2P.js +15 -0
  4. package/dist/AgentOverview-5JIVYXPX.js +314 -0
  5. package/dist/AgentOverview-5JIVYXPX.js.map +1 -0
  6. package/dist/{AgentSessionEventTimeline-7QM7QKIQ.js → AgentSessionEventTimeline-WELJSS6O.js} +7 -7
  7. package/dist/{AgentSessionEventTimelineChart-PIDYWLYT.js → AgentSessionEventTimelineChart-ADB3KICM.js} +7 -7
  8. package/dist/{AgentSessions-MR2DREKN.js → AgentSessions-NSN4LIGJ.js} +81 -16
  9. package/dist/AgentSessions-NSN4LIGJ.js.map +1 -0
  10. package/dist/{ConnectorSettings-YBGANZOG.js → ConnectorSettings-C6MFCKYX.js} +12 -10
  11. package/dist/ConnectorSettings-C6MFCKYX.js.map +1 -0
  12. package/dist/{DockLayout-O5TS4YZH.js → DockLayout-VY7OZ55R.js} +10 -10
  13. package/dist/{DrawerLayout-7R3XONK2.js → DrawerLayout-B2UA3CZO.js} +11 -11
  14. package/dist/{ModelSettings-UXPL4E6X.js → ModelSettings-3YAHICJ3.js} +9 -9
  15. package/dist/ModelSettings-3YAHICJ3.js.map +1 -0
  16. package/dist/OpenUiFenceBlock-BZPFNXWZ.js +9 -0
  17. package/dist/{SandboxSettings-5MMPJHBH.js → SandboxSettings-ALR6F5KU.js} +7 -7
  18. package/dist/SchedulesPage-TIS3BH67.js +15 -0
  19. package/dist/{SettingsBuilder-JAP4QGMY.js → SettingsBuilder-G5CP5X6Q.js} +8 -8
  20. package/dist/{ShellRouteSync-SJXFKUAJ.js → ShellRouteSync-G7IJ5VIW.js} +4 -4
  21. package/dist/{SidebarLayout-MYZTVWWE.js → SidebarLayout-FKRLGEDB.js} +13 -13
  22. package/dist/SidebarLayout-FKRLGEDB.js.map +1 -0
  23. package/dist/{SkillSettings-6C5PH3NN.js → SkillSettings-E5SJ4U3T.js} +7 -7
  24. package/dist/{TrueForgeUIWithRouter-3J5G62O5.js → TrueForgeUIWithRouter-WD7O3TWR.js} +9 -9
  25. package/dist/{WidgetLayout-24ZL3QWT.js → WidgetLayout-KQZTQNE7.js} +10 -10
  26. package/dist/{chunk-UBQYRCCH.js → chunk-2XFOONKH.js} +251 -97
  27. package/dist/chunk-2XFOONKH.js.map +1 -0
  28. package/dist/{chunk-2GIZY3JJ.js → chunk-2XT2VUT4.js} +58 -5
  29. package/dist/chunk-2XT2VUT4.js.map +1 -0
  30. package/dist/{chunk-3ZW74FHC.js → chunk-4OZFQVSR.js} +23 -19
  31. package/dist/chunk-4OZFQVSR.js.map +1 -0
  32. package/dist/chunk-6UACSIIY.js +587 -0
  33. package/dist/chunk-6UACSIIY.js.map +1 -0
  34. package/dist/{chunk-RI6TIYWL.js → chunk-7UE7LZS2.js} +45 -15
  35. package/dist/chunk-7UE7LZS2.js.map +1 -0
  36. package/dist/{chunk-T6QQV5LK.js → chunk-AO23SZBG.js} +2 -2
  37. package/dist/{chunk-MACHU4OO.js → chunk-AU4BJQMK.js} +60 -25
  38. package/dist/chunk-AU4BJQMK.js.map +1 -0
  39. package/dist/{chunk-2QTH6JHX.js → chunk-B76JC5B2.js} +3 -3
  40. package/dist/{chunk-JTQU2N2Q.js → chunk-G7BT4OKG.js} +7 -5
  41. package/dist/{chunk-JTQU2N2Q.js.map → chunk-G7BT4OKG.js.map} +1 -1
  42. package/dist/{chunk-JF4IELMW.js → chunk-IGYCJIU7.js} +9 -9
  43. package/dist/{chunk-CG75X77Q.js → chunk-QKFMAQ7O.js} +2 -2
  44. package/dist/{chunk-JKUYG6HV.js → chunk-SAYUMANU.js} +9 -15
  45. package/dist/chunk-SAYUMANU.js.map +1 -0
  46. package/dist/{chunk-FEHL45EB.js → chunk-XHPIJ77Q.js} +2 -2
  47. package/dist/{chunk-4OEAJKLJ.js → chunk-XR4S7B2K.js} +2528 -1923
  48. package/dist/chunk-XR4S7B2K.js.map +1 -0
  49. package/dist/index.d.ts +53 -11
  50. package/dist/index.js +16 -12
  51. package/dist/index.js.map +1 -1
  52. package/dist/plugins/trueforge-agent-server-adapter/index.d.ts +10 -3
  53. package/dist/plugins/trueforge-agent-server-adapter/index.js +43 -14
  54. package/dist/plugins/trueforge-agent-server-adapter/index.js.map +1 -1
  55. package/dist/styles.css +1 -1
  56. package/package.json +3 -3
  57. package/dist/AgentMetricChart-ZQIRBCZL.js +0 -15
  58. package/dist/AgentOverview-7GJJV2OU.js +0 -169
  59. package/dist/AgentOverview-7GJJV2OU.js.map +0 -1
  60. package/dist/AgentSessions-MR2DREKN.js.map +0 -1
  61. package/dist/ConnectorSettings-YBGANZOG.js.map +0 -1
  62. package/dist/ModelSettings-UXPL4E6X.js.map +0 -1
  63. package/dist/OpenUiFenceBlock-KPZFLUSC.js +0 -9
  64. package/dist/SchedulesPage-5XZRDA5O.js +0 -15
  65. package/dist/SidebarLayout-MYZTVWWE.js.map +0 -1
  66. package/dist/chunk-2GIZY3JJ.js.map +0 -1
  67. package/dist/chunk-3ZW74FHC.js.map +0 -1
  68. package/dist/chunk-4OEAJKLJ.js.map +0 -1
  69. package/dist/chunk-JCL3Q7RW.js +0 -587
  70. package/dist/chunk-JCL3Q7RW.js.map +0 -1
  71. package/dist/chunk-JKUYG6HV.js.map +0 -1
  72. package/dist/chunk-MACHU4OO.js.map +0 -1
  73. package/dist/chunk-RI6TIYWL.js.map +0 -1
  74. package/dist/chunk-UBQYRCCH.js.map +0 -1
  75. /package/dist/{AgentCodeSnippets-ARHIK2T6.js.map → AgentCodeSnippets-DAZWEBJS.js.map} +0 -0
  76. /package/dist/{AgentMetricChart-ZQIRBCZL.js.map → AgentMetricChart-VDIE3S2P.js.map} +0 -0
  77. /package/dist/{AgentSessionEventTimeline-7QM7QKIQ.js.map → AgentSessionEventTimeline-WELJSS6O.js.map} +0 -0
  78. /package/dist/{AgentSessionEventTimelineChart-PIDYWLYT.js.map → AgentSessionEventTimelineChart-ADB3KICM.js.map} +0 -0
  79. /package/dist/{DockLayout-O5TS4YZH.js.map → DockLayout-VY7OZ55R.js.map} +0 -0
  80. /package/dist/{DrawerLayout-7R3XONK2.js.map → DrawerLayout-B2UA3CZO.js.map} +0 -0
  81. /package/dist/{OpenUiFenceBlock-KPZFLUSC.js.map → OpenUiFenceBlock-BZPFNXWZ.js.map} +0 -0
  82. /package/dist/{SandboxSettings-5MMPJHBH.js.map → SandboxSettings-ALR6F5KU.js.map} +0 -0
  83. /package/dist/{SchedulesPage-5XZRDA5O.js.map → SchedulesPage-TIS3BH67.js.map} +0 -0
  84. /package/dist/{SettingsBuilder-JAP4QGMY.js.map → SettingsBuilder-G5CP5X6Q.js.map} +0 -0
  85. /package/dist/{ShellRouteSync-SJXFKUAJ.js.map → ShellRouteSync-G7IJ5VIW.js.map} +0 -0
  86. /package/dist/{SkillSettings-6C5PH3NN.js.map → SkillSettings-E5SJ4U3T.js.map} +0 -0
  87. /package/dist/{TrueForgeUIWithRouter-3J5G62O5.js.map → TrueForgeUIWithRouter-WD7O3TWR.js.map} +0 -0
  88. /package/dist/{WidgetLayout-24ZL3QWT.js.map → WidgetLayout-KQZTQNE7.js.map} +0 -0
  89. /package/dist/{chunk-T6QQV5LK.js.map → chunk-AO23SZBG.js.map} +0 -0
  90. /package/dist/{chunk-2QTH6JHX.js.map → chunk-B76JC5B2.js.map} +0 -0
  91. /package/dist/{chunk-JF4IELMW.js.map → chunk-IGYCJIU7.js.map} +0 -0
  92. /package/dist/{chunk-CG75X77Q.js.map → chunk-QKFMAQ7O.js.map} +0 -0
  93. /package/dist/{chunk-FEHL45EB.js.map → chunk-XHPIJ77Q.js.map} +0 -0
@@ -21,13 +21,14 @@ import {
21
21
  ToasterProvider,
22
22
  modelPatchWithReasoningEffort,
23
23
  mountName,
24
+ preloadMonaco,
24
25
  useThemeMode,
25
26
  useToaster
26
- } from "./chunk-4OEAJKLJ.js";
27
+ } from "./chunk-XR4S7B2K.js";
27
28
  import {
28
29
  DraftCatalogProvider,
29
30
  useDraftCatalog
30
- } from "./chunk-3ZW74FHC.js";
31
+ } from "./chunk-4OZFQVSR.js";
31
32
  import {
32
33
  DEFAULT_AGENT_CONFIG,
33
34
  ServerProvider,
@@ -39,15 +40,16 @@ import {
39
40
  useOptionalShellMode,
40
41
  useServerCapabilities,
41
42
  useShellMode,
42
- withCapabilitiesSandbox
43
- } from "./chunk-2GIZY3JJ.js";
43
+ withCapabilitiesSandbox,
44
+ withCapabilitiesWebSearch
45
+ } from "./chunk-2XT2VUT4.js";
44
46
  import {
45
47
  useAui,
46
48
  useAuiState
47
49
  } from "./chunk-M6MHLVSO.js";
48
50
  import {
49
51
  cn
50
- } from "./chunk-JCL3Q7RW.js";
52
+ } from "./chunk-6UACSIIY.js";
51
53
 
52
54
  // src/containers/TrueFoundryChatProvider.tsx
53
55
  import { AssistantRuntimeProvider, useAuiState as useAuiState2 } from "@assistant-ui/react";
@@ -150,7 +152,7 @@ function TrueFoundryChatProvider(props) {
150
152
  }
151
153
 
152
154
  // src/containers/TrueForgeUIShell.tsx
153
- import { lazy, Suspense, useCallback as useCallback2, useMemo as useMemo2, useState as useState2 } from "react";
155
+ import { lazy, Suspense, useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useState as useState2 } from "react";
154
156
  import { ThinkingOrb } from "thinking-orbs";
155
157
 
156
158
  // src/atoms/draft/DraftSpecPreferenceBridge.tsx
@@ -235,15 +237,26 @@ function reconcileDraftSandbox({
235
237
  const nextSpec = withCapabilitiesSandbox(agentSpec, sandboxEnabled);
236
238
  return nextSpec === agentSpec ? {} : { config: nextSpec.config };
237
239
  }
240
+ function reconcileDraftWebSearch({
241
+ agentSpec,
242
+ webSearchEnabled,
243
+ kind = "agent"
244
+ }) {
245
+ const nextSpec = withCapabilitiesWebSearch({ spec: agentSpec, webSearchEnabled, kind });
246
+ return nextSpec === agentSpec ? {} : { config: nextSpec.config };
247
+ }
238
248
  function DraftSpecPreferenceBridge() {
239
249
  const { mode, pendingSessionId, rememberDraftSpec } = useShellMode();
240
250
  const { agentSpec } = useTrueFoundryAgentSpec();
241
251
  const updateAgentSpec = useTrueFoundryUpdateAgentSpec();
242
252
  const capabilities = useServerCapabilities();
243
253
  const sandboxEnabled = capabilities?.sandbox.enabled;
254
+ const webSearchEnabled = capabilities?.webSearch?.enabled;
244
255
  const { models, skills, connectors, loaded, error, ensureLoaded } = useDraftCatalog();
245
- const isPlainDraft = mode.status === "active" && mode.isMutable && mode.agentId == null && pendingSessionId == null;
256
+ const isMutableDraft = mode.status === "active" && mode.isMutable && pendingSessionId == null;
257
+ const isPlainDraft = isMutableDraft && mode.agentId == null;
246
258
  const preferenceKind = mode.status === "active" && mode.isMutable && mode.isCreateAgent ? "agent" : "chat";
259
+ const webSearchKind = mode.status === "active" && mode.isMutable && (mode.isCreateAgent || mode.agentId != null) ? "agent" : "chat";
247
260
  useEffect(() => {
248
261
  if (isPlainDraft) ensureLoaded();
249
262
  }, [ensureLoaded, isPlainDraft]);
@@ -259,6 +272,13 @@ function DraftSpecPreferenceBridge() {
259
272
  updateAgentSpec(update);
260
273
  }
261
274
  }, [agentSpec, isPlainDraft, preferenceKind, sandboxEnabled, updateAgentSpec]);
275
+ useEffect(() => {
276
+ if (!isMutableDraft || agentSpec == null || updateAgentSpec == null) return;
277
+ const update = reconcileDraftWebSearch({ agentSpec, webSearchEnabled, kind: webSearchKind });
278
+ if (Object.keys(update).length > 0) {
279
+ updateAgentSpec(update);
280
+ }
281
+ }, [agentSpec, isMutableDraft, webSearchEnabled, webSearchKind, updateAgentSpec]);
262
282
  useEffect(() => {
263
283
  if (!isPlainDraft || agentSpec == null || updateAgentSpec == null || !loaded || error != null) return;
264
284
  const update = reconcileDraftSpecPreferences({
@@ -342,7 +362,7 @@ function withSessionListCache({
342
362
  server,
343
363
  cache
344
364
  }) {
345
- const { deleteSession } = server;
365
+ const { deleteSession, renameSession } = server;
346
366
  return {
347
367
  ...server,
348
368
  listSessions(request) {
@@ -372,6 +392,12 @@ function withSessionListCache({
372
392
  await deleteSession.call(server, request);
373
393
  cache.clear();
374
394
  }
395
+ } : {},
396
+ ...renameSession != null ? {
397
+ renameSession: async (request) => {
398
+ await renameSession.call(server, request);
399
+ cache.clear();
400
+ }
375
401
  } : {}
376
402
  };
377
403
  }
@@ -383,7 +409,8 @@ var DEFAULT_CAPABILITIES = {
383
409
  data: {
384
410
  sandbox: { enabled: true },
385
411
  skill: { enabled: true },
386
- settings: { enabled: true }
412
+ settings: { enabled: true },
413
+ webSearch: { enabled: false }
387
414
  }
388
415
  };
389
416
  function isBuiltInConfig(config) {
@@ -489,11 +516,11 @@ function useResolvedServer(config, onError) {
489
516
 
490
517
  // src/containers/TrueForgeUIShell.tsx
491
518
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
492
- var SidebarLayout = lazy(() => import("./SidebarLayout-MYZTVWWE.js").then((m) => ({ default: m.SidebarLayout })));
493
- var DrawerLayout = lazy(() => import("./DrawerLayout-7R3XONK2.js").then((m) => ({ default: m.DrawerLayout })));
494
- var DockLayout = lazy(() => import("./DockLayout-O5TS4YZH.js").then((m) => ({ default: m.DockLayout })));
495
- var WidgetLayout = lazy(() => import("./WidgetLayout-24ZL3QWT.js").then((m) => ({ default: m.WidgetLayout })));
496
- var ShellRouteSync = lazy(() => import("./ShellRouteSync-SJXFKUAJ.js").then((m) => ({ default: m.ShellRouteSync })));
519
+ var SidebarLayout = lazy(() => import("./SidebarLayout-FKRLGEDB.js").then((m) => ({ default: m.SidebarLayout })));
520
+ var DrawerLayout = lazy(() => import("./DrawerLayout-B2UA3CZO.js").then((m) => ({ default: m.DrawerLayout })));
521
+ var DockLayout = lazy(() => import("./DockLayout-VY7OZ55R.js").then((m) => ({ default: m.DockLayout })));
522
+ var WidgetLayout = lazy(() => import("./WidgetLayout-KQZTQNE7.js").then((m) => ({ default: m.WidgetLayout })));
523
+ var ShellRouteSync = lazy(() => import("./ShellRouteSync-G7IJ5VIW.js").then((m) => ({ default: m.ShellRouteSync })));
497
524
  function LayoutFallback({ className }) {
498
525
  return /* @__PURE__ */ jsx2(
499
526
  "div",
@@ -674,6 +701,9 @@ function TrueForgeUIShell(props) {
674
701
  const resolved = useResolvedServer(serverConfig, onError);
675
702
  const [activeRemoteId, setActiveRemoteId] = useState2(void 0);
676
703
  const handleRemoteIdChange = useCallback2((id) => setActiveRemoteId(id), []);
704
+ useEffect6(() => {
705
+ void preloadMonaco();
706
+ }, []);
677
707
  if (resolved.status === "loading") {
678
708
  return /* @__PURE__ */ jsx2(SlotsProvider, { overrides, theme, children: /* @__PURE__ */ jsx2(ServerInitLoader, { className }) });
679
709
  }
@@ -712,4 +742,4 @@ export {
712
742
  ServerInitLoader,
713
743
  TrueForgeUIShell
714
744
  };
715
- //# sourceMappingURL=chunk-RI6TIYWL.js.map
745
+ //# sourceMappingURL=chunk-7UE7LZS2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/containers/TrueFoundryChatProvider.tsx","../src/containers/TrueForgeUIShell.tsx","../src/atoms/draft/DraftSpecPreferenceBridge.tsx","../src/routing/HistorySessionSwitchBridge.tsx","../src/routing/LibrarySessionShareBoot.tsx","../src/routing/RemoteIdRouteBridge.tsx","../src/server/sessionListCache.ts","../src/containers/useResolvedServer.ts"],"sourcesContent":["'use client';\n\nimport { AssistantRuntimeProvider, useAuiState } from '@assistant-ui/react';\nimport {\n trueFoundryAttachmentAdapter,\n useTrueFoundryAgentRuntime,\n type TrueFoundryAgentConfig,\n type UseTrueFoundryAgentRuntimeOptions,\n} from '@truefoundry/assistant-ui-runtime';\nimport { useCallback, useMemo, type ReactNode } from 'react';\n\nimport { sessionIsCreateAgent } from '../atoms/lib/sessionCreateAgent.js';\nimport { notifyComposerBusyFailure } from '../hooks/useComposerBusyState.js';\nimport { ActiveSessionPermissionsProvider } from '../hooks/useResourcePermissions.js';\nimport type { AgentUIServer } from '../server/types.js';\nimport { ToasterProvider, useToaster } from './ToasterContainer.js';\n\ntype RuntimeAdapters = NonNullable<UseTrueFoundryAgentRuntimeOptions['adapters']>;\n\nfunction ActiveSessionPermissionScope({\n locallyCreatedSessionIds,\n children,\n}: {\n locallyCreatedSessionIds: ReadonlySet<string>;\n children: ReactNode;\n}) {\n const remoteId = useAuiState(state => state.threadListItem.remoteId);\n return (\n <ActiveSessionPermissionsProvider\n sessionId={remoteId}\n assumeManage={remoteId != null && locallyCreatedSessionIds.has(remoteId)}\n >\n {children}\n </ActiveSessionPermissionsProvider>\n );\n}\n\nfunction runtimeServer({\n server,\n locallyCreatedSessionIds,\n}: {\n server: AgentUIServer;\n locallyCreatedSessionIds: Set<string>;\n}): AgentUIServer {\n return {\n ...server,\n async createSession(request) {\n const session = await server.createSession(request);\n locallyCreatedSessionIds.add(session.id);\n return session;\n },\n async listSessions(request) {\n const result = await server.listSessions(request);\n return {\n ...result,\n data: result.data.filter(session => !sessionIsCreateAgent(session)),\n };\n },\n };\n}\n\nexport type TrueFoundryChatProviderProps = {\n server: AgentUIServer;\n initialSessionId?: string;\n adapters?: RuntimeAdapters;\n onError?: (error: unknown) => void;\n children: ReactNode;\n /** Discriminated agent source. Prefer over legacy `agentName`. */\n agent?: TrueFoundryAgentConfig;\n /** Legacy named-agent shorthand. Prefer `agent: { mode: \"named\", agentName }`. */\n agentName?: string;\n /** Forwarded to `listSessions({ agentId })` for history filtering. */\n listSessionsAgentId?: string;\n};\n\nfunction ChatRuntimeScope({\n server,\n agent,\n agentName,\n listSessionsAgentId,\n initialSessionId,\n adapters,\n onError,\n children,\n}: {\n server: AgentUIServer;\n agent?: TrueFoundryAgentConfig;\n agentName?: string;\n listSessionsAgentId?: string;\n initialSessionId?: string;\n adapters?: RuntimeAdapters;\n onError?: (error: unknown) => void;\n children: ReactNode;\n}) {\n const { showError } = useToaster();\n const reportError = onError ?? showError;\n const localSessionState = useMemo(() => ({ server, ids: new Set<string>() }), [server]);\n const locallyCreatedSessionIds = localSessionState.ids;\n const historyServer = useMemo(\n () => runtimeServer({ server, locallyCreatedSessionIds }),\n [locallyCreatedSessionIds, server],\n );\n // composer().send() is void and swallows onNew rejections; clear optimistic\n // busy when the runtime reports a pre-stream failure (e.g. createSession).\n const resolvedOnError = useCallback(\n (error: unknown) => {\n notifyComposerBusyFailure();\n reportError(error);\n },\n [reportError],\n );\n\n const runtime = useTrueFoundryAgentRuntime({\n server: historyServer as never,\n agent,\n agentName,\n listSessionsAgentId,\n listSessionsCreatedByMe: true,\n initialSessionId,\n onError: resolvedOnError,\n adapters: {\n ...adapters,\n attachments: adapters?.attachments ?? trueFoundryAttachmentAdapter,\n },\n });\n\n return (\n <AssistantRuntimeProvider runtime={runtime as never}>\n <ActiveSessionPermissionScope locallyCreatedSessionIds={locallyCreatedSessionIds}>\n {children}\n </ActiveSessionPermissionScope>\n </AssistantRuntimeProvider>\n );\n}\n\n/**\n * Chat shell: wires `useTrueFoundryAgentRuntime` from `server` and provides\n * assistant-ui + error toasts.\n */\nexport function TrueFoundryChatProvider(props: TrueFoundryChatProviderProps) {\n const { server, initialSessionId, adapters, onError, children, agent, agentName, listSessionsAgentId } = props;\n\n const stableServer = useMemo(() => server, [server]);\n\n return (\n <ToasterProvider>\n <ChatRuntimeScope\n server={stableServer}\n agent={agent}\n agentName={agentName}\n listSessionsAgentId={listSessionsAgentId}\n initialSessionId={initialSessionId}\n adapters={adapters}\n onError={onError}\n >\n {children}\n </ChatRuntimeScope>\n </ToasterProvider>\n );\n}\n","'use client';\n\nimport type { TrueFoundryAgentConfig, UseTrueFoundryAgentRuntimeOptions } from '@truefoundry/assistant-ui-runtime';\nimport { lazy, Suspense, useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';\nimport { ThinkingOrb } from 'thinking-orbs';\n\nimport { AgentConfigInstructionsProvider } from '../atoms/draft/AgentConfigInstructionsContext.js';\nimport { DraftCatalogProvider } from '../atoms/draft/DraftCatalogProvider.js';\nimport { DraftSpecPreferenceBridge } from '../atoms/draft/DraftSpecPreferenceBridge.js';\nimport { cn } from '../atoms/lib/cn.js';\nimport { IS_CREATE_AGENT_METADATA_KEY, isCreateAgentMetadataValue } from '../atoms/lib/sessionCreateAgent.js';\nimport { preloadMonaco } from '../atoms/monacoPreload.js';\nimport { CurrentUserProvider, type CurrentUser } from '../contexts/CurrentUserContext.js';\nimport { WidgetVisibilityProvider } from '../layouts/WidgetVisibilityContext.js';\nimport { HistorySessionSwitchBridge } from '../routing/HistorySessionSwitchBridge.js';\nimport { LibrarySessionShareBoot } from '../routing/LibrarySessionShareBoot.js';\nimport { RemoteIdRouteBridge } from '../routing/RemoteIdRouteBridge.js';\nimport { ResolvedRoutesProvider } from '../routing/ResolvedRoutesContext.js';\nimport type { ResolvedRoutes, RoutesConfig } from '../routing/types.js';\nimport { CustomActionRenderersProvider, type CustomActionRenderers } from '../server/CustomActionRenderersContext.js';\nimport { ServerProvider } from '../server/ServerContext.js';\nimport { createSessionListCache, withSessionListCache } from '../server/sessionListCache.js';\nimport { DEFAULT_AGENT_CONFIG, ShellModeProvider, useShellMode, type AgentConfig } from '../server/ShellModeContext.js';\nimport type { TrueForgeServerConfig } from '../server/TrueForgeServerConfig.js';\nimport type { AgentUIServer, CreateSessionRequest } from '../server/types.js';\nimport { SlotsProvider, useThemeMode, type SlotOverrides } from '../theme/SlotsProvider.js';\nimport type { LayoutProp, ThemeConfig } from '../theme/types.js';\nimport { getErrorMessage } from '../utils/getErrorMessage.js';\nimport { TrueFoundryChatProvider, type TrueFoundryChatProviderProps } from './TrueFoundryChatProvider.js';\nimport { useResolvedServer } from './useResolvedServer.js';\n\nconst SidebarLayout = lazy(() => import('../layouts/SidebarLayout.js').then(m => ({ default: m.SidebarLayout })));\nconst DrawerLayout = lazy(() => import('../layouts/DrawerLayout.js').then(m => ({ default: m.DrawerLayout })));\nconst DockLayout = lazy(() => import('../layouts/DockLayout.js').then(m => ({ default: m.DockLayout })));\nconst WidgetLayout = lazy(() => import('../layouts/WidgetLayout.js').then(m => ({ default: m.WidgetLayout })));\nconst ShellRouteSync = lazy(() => import('../routing/ShellRouteSync.js').then(m => ({ default: m.ShellRouteSync })));\n\nexport type ChatLayout = 'sidebar' | 'drawer' | 'dock' | 'widget';\n\ntype RuntimeAdapters = NonNullable<UseTrueFoundryAgentRuntimeOptions['adapters']>;\n\nexport type TrueForgeUIProps = {\n server: TrueForgeServerConfig;\n /** Built-in layout string or a custom layout component. Defaults to `\"sidebar\"`. */\n layout?: LayoutProp;\n overrides?: SlotOverrides;\n theme?: ThemeConfig;\n className?: string;\n initialSessionId?: string;\n adapters?: RuntimeAdapters;\n onError?: (error: unknown) => void;\n /**\n * Agent / library / composer shell mode.\n * Defaults to `{ mode: \"AgentLibraryWithComposer\" }`.\n */\n agentConfig?: AgentConfig;\n /** Open settings on first paint only (host boot with no models configured). */\n initialSettingsOpen?: boolean;\n /**\n * Host UI for pending client-side tools, keyed by tool name.\n * When a pending tool matches, the composer mounts that component instead of Ask User.\n */\n customActionRenderers?: CustomActionRenderers;\n /**\n * Sync shell navigation to the browser URL via react-router (opt-in).\n * Requires `react-router-dom` in the host. Leave off for dock/widget embeds\n * and hosts that own their own router. Defaults to `false`.\n */\n withRouter?: boolean;\n /** URL path customization; only honored when `withRouter`. */\n routes?: RoutesConfig;\n /** Optional identity rendered by the default `UserAvatar` slot. */\n currentUser?: CurrentUser;\n};\n\nexport type TrueForgeUIShellProps = Omit<TrueForgeUIProps, 'withRouter'> & { resolvedRoutes?: ResolvedRoutes };\n\nfunction LayoutFallback({ className }: { className?: string }) {\n return (\n <div\n className={className}\n style={{\n height: '100%',\n minHeight: '12rem',\n background:\n '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%)',\n backgroundSize: '200% 100%',\n animation: 'tfy-aui-pulse 1.2s ease-in-out infinite',\n }}\n aria-hidden\n />\n );\n}\n\n/** Shown while `type: \"truefoundry\"` resolves the agent UI server. */\nexport function ServerInitLoader({ className }: { className?: string }) {\n // Outside ThemeProvider (Suspense), useThemeMode falls back to light.\n const themeMode = useThemeMode();\n return (\n <div\n role=\"status\"\n aria-label=\"Loading\"\n aria-live=\"polite\"\n aria-busy=\"true\"\n className={cn(\n 'flex h-full min-h-48 w-full flex-1 items-center justify-center bg-primary-bg text-text-secondary',\n className,\n )}\n >\n <ThinkingOrb\n state=\"connecting\"\n speed={1}\n theme={themeMode}\n paused={false}\n aria-hidden\n size={64}\n style={{ width: '4.5rem', height: '4.5rem' }}\n />\n </div>\n );\n}\n\nfunction ServerInitError({ error, className }: { error: unknown; className?: string }) {\n const message = getErrorMessage(error, 'Failed to initialize server');\n return (\n <div\n role=\"alert\"\n className={cn(\n 'flex h-full min-h-48 items-center justify-center bg-primary-bg px-6 text-center text-sm text-failure-bg',\n className,\n )}\n >\n {message}\n </div>\n );\n}\n\nfunction isBuiltInLayout(layout: LayoutProp): layout is ChatLayout {\n return layout === 'sidebar' || layout === 'drawer' || layout === 'dock' || layout === 'widget';\n}\n\nfunction BuiltInLayoutView({ layout, className }: { layout: ChatLayout; className?: string }) {\n switch (layout) {\n case 'sidebar':\n return <SidebarLayout className={className} />;\n case 'drawer':\n return <DrawerLayout className={className} />;\n case 'dock':\n return <DockLayout className={className} />;\n case 'widget':\n return <WidgetLayout className={className} />;\n }\n}\n\nfunction LayoutChildren({ layout, className }: { layout: LayoutProp; className?: string }) {\n if (isBuiltInLayout(layout)) {\n return (\n <Suspense fallback={<LayoutFallback className={className} />}>\n <BuiltInLayoutView layout={layout} className={className} />\n </Suspense>\n );\n }\n const HostLayout = layout;\n return <HostLayout className={className} />;\n}\n\nfunction ChatProviderFromShell({\n children,\n initialSessionId: hostInitialSessionId,\n onRemoteIdChange,\n server,\n ...providerRest\n}: {\n children: ReactNode;\n /** When routing, reports the active thread's remote id up to `ShellRouteSync`. */\n onRemoteIdChange?: (id: string | undefined) => void;\n} & Omit<TrueFoundryChatProviderProps, 'agent' | 'agentName' | 'listSessionsAgentId' | 'children'>) {\n const { mode, runtimeKey, historyAgentFilter, listSessionsAgentId, pendingSessionId } = useShellMode();\n\n const isCreateAgent = mode.status === 'active' && mode.isMutable && mode.isCreateAgent;\n\n // Keep one isolated cache per shell, preserved across chat runtime remounts.\n const [sessionListCache] = useState(createSessionListCache);\n\n const serverWithCreateIntent = useMemo((): AgentUIServer => {\n return {\n ...server,\n createSession: request => {\n if (request.agentSpec === undefined) {\n return server.createSession(request);\n }\n const withMetadata: CreateSessionRequest & { metadata: Record<string, string> } = {\n ...request,\n metadata: {\n [IS_CREATE_AGENT_METADATA_KEY]: isCreateAgentMetadataValue(isCreateAgent),\n },\n };\n return server.createSession(withMetadata);\n },\n };\n }, [server, isCreateAgent]);\n\n const cachedRuntimeServer = useMemo(\n () => withSessionListCache({ server: serverWithCreateIntent, cache: sessionListCache }),\n [serverWithCreateIntent, sessionListCache],\n );\n const runtimeServer = useMemo<AgentUIServer>(() => {\n if (historyAgentFilter == null || historyAgentFilter.agentId != null) return cachedRuntimeServer;\n // Do not expose an unfiltered page under a filter label while its backend id resolves.\n return { ...cachedRuntimeServer, listSessions: async () => ({ data: [] }) };\n }, [cachedRuntimeServer, historyAgentFilter]);\n\n // Freeze draft seed for the life of this runtimeKey so bindMutableAgent (identity /\n // instructions on shell) does not push a new defaultAgentSpec into the runtime.\n const draftDefaultAgentSpec = useMemo(() => {\n if (mode.status === 'active' && mode.isMutable) {\n return mode.agentSpec ?? { model: { name: 'openai-main/gpt-4.1' } };\n }\n return { model: { name: 'openai-main/gpt-4.1' } };\n // runtimeKey is the remount boundary for mutable chats.\n // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally keyed on runtimeKey only\n }, [runtimeKey]);\n\n const agent: TrueFoundryAgentConfig = useMemo(() => {\n // idle uses a placeholder draft so layout chrome (useAui) still mounts;\n // layouts render an empty CTA instead of the thread.\n if (mode.status === 'idle') {\n return {\n mode: 'draft',\n defaultAgentSpec: { model: { name: 'openai-main/gpt-4.1' } },\n };\n }\n // Runtime still uses named|draft; shell mutability maps onto that adapter.\n if (!mode.isMutable) {\n const agentName = mode.agentName ?? mode.agentId ?? pendingSessionId;\n if (agentName == null) {\n // Active immutable without identity should not happen; keep chrome mounted.\n return {\n mode: 'draft',\n defaultAgentSpec: { model: { name: 'openai-main/gpt-4.1' } },\n };\n }\n return { mode: 'named', agentName };\n }\n return {\n mode: 'draft',\n defaultAgentSpec: draftDefaultAgentSpec,\n };\n }, [mode, draftDefaultAgentSpec, pendingSessionId]);\n\n return (\n <DraftCatalogProvider>\n <TrueFoundryChatProvider\n key={runtimeKey}\n {...providerRest}\n server={runtimeServer}\n agent={agent}\n listSessionsAgentId={listSessionsAgentId}\n initialSessionId={pendingSessionId ?? hostInitialSessionId}\n >\n <AgentConfigInstructionsProvider>\n <DraftSpecPreferenceBridge />\n <HistorySessionSwitchBridge />\n {onRemoteIdChange != null ? <RemoteIdRouteBridge onRemoteIdChange={onRemoteIdChange} /> : null}\n {children}\n </AgentConfigInstructionsProvider>\n </TrueFoundryChatProvider>\n </DraftCatalogProvider>\n );\n}\n\n/** Internal shell. `resolvedRoutes` present iff mounted under `TrueForgeUIWithRouter`. */\nexport function TrueForgeUIShell(props: TrueForgeUIShellProps) {\n const {\n layout = 'sidebar',\n overrides,\n theme,\n className,\n agentConfig = DEFAULT_AGENT_CONFIG,\n initialSettingsOpen = false,\n server: serverConfig,\n onError,\n customActionRenderers,\n currentUser,\n resolvedRoutes,\n routes: _routes,\n ...providerRest\n } = props;\n\n const resolved = useResolvedServer(serverConfig, onError);\n const [activeRemoteId, setActiveRemoteId] = useState<string | undefined>(undefined);\n const handleRemoteIdChange = useCallback((id: string | undefined) => setActiveRemoteId(id), []);\n\n // Warm Monaco while the shell boots so tool request/response cards paint faster.\n useEffect(() => {\n void preloadMonaco();\n }, []);\n\n if (resolved.status === 'loading') {\n return (\n <SlotsProvider overrides={overrides} theme={theme}>\n <ServerInitLoader className={className} />\n </SlotsProvider>\n );\n }\n\n if (resolved.status === 'error') {\n return (\n <SlotsProvider overrides={overrides} theme={theme}>\n <ServerInitError error={resolved.error} className={className} />\n </SlotsProvider>\n );\n }\n\n const server = resolved.server;\n const layoutTree = <LayoutChildren layout={layout} className={className} />;\n\n const shellTree = (\n <ShellModeProvider agentConfig={agentConfig} initialSettingsOpen={initialSettingsOpen}>\n <LibrarySessionShareBoot />\n {resolvedRoutes != null ? (\n <Suspense fallback={null}>\n <ShellRouteSync\n routes={resolvedRoutes}\n activeRemoteId={activeRemoteId}\n initialSettingsOpen={initialSettingsOpen}\n />\n </Suspense>\n ) : null}\n <ChatProviderFromShell\n server={server}\n onError={onError}\n onRemoteIdChange={resolvedRoutes != null ? handleRemoteIdChange : undefined}\n {...providerRest}\n >\n {layoutTree}\n </ChatProviderFromShell>\n </ShellModeProvider>\n );\n // Widget visibility provider is used to control the visibility of the widget with isolated state\n const visibilityTree =\n layout === 'widget' ? <WidgetVisibilityProvider>{shellTree}</WidgetVisibilityProvider> : shellTree;\n\n return (\n <SlotsProvider overrides={overrides} theme={theme}>\n <CurrentUserProvider currentUser={currentUser}>\n <CustomActionRenderersProvider renderers={customActionRenderers}>\n <ServerProvider server={server}>\n {resolvedRoutes != null ? (\n <ResolvedRoutesProvider routes={resolvedRoutes}>{visibilityTree}</ResolvedRoutesProvider>\n ) : (\n visibilityTree\n )}\n </ServerProvider>\n </CustomActionRenderersProvider>\n </CurrentUserProvider>\n </SlotsProvider>\n );\n}\n","'use client';\n\nimport { useTrueFoundryAgentSpec, useTrueFoundryUpdateAgentSpec } from '@truefoundry/assistant-ui-runtime';\nimport { useEffect } from 'react';\n\nimport {\n type DraftPreferenceKind,\n withCapabilitiesSandbox,\n withCapabilitiesWebSearch,\n} from '../../server/draftSpecPreferences.js';\nimport { useServerCapabilities } from '../../server/ServerContext.js';\nimport { useShellMode } from '../../server/ShellModeContext.js';\nimport type { AgentSkill, AgentSpec, ConnectorState, ModelSelection } from '../../server/types.js';\nimport { mountName } from '../lib/mountName.js';\nimport { useDraftCatalog } from './DraftCatalogProvider.js';\nimport { modelPatchWithReasoningEffort } from './reasoningEffort.js';\n\nfunction readDraftSandboxEnabled(spec: AgentSpec): boolean | undefined {\n if (spec.config === undefined) return undefined;\n // `sandbox` is draft runtime config and may be absent from AgentRuntimeConfig typings.\n const sandbox = Reflect.get(spec.config, 'sandbox');\n if (typeof sandbox !== 'object' || sandbox === null) return undefined;\n const enabled = Reflect.get(sandbox, 'enabled');\n return typeof enabled === 'boolean' ? enabled : undefined;\n}\n\nfunction filterMounts<T extends object>(mounts: T[] | undefined, availableNames: Set<string>): T[] | undefined {\n if (mounts === undefined) return undefined;\n const filtered = mounts.filter(mount => {\n const name = mountName(mount);\n return name !== null && availableNames.has(name);\n });\n return filtered.length === mounts.length ? mounts : filtered;\n}\n\nexport function reconcileDraftSpecPreferences({\n agentSpec,\n models,\n skills,\n connectors,\n skillsEnabled,\n}: {\n agentSpec: AgentSpec;\n models: ModelSelection[];\n skills: AgentSkill[];\n connectors: ConnectorState[];\n skillsEnabled: boolean | undefined;\n}): Partial<AgentSpec> {\n const update: Partial<AgentSpec> = {};\n const selectedModel = agentSpec.model.name.trim();\n if (!models.some(model => model.name === selectedModel)) {\n const fallback = models[0];\n if (fallback !== undefined) {\n update.model = modelPatchWithReasoningEffort(\n fallback.name,\n agentSpec.model.params,\n fallback.properties.reasoningEfforts,\n );\n }\n }\n\n const nextMcpServers = filterMounts(agentSpec.mcpServers, new Set(connectors.map(connector => connector.name)));\n if (nextMcpServers !== agentSpec.mcpServers) {\n update.mcpServers = nextMcpServers;\n }\n\n if (skillsEnabled === false) {\n // Only clear when there is something to clear — a fresh `[]` each call would\n // fail reference equality and loop `updateAgentSpec` forever.\n if (agentSpec.skills !== undefined && agentSpec.skills.length > 0) {\n update.skills = [];\n }\n } else {\n const nextSkills = filterMounts(agentSpec.skills, new Set(skills.map(skill => skill.name)));\n if (nextSkills !== agentSpec.skills) {\n update.skills = nextSkills;\n }\n }\n\n return update;\n}\n\nexport function reconcileDraftSandbox({\n agentSpec,\n sandboxEnabled,\n kind = 'agent',\n}: {\n agentSpec: AgentSpec;\n sandboxEnabled: boolean | null | undefined;\n kind?: DraftPreferenceKind;\n}): Partial<AgentSpec> {\n if (kind === 'chat') {\n if (sandboxEnabled == null) return {};\n const current = readDraftSandboxEnabled(agentSpec);\n if (sandboxEnabled === true && current !== true) {\n return {\n config: {\n ...agentSpec.config,\n sandbox: { ...agentSpec.config?.sandbox, enabled: true },\n },\n };\n }\n if (sandboxEnabled === false && current === true) {\n return {\n config: {\n ...agentSpec.config,\n sandbox: { ...agentSpec.config?.sandbox, enabled: false },\n },\n };\n }\n return {};\n }\n\n const nextSpec = withCapabilitiesSandbox(agentSpec, sandboxEnabled);\n return nextSpec === agentSpec ? {} : { config: nextSpec.config };\n}\n\nexport function reconcileDraftWebSearch({\n agentSpec,\n webSearchEnabled,\n kind = 'agent',\n}: {\n agentSpec: AgentSpec;\n webSearchEnabled: boolean | null | undefined;\n kind?: DraftPreferenceKind;\n}): Partial<AgentSpec> {\n const nextSpec = withCapabilitiesWebSearch({ spec: agentSpec, webSearchEnabled, kind });\n return nextSpec === agentSpec ? {} : { config: nextSpec.config };\n}\n\n/**\n * Mirrors plain-draft composer choices into the shell seed and removes catalog\n * entries that disappeared since those choices were stored.\n * New Chat and New Agent keep separate seeds; chat never persists runtime config.\n */\nexport function DraftSpecPreferenceBridge() {\n const { mode, pendingSessionId, rememberDraftSpec } = useShellMode();\n const { agentSpec } = useTrueFoundryAgentSpec();\n const updateAgentSpec = useTrueFoundryUpdateAgentSpec();\n const capabilities = useServerCapabilities();\n const sandboxEnabled = capabilities?.sandbox.enabled;\n const webSearchEnabled = capabilities?.webSearch?.enabled;\n const { models, skills, connectors, loaded, error, ensureLoaded } = useDraftCatalog();\n const isMutableDraft = mode.status === 'active' && mode.isMutable && pendingSessionId == null;\n const isPlainDraft = isMutableDraft && mode.agentId == null;\n const preferenceKind = mode.status === 'active' && mode.isMutable && mode.isCreateAgent ? 'agent' : 'chat';\n // New Chat forces on; New Agent + edit existing only fill when absent.\n const webSearchKind: DraftPreferenceKind =\n mode.status === 'active' && mode.isMutable && (mode.isCreateAgent || mode.agentId != null) ? 'agent' : 'chat';\n\n useEffect(() => {\n if (isPlainDraft) ensureLoaded();\n }, [ensureLoaded, isPlainDraft]);\n\n useEffect(() => {\n if (isPlainDraft && agentSpec != null) {\n rememberDraftSpec(agentSpec, preferenceKind);\n }\n }, [agentSpec, isPlainDraft, preferenceKind, rememberDraftSpec]);\n\n useEffect(() => {\n // New Chat mirrors capabilities onto the live draft; New Agent only disables when unavailable.\n if (!isPlainDraft || agentSpec == null || updateAgentSpec == null) return;\n const update = reconcileDraftSandbox({ agentSpec, sandboxEnabled, kind: preferenceKind });\n if (Object.keys(update).length > 0) {\n updateAgentSpec(update);\n }\n }, [agentSpec, isPlainDraft, preferenceKind, sandboxEnabled, updateAgentSpec]);\n\n useEffect(() => {\n // Apply to New Chat / New Agent / edit-existing mutable drafts.\n if (!isMutableDraft || agentSpec == null || updateAgentSpec == null) return;\n const update = reconcileDraftWebSearch({ agentSpec, webSearchEnabled, kind: webSearchKind });\n if (Object.keys(update).length > 0) {\n updateAgentSpec(update);\n }\n }, [agentSpec, isMutableDraft, webSearchEnabled, webSearchKind, updateAgentSpec]);\n\n useEffect(() => {\n if (!isPlainDraft || agentSpec == null || updateAgentSpec == null || !loaded || error != null) return;\n\n const update = reconcileDraftSpecPreferences({\n agentSpec,\n models,\n skills,\n connectors,\n skillsEnabled: capabilities?.skill.enabled,\n });\n if (Object.keys(update).length > 0) {\n updateAgentSpec(update);\n }\n }, [\n agentSpec,\n capabilities?.skill.enabled,\n connectors,\n error,\n isPlainDraft,\n loaded,\n models,\n skills,\n updateAgentSpec,\n ]);\n\n return null;\n}\n","'use client';\n\nimport { useEffect } from 'react';\n\nimport { useAui } from '../assistant-ui.js';\nimport { useOptionalShellMode } from '../server/ShellModeContext.js';\n\n/** Switches history sessions in place to preserve mounted chat state to prevent flickering */\nexport function HistorySessionSwitchBridge() {\n const shell = useOptionalShellMode();\n const aui = useAui();\n const pendingSessionId = shell?.pendingSessionId;\n const pendingSessionEpoch = shell?.pendingSessionEpoch ?? 0;\n\n useEffect(() => {\n if (pendingSessionId == null) return;\n void Promise.resolve(aui.threads().switchToThread(pendingSessionId)).catch(() => undefined);\n }, [aui, pendingSessionId, pendingSessionEpoch]);\n\n return null;\n}\n","'use client';\n\nimport { useEffect } from 'react';\n\nimport { useOptionalAgentSessionsServer } from '../server/ServerContext.js';\nimport { useShellMode } from '../server/ShellModeContext.js';\nimport { isSessionsChromeEnabled } from '../server/serverChrome.js';\nimport { readSessionShareSearch } from '../utils/sessionShareUrl.js';\n\n/** Open the sessions browser or a library agent from the share query — with or without `withRouter`. */\nexport function LibrarySessionShareBoot() {\n const { openLibraryAgent, setSessionsOpen } = useShellMode();\n const sessions = useOptionalAgentSessionsServer();\n const sessionsEnabled = isSessionsChromeEnabled({ sessions });\n\n useEffect(() => {\n if (!sessionsEnabled) return;\n const share = readSessionShareSearch(window.location.search);\n if (share.view === 'sessions') {\n setSessionsOpen(true);\n return;\n }\n if (share.agentId == null) return;\n openLibraryAgent(share.agentId);\n }, [openLibraryAgent, sessionsEnabled, setSessionsOpen]);\n\n return null;\n}\n","'use client';\n\nimport { useEffect } from 'react';\n\nimport { useAuiState } from '../assistant-ui.js';\n\n/**\n * Observes the active thread's remote id (assigned once a fresh chat persists)\n * and lifts it to the parent so `ShellRouteSync` can mirror it to `/sessions/:id`.\n * Lives inside the chat runtime, so it remounts with `runtimeKey`; reporting is\n * idempotent, so that is harmless. Carries no react-router dependency.\n */\nexport function RemoteIdRouteBridge({ onRemoteIdChange }: { onRemoteIdChange: (id: string | undefined) => void }) {\n const remoteId = useAuiState(s => s.threadListItem.remoteId);\n useEffect(() => {\n onRemoteIdChange(remoteId ?? undefined);\n }, [remoteId, onRemoteIdChange]);\n return null;\n}\n","import type { AgentUIServer, ListSessionsParams } from './types.js';\n\n/** Cached pages go stale after this window so external session changes surface. */\nconst SESSION_LIST_TTL_MS = 30_000;\n\ntype SessionListPage = ReturnType<AgentUIServer['listSessions']>;\n\ntype CacheEntry = { at: number; page: SessionListPage };\n\nexport type SessionListCache = Map<string, CacheEntry>;\n\nexport function createSessionListCache(): SessionListCache {\n return new Map();\n}\n\n// `startTimestamp` is a rolling \"now − 1 year\" that differs on every call;\n// keying on it would make each request unique and defeat the cache.\nfunction cacheKey(request: ListSessionsParams | undefined): string {\n const rest: ListSessionsParams = { ...request };\n delete rest.startTimestamp;\n return JSON.stringify(rest, Object.keys(rest).sort());\n}\n\n/** Deduplicates session pages and invalidates them after mutations or TTL expiry. */\nexport function withSessionListCache({\n server,\n cache,\n}: {\n server: AgentUIServer;\n cache: SessionListCache;\n}): AgentUIServer {\n const { deleteSession, renameSession } = server;\n return {\n ...server,\n listSessions(request) {\n const key = cacheKey(request);\n const now = Date.now();\n const entry = cache.get(key);\n if (entry !== undefined && now - entry.at < SESSION_LIST_TTL_MS) return entry.page;\n const page = server.listSessions(request);\n cache.set(key, { at: now, page });\n // Allow failed pages to be retried.\n void page.catch(() => {\n if (cache.get(key)?.page === page) cache.delete(key);\n });\n return page;\n },\n async createSession(request) {\n const result = await server.createSession(request);\n cache.clear();\n return result;\n },\n async updateSession(request) {\n const result = await server.updateSession(request);\n cache.clear();\n return result;\n },\n ...(deleteSession != null\n ? {\n deleteSession: async (request: { sessionId: string }) => {\n await deleteSession.call(server, request);\n cache.clear();\n },\n }\n : {}),\n ...(renameSession != null\n ? {\n renameSession: async (request: { sessionId: string; title: string }) => {\n await renameSession.call(server, request);\n cache.clear();\n },\n }\n : {}),\n };\n}\n","'use client';\n\nimport { createTrueFoundryAgentUIServer } from '@truefoundry/assistant-ui-runtime/plugins/truefoundry-agent-server-adapter';\nimport { useEffect, useState } from 'react';\n\nimport type { TrueForgeBuiltInServerConfig, TrueForgeServerConfig } from '../server/TrueForgeServerConfig.js';\nimport type {\n AgentBuilderCapabilitiesResponse,\n AgentUIServer,\n CatalogServer,\n PermissionsServer,\n} from '../server/types.js';\n\nexport type ResolvedServerState =\n | { status: 'loading'; server: null; error: null }\n | { status: 'ready'; server: AgentUIServer; error: null }\n | { status: 'error'; server: null; error: unknown };\n\n/** Fallback when an older runtime adapter omits `getCapabilities`. */\nconst DEFAULT_CAPABILITIES = {\n data: {\n sandbox: { enabled: true },\n skill: { enabled: true },\n settings: { enabled: true },\n webSearch: { enabled: false },\n },\n} satisfies AgentBuilderCapabilitiesResponse;\n\nfunction isBuiltInConfig(config: TrueForgeServerConfig): config is TrueForgeBuiltInServerConfig {\n return (\n typeof config === 'object' &&\n config !== null &&\n 'type' in config &&\n (config.type === 'truefoundry' || config.type === 'trueforge')\n );\n}\n\nfunction hasGetCapabilities(\n server: object,\n): server is { getCapabilities: () => Promise<AgentBuilderCapabilitiesResponse> } {\n return typeof Reflect.get(server, 'getCapabilities') === 'function';\n}\n\n/**\n * Attach optional host ports and ensure `getCapabilities` exists on the composed port.\n */\nfunction toAgentUIServer(\n server: object,\n catalog: CatalogServer | undefined,\n permissions: PermissionsServer | undefined,\n): AgentUIServer {\n const getCapabilities = hasGetCapabilities(server)\n ? () => server.getCapabilities()\n : async () => DEFAULT_CAPABILITIES;\n const withCapabilities = { ...server, getCapabilities };\n const withOptionalPorts = {\n ...withCapabilities,\n ...(catalog == null ? {} : { catalog }),\n ...(permissions == null ? {} : { permissions }),\n };\n if (!isAgentUIServer(withOptionalPorts)) {\n throw new Error('TrueForgeUI: runtime adapter returned an incomplete AgentUIServer');\n }\n return withOptionalPorts;\n}\n\nfunction isAgentUIServer(value: object): value is AgentUIServer {\n return (\n typeof Reflect.get(value, 'createSession') === 'function' &&\n typeof Reflect.get(value, 'listSessions') === 'function' &&\n typeof Reflect.get(value, 'getSession') === 'function' &&\n typeof Reflect.get(value, 'updateSession') === 'function' &&\n typeof Reflect.get(value, 'createTurn') === 'function' &&\n typeof Reflect.get(value, 'cancelSession') === 'function' &&\n typeof Reflect.get(value, 'listTurns') === 'function' &&\n typeof Reflect.get(value, 'getTurn') === 'function' &&\n typeof Reflect.get(value, 'listEvents') === 'function' &&\n typeof Reflect.get(value, 'getCapabilities') === 'function' &&\n typeof Reflect.get(value, 'getModels') === 'function' &&\n typeof Reflect.get(value, 'getSkills') === 'function' &&\n typeof Reflect.get(value, 'getMcp') === 'function' &&\n typeof Reflect.get(value, 'searchAgents') === 'function' &&\n typeof Reflect.get(value, 'saveAgent') === 'function'\n );\n}\n\n/**\n * Resolves a {@link TrueForgeServerConfig} to an {@link AgentUIServer}.\n * - `AgentUIServer` — sync passthrough\n * - `truefoundry` — async via `createTrueFoundryAgentUIServer`\n * - `trueforge` — via dynamic import of the Harness plugin adapter\n */\nexport function useResolvedServer(\n config: TrueForgeServerConfig,\n onError?: (error: unknown) => void,\n): ResolvedServerState {\n const builtIn = isBuiltInConfig(config) ? config : null;\n const directServer: AgentUIServer | null = isBuiltInConfig(config) ? null : config;\n const type = builtIn?.type;\n const apiKey = builtIn?.type === 'truefoundry' ? builtIn.apiKey : '';\n const controlPlaneURL = builtIn?.type === 'truefoundry' ? builtIn.controlPlaneURL : '';\n const gatewayPlaneURL = builtIn?.type === 'truefoundry' ? (builtIn.gatewayPlaneURL ?? '') : '';\n const trueforgeBaseUrl = builtIn?.type === 'trueforge' ? (builtIn.baseUrl ?? '') : '';\n const trueforgeToken = builtIn?.type === 'trueforge' ? (builtIn.token ?? '') : '';\n const trueforgeFetch = builtIn?.type === 'trueforge' ? builtIn.fetch : undefined;\n const catalog = builtIn?.catalog;\n const permissions = builtIn?.permissions;\n\n const [state, setState] = useState<ResolvedServerState>(() => {\n if (directServer) {\n return { status: 'ready', server: directServer, error: null };\n }\n return { status: 'loading', server: null, error: null };\n });\n\n useEffect(() => {\n if (directServer) {\n setState({ status: 'ready', server: directServer, error: null });\n return;\n }\n\n let cancelled = false;\n setState({ status: 'loading', server: null, error: null });\n\n const resolve = async (): Promise<AgentUIServer> => {\n if (type === 'trueforge') {\n const { createTrueForgeAgentUIServer } = await import('../plugins/trueforge-agent-server-adapter/index.js');\n return createTrueForgeAgentUIServer({\n ...(trueforgeBaseUrl ? { baseUrl: trueforgeBaseUrl } : {}),\n ...(trueforgeToken ? { token: trueforgeToken } : {}),\n ...(trueforgeFetch !== undefined ? { fetch: trueforgeFetch } : {}),\n ...(catalog != null ? { catalog } : {}),\n ...(permissions != null ? { permissions } : {}),\n });\n }\n\n const runtimeServer = await createTrueFoundryAgentUIServer({\n apiKey,\n cpURL: controlPlaneURL,\n ...(gatewayPlaneURL ? { gatewayURL: gatewayPlaneURL } : {}),\n });\n // TrueFoundry adapter may omit catalog; attach host-supplied catalog here.\n return toAgentUIServer(runtimeServer, catalog, permissions);\n };\n\n void resolve()\n .then(server => {\n if (cancelled) return;\n try {\n // trueforge factory already includes catalog; still normalize capabilities.\n setState({\n status: 'ready',\n server: type === 'trueforge' ? toAgentUIServer(server, undefined, undefined) : server,\n error: null,\n });\n } catch (error: unknown) {\n onError?.(error);\n setState({ status: 'error', server: null, error });\n }\n })\n .catch((error: unknown) => {\n if (cancelled) return;\n onError?.(error);\n setState({ status: 'error', server: null, error });\n });\n\n return () => {\n cancelled = true;\n };\n }, [\n type,\n directServer,\n apiKey,\n controlPlaneURL,\n gatewayPlaneURL,\n trueforgeBaseUrl,\n trueforgeToken,\n trueforgeFetch,\n catalog,\n permissions,\n onError,\n ]);\n\n return state;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,0BAA0B,eAAAA,oBAAmB;AACtD;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,aAAa,eAA+B;AAmBjD;AATJ,SAAS,6BAA6B;AAAA,EACpC;AAAA,EACA;AACF,GAGG;AACD,QAAM,WAAWC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sB,GAChE;AAAA,EAEJ;AAEA,QAAM,SAAS,SAAS;AACxB,QAAM,aAAa,gBAAAA,KAAC,kBAAe,QAAgB,WAAsB;AAEzE,QAAM,YACJ,qBAAC,qBAAkB,aAA0B,qBAC3C;AAAA,oBAAAA,KAAC,2BAAwB;AAAA,IACxB,kBAAkB,OACjB,gBAAAA,KAAC,YAAS,UAAU,MAClB,0BAAAA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR;AAAA,QACA;AAAA;AAAA,IACF,GACF,IACE;AAAA,IACJ,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,kBAAkB,kBAAkB,OAAO,uBAAuB;AAAA,QACjE,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,KACF;AAGF,QAAM,iBACJ,WAAW,WAAW,gBAAAA,KAAC,4BAA0B,qBAAU,IAA8B;AAE3F,SACE,gBAAAA,KAAC,iBAAc,WAAsB,OACnC,0BAAAA,KAAC,uBAAoB,aACnB,0BAAAA,KAAC,iCAA8B,WAAW,uBACxC,0BAAAA,KAAC,kBAAe,QACb,4BAAkB,OACjB,gBAAAA,KAAC,0BAAuB,QAAQ,gBAAiB,0BAAe,IAEhE,gBAEJ,GACF,GACF,GACF;AAEJ;","names":["useAuiState","useAuiState","useCallback","useEffect","useMemo","useState","useEffect","useEffect","useEffect","useEffect","useEffect","useEffect","useEffect","runtimeServer","jsx","useState","useMemo","runtimeServer","useCallback","useEffect"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getErrorMessage,
3
3
  useOptionalServer
4
- } from "./chunk-2GIZY3JJ.js";
4
+ } from "./chunk-2XT2VUT4.js";
5
5
 
6
6
  // src/atoms/lib/useSearchAgentsList.ts
7
7
  import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
@@ -235,4 +235,4 @@ export {
235
235
  clearScheduleShareSearch,
236
236
  replaceScheduleShareSearch
237
237
  };
238
- //# sourceMappingURL=chunk-T6QQV5LK.js.map
238
+ //# sourceMappingURL=chunk-AO23SZBG.js.map
@@ -19,16 +19,16 @@ import {
19
19
  useOptionalApprovalFocus,
20
20
  useSlot,
21
21
  useSlotIsDefault
22
- } from "./chunk-4OEAJKLJ.js";
22
+ } from "./chunk-XR4S7B2K.js";
23
23
  import {
24
24
  DraftCatalogProvider,
25
25
  useDraftCatalog
26
- } from "./chunk-3ZW74FHC.js";
26
+ } from "./chunk-4OZFQVSR.js";
27
27
  import {
28
28
  useOptionalCatalogServer,
29
29
  useOptionalServer,
30
30
  useOptionalShellMode
31
- } from "./chunk-2GIZY3JJ.js";
31
+ } from "./chunk-2XT2VUT4.js";
32
32
  import {
33
33
  useAui,
34
34
  useAuiState
@@ -247,19 +247,54 @@ function CustomActionContainer({ disabled = false }) {
247
247
  // src/containers/McpAuthContainer.tsx
248
248
  import { useThreadIsRunning as useThreadIsRunning3 } from "@assistant-ui/core/react";
249
249
  import { useTrueFoundryMcpAuth } from "@truefoundry/assistant-ui-runtime";
250
+ import { useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
250
251
  import { jsx as jsx4 } from "react/jsx-runtime";
251
252
  function CatalogMcpAuthPrompt({ servers, onContinue, readOnly }) {
252
253
  const McpAuthPrompt = useSlot("McpAuthPrompt");
253
254
  const { handleAuthorize } = useMCPAuth();
254
255
  const { refreshConnectors } = useDraftCatalog();
256
+ const [connectedServerIds, setConnectedServerIds] = useState3(() => /* @__PURE__ */ new Set());
257
+ const connectedServerIdsRef = useRef2(connectedServerIds);
258
+ const [isResuming, setIsResuming] = useState3(false);
259
+ const resumedRef = useRef2(false);
260
+ const promptGenerationRef = useRef2(0);
261
+ useEffect3(
262
+ () => () => {
263
+ promptGenerationRef.current += 1;
264
+ },
265
+ []
266
+ );
267
+ const startResume = () => {
268
+ if (readOnly || resumedRef.current) return;
269
+ resumedRef.current = true;
270
+ setIsResuming(true);
271
+ void onContinue().catch(() => {
272
+ resumedRef.current = false;
273
+ setIsResuming(false);
274
+ });
275
+ };
255
276
  const handleConnect = (serverId) => {
277
+ const generation = promptGenerationRef.current;
256
278
  void handleAuthorize(serverId, (isSuccess) => {
257
- if (isSuccess) {
258
- void refreshConnectors();
259
- }
279
+ if (generation !== promptGenerationRef.current || !isSuccess) return;
280
+ const nextConnectedServerIds = /* @__PURE__ */ new Set([...connectedServerIdsRef.current, serverId]);
281
+ connectedServerIdsRef.current = nextConnectedServerIds;
282
+ setConnectedServerIds(nextConnectedServerIds);
283
+ void refreshConnectors();
284
+ if (servers.every((server) => nextConnectedServerIds.has(server.id))) startResume();
260
285
  });
261
286
  };
262
- return /* @__PURE__ */ jsx4(McpAuthPrompt, { servers, onConnect: handleConnect, onContinue, readOnly });
287
+ return /* @__PURE__ */ jsx4(
288
+ McpAuthPrompt,
289
+ {
290
+ servers,
291
+ connectedServerIds,
292
+ continueLoading: isResuming,
293
+ onConnect: handleConnect,
294
+ onContinue: startResume,
295
+ readOnly
296
+ }
297
+ );
263
298
  }
264
299
  function McpAuthContainer({ disabled = false }) {
265
300
  const McpAuthPrompt = useSlot("McpAuthPrompt");
@@ -268,15 +303,15 @@ function McpAuthContainer({ disabled = false }) {
268
303
  const catalog = useOptionalCatalogServer();
269
304
  if (!pending) return null;
270
305
  if (catalog) {
306
+ const pendingServerKey = JSON.stringify(pending.mcpServers.map((server) => server.id));
271
307
  return /* @__PURE__ */ jsx4(
272
308
  CatalogMcpAuthPrompt,
273
309
  {
274
310
  servers: pending.mcpServers,
275
- onContinue: () => {
276
- if (!disabled) void resume();
277
- },
311
+ onContinue: resume,
278
312
  readOnly: isRunning || disabled
279
- }
313
+ },
314
+ pendingServerKey
280
315
  );
281
316
  }
282
317
  const handleConnect = (serverId) => {
@@ -301,7 +336,7 @@ function McpAuthContainer({ disabled = false }) {
301
336
  // src/containers/ComposerContainer.tsx
302
337
  import { ComposerPrimitive, useAui as useAui2, useAuiState as useAuiState3 } from "@assistant-ui/react";
303
338
  import { useTrueFoundryAgentSpec, useTrueFoundryCancel } from "@truefoundry/assistant-ui-runtime";
304
- import { useRef as useRef2 } from "react";
339
+ import { useRef as useRef3 } from "react";
305
340
  import { Fragment, jsx as jsx5, jsxs } from "react/jsx-runtime";
306
341
  function canSubmitComposer({
307
342
  disabled,
@@ -328,7 +363,7 @@ function ComposerBody({
328
363
  const { isBusy, send, resetBusy } = useComposerBusyState();
329
364
  const canManageSession = useActiveSessionCanManage();
330
365
  const cancel = useTrueFoundryCancel();
331
- const fileInputRef = useRef2(null);
366
+ const fileInputRef = useRef3(null);
332
367
  const disabled = isBusy || forceDisabled || !canManageSession;
333
368
  const canSubmit = canSubmitComposer({ disabled, hasText, hasAttachments, requiresModel, hasModel });
334
369
  const submit = () => {
@@ -457,15 +492,15 @@ function ComposerContainer({
457
492
 
458
493
  // src/containers/HistoryLoaderContainer.tsx
459
494
  import { useTrueFoundryHistoryPagination } from "@truefoundry/assistant-ui-runtime";
460
- import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
495
+ import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
461
496
  import { jsx as jsx6 } from "react/jsx-runtime";
462
497
  var TOP_THRESHOLD_PX = 200;
463
498
  var VIEWPORT_SELECTOR = '[data-slot="aui_thread-viewport"]';
464
499
  function HistoryLoaderContainer() {
465
500
  const HistoryLoader = useSlot("HistoryLoader");
466
501
  const { hasOlderHistory, isLoadingOlderHistory, loadOlderHistory } = useTrueFoundryHistoryPagination();
467
- const [sentinel, setSentinel] = useState3(null);
468
- const inflightRef = useRef3(false);
502
+ const [sentinel, setSentinel] = useState4(null);
503
+ const inflightRef = useRef4(false);
469
504
  const maybeLoadOlder = useCallback4(async () => {
470
505
  if (inflightRef.current) return;
471
506
  inflightRef.current = true;
@@ -486,7 +521,7 @@ function HistoryLoaderContainer() {
486
521
  inflightRef.current = false;
487
522
  }
488
523
  }, [sentinel, loadOlderHistory]);
489
- useEffect3(() => {
524
+ useEffect4(() => {
490
525
  if (sentinel == null || !hasOlderHistory) return;
491
526
  const viewport = sentinel.closest(VIEWPORT_SELECTOR);
492
527
  const observer = new IntersectionObserver(
@@ -565,23 +600,23 @@ function UserEditComposerContainer() {
565
600
 
566
601
  // src/containers/ThreadContainer.tsx
567
602
  import { ThreadPrimitive, useAuiState as useAuiState5 } from "@assistant-ui/react";
568
- import { useEffect as useEffect5 } from "react";
603
+ import { useEffect as useEffect6 } from "react";
569
604
 
570
605
  // src/hooks/useSyncSessionTitle.ts
571
606
  import { useThreadIsRunning as useThreadIsRunning5 } from "@assistant-ui/core/react";
572
- import { useEffect as useEffect4, useRef as useRef4 } from "react";
607
+ import { useEffect as useEffect5, useRef as useRef5 } from "react";
573
608
  function useSyncSessionTitle() {
574
609
  const server = useOptionalServer();
575
610
  const aui = useAui();
576
611
  const remoteId = useAuiState((s) => s.threadListItem.remoteId);
577
612
  const title = useAuiState((s) => s.threadListItem.title);
578
613
  const isRunning = useThreadIsRunning5();
579
- const wasRunningRef = useRef4(false);
580
- const syncedRemoteIdRef = useRef4(void 0);
581
- useEffect4(() => {
614
+ const wasRunningRef = useRef5(false);
615
+ const syncedRemoteIdRef = useRef5(void 0);
616
+ useEffect5(() => {
582
617
  syncedRemoteIdRef.current = void 0;
583
618
  }, [remoteId]);
584
- useEffect4(() => {
619
+ useEffect5(() => {
585
620
  const finishedTurn = wasRunningRef.current && !isRunning;
586
621
  wasRunningRef.current = isRunning;
587
622
  if (!finishedTurn || server == null || remoteId == null) {
@@ -624,7 +659,7 @@ function ThreadMessage({ isEditing }) {
624
659
  return /* @__PURE__ */ jsx9(AssistantMessageContainer, {});
625
660
  }
626
661
  function ThreadContainer({ composer }) {
627
- useEffect5(() => {
662
+ useEffect6(() => {
628
663
  void preloadMarkdownOpenUI();
629
664
  }, []);
630
665
  useSyncSessionTitle();
@@ -679,4 +714,4 @@ export {
679
714
  ThreadContainer,
680
715
  Thread
681
716
  };
682
- //# sourceMappingURL=chunk-MACHU4OO.js.map
717
+ //# sourceMappingURL=chunk-AU4BJQMK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/useApprovalNav.ts","../src/containers/ApprovalNavContainer.tsx","../src/containers/AskUserContainer.tsx","../src/hooks/useComposerPauseView.ts","../src/containers/CustomActionContainer.tsx","../src/containers/McpAuthContainer.tsx","../src/containers/ComposerContainer.tsx","../src/containers/HistoryLoaderContainer.tsx","../src/containers/ResumeUnavailableContainer.tsx","../src/containers/UserEditComposerContainer.tsx","../src/containers/ThreadContainer.tsx","../src/hooks/useSyncSessionTitle.ts","../src/containers/Thread.tsx"],"sourcesContent":["'use client';\n\nimport { useTrueFoundryApprovals } from '@truefoundry/assistant-ui-runtime';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useOptionalApprovalFocus } from '../containers/approvalFocus.js';\n\nexport type ApprovalNavState = {\n count: number;\n /** 0-based index into pending approvals. */\n index: number;\n canPrev: boolean;\n canNext: boolean;\n goPrev: () => void;\n goNext: () => void;\n /** Scroll to the currently selected approval (e.g. after the user scrolled away). */\n focusCurrent: () => void;\n};\n\n/**\n * Tracks the focused pending tool approval for the composer banner.\n * Auto-focuses #1 when approvals appear; after allow/deny, stays on the same\n * index so the next pending item fills the slot; chevrons do not wrap.\n */\nexport function useApprovalNav(): ApprovalNavState {\n const { pending } = useTrueFoundryApprovals();\n const focusApi = useOptionalApprovalFocus();\n const [selection, setSelection] = useState<{ approvalId: string | null; index: number }>({\n approvalId: null,\n index: 0,\n });\n const focusedIdRef = useRef<string | null>(null);\n\n const count = pending.length;\n const matchedIndex =\n selection.approvalId == null ? -1 : pending.findIndex(item => item.approvalId === selection.approvalId);\n const safeIndex = matchedIndex >= 0 ? matchedIndex : count === 0 ? 0 : Math.min(selection.index, count - 1);\n const currentId = pending[safeIndex]?.approvalId;\n\n useEffect(() => {\n const approvalId = currentId ?? null;\n if (selection.approvalId === approvalId && selection.index === safeIndex) return;\n setSelection({ approvalId, index: safeIndex });\n }, [currentId, safeIndex, selection.approvalId, selection.index]);\n\n useEffect(() => {\n if (currentId == null || focusApi == null) {\n if (currentId == null) focusedIdRef.current = null;\n return;\n }\n if (focusedIdRef.current === currentId) return;\n focusedIdRef.current = currentId;\n focusApi.focus(currentId);\n }, [currentId, focusApi]);\n\n const goPrev = useCallback(() => {\n const index = Math.max(0, safeIndex - 1);\n setSelection({ approvalId: pending[index]?.approvalId ?? null, index });\n }, [pending, safeIndex]);\n\n const goNext = useCallback(() => {\n const index = Math.min(Math.max(count - 1, 0), safeIndex + 1);\n setSelection({ approvalId: pending[index]?.approvalId ?? null, index });\n }, [count, pending, safeIndex]);\n\n const focusCurrent = useCallback(() => {\n if (currentId == null || focusApi == null) return;\n focusApi.focus(currentId);\n }, [currentId, focusApi]);\n\n return {\n count,\n index: safeIndex,\n canPrev: safeIndex > 0,\n canNext: safeIndex < count - 1,\n goPrev,\n goNext,\n focusCurrent,\n };\n}\n","'use client';\n\nimport { useApprovalNav } from '../hooks/useApprovalNav.js';\nimport { useSlot } from '../theme/SlotsProvider.js';\n\n/** Composer banner that navigates pending tool approvals. */\nexport function ApprovalNavContainer() {\n const ApprovalNavBanner = useSlot('ApprovalNavBanner');\n const { count, index, canPrev, canNext, goPrev, goNext, focusCurrent } = useApprovalNav();\n\n if (count === 0) return null;\n\n return (\n <ApprovalNavBanner\n total={count}\n current={index + 1}\n canPrev={canPrev}\n canNext={canNext}\n onPrev={goPrev}\n onNext={goNext}\n onFocusCurrent={focusCurrent}\n />\n );\n}\n","'use client';\n\nimport { useThreadIsRunning } from '@assistant-ui/core/react';\nimport { useTrueFoundryToolResponses } from '@truefoundry/assistant-ui-runtime';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n ASK_USER_CUSTOM_OPTION,\n type AskUserAnswerDraft,\n type Question,\n} from '../atoms/adapters/AskUserPromptAdapter.js';\n\nimport { useSlot } from '../theme/SlotsProvider.js';\n\nconst EMPTY_ANSWER: AskUserAnswerDraft = { radioValue: '', custom: '' };\n\nexport function AskUserContainer({ disabled = false }: { disabled?: boolean }) {\n const AskUserPrompt = useSlot('AskUserPrompt');\n const { pending, respond } = useTrueFoundryToolResponses();\n const isRunning = useThreadIsRunning();\n const item = pending[0];\n\n const questions = useMemo<Question[]>(\n () =>\n item == null\n ? []\n : [\n {\n id: item.toolCallId,\n question: item.question ?? 'Answer required',\n options: item.options ?? [],\n },\n ],\n [item],\n );\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);\n const [answers, setAnswers] = useState<Record<string, AskUserAnswerDraft>>({});\n\n useEffect(() => {\n setCurrentQuestionIndex(0);\n setAnswers({});\n }, [item?.toolCallId]);\n\n const safeIndex = Math.min(currentQuestionIndex, Math.max(questions.length - 1, 0));\n const currentQuestion = questions[safeIndex];\n const currentAnswer = currentQuestion == null ? EMPTY_ANSWER : (answers[currentQuestion.id] ?? EMPTY_ANSWER);\n const getResponseForQuestion = useCallback(\n (questionId: string) => {\n const answer = answers[questionId] ?? EMPTY_ANSWER;\n return answer.radioValue === ASK_USER_CUSTOM_OPTION ? answer.custom.trim() : answer.radioValue.trim();\n },\n [answers],\n );\n const allQuestionsAnswered = useMemo(\n () => questions.every(question => getResponseForQuestion(question.id)),\n [getResponseForQuestion, questions],\n );\n const selectedResponse =\n currentAnswer.radioValue === ASK_USER_CUSTOM_OPTION ? currentAnswer.custom.trim() : currentAnswer.radioValue.trim();\n const isSubmitDisabled = isRunning || disabled || currentQuestion == null || selectedResponse.length === 0;\n const isSubmitAllDisabled = isSubmitDisabled || !allQuestionsAnswered;\n\n const onCurrentAnswerChange = useCallback((questionId: string, update: Partial<AskUserAnswerDraft>) => {\n setAnswers(previous => ({\n ...previous,\n [questionId]: {\n ...(previous[questionId] ?? EMPTY_ANSWER),\n ...update,\n },\n }));\n }, []);\n\n const onSubmit = useCallback(() => {\n if (disabled || item == null || !allQuestionsAnswered) return;\n const content = getResponseForQuestion(item.toolCallId);\n if (!content) return;\n respond({ toolCallId: item.toolCallId, content });\n }, [allQuestionsAnswered, disabled, getResponseForQuestion, item, respond]);\n\n if (item == null || currentQuestion == null) return null;\n\n return (\n <AskUserPrompt\n questions={questions}\n readOnly={isRunning || disabled}\n currentQuestion={currentQuestion}\n currentQuestionIndex={safeIndex}\n currentAnswer={currentAnswer}\n totalQuestions={questions.length}\n isMultiQuestion={questions.length > 1}\n isLastQuestion={safeIndex === questions.length - 1}\n allQuestionsAnswered={allQuestionsAnswered}\n isSubmitDisabled={isSubmitDisabled}\n isSubmitAllDisabled={isSubmitAllDisabled}\n onCurrentQuestionIndexChange={setCurrentQuestionIndex}\n onCurrentAnswerChange={onCurrentAnswerChange}\n onSubmit={onSubmit}\n />\n );\n}\n","'use client';\n\nimport { useAuiState } from '@assistant-ui/react';\nimport { useTrueFoundryApprovals, useTrueFoundryToolResponses } from '@truefoundry/assistant-ui-runtime';\n\nimport { useOptionalCustomActionRenderers } from '../server/CustomActionRenderersContext.js';\n\nexport type ThreadPauseState = {\n thread: {\n messages: readonly {\n role: string;\n status?: { type: string };\n metadata?: { custom?: unknown };\n }[];\n };\n};\n\n/** Returns true when the latest assistant message is paused for MCP authorization. */\nexport function threadHasPendingMcpAuth(s: ThreadPauseState): boolean {\n const messages = s.thread.messages;\n const last = messages[messages.length - 1];\n if (last?.role !== 'assistant') return false;\n if (last.status?.type !== 'requires-action') return false;\n return (last.metadata?.custom as { pendingMcpAuth?: boolean } | undefined)?.pendingMcpAuth === true;\n}\n\nexport type ComposerPauseView =\n | { kind: 'mcp' }\n | { kind: 'custom'; toolName: string }\n | { kind: 'ask-user' }\n | { kind: 'approval' }\n | { kind: 'compose' };\n\n/** Shared composer pause detection for default and custom composer containers. */\nexport function useComposerPauseView(): ComposerPauseView {\n const mcpPending = useAuiState(threadHasPendingMcpAuth);\n const { pending: toolResponsesPending } = useTrueFoundryToolResponses();\n const { pending: approvalsPending } = useTrueFoundryApprovals();\n const customActionRenderers = useOptionalCustomActionRenderers();\n\n if (mcpPending) {\n return { kind: 'mcp' };\n }\n\n const firstPending = toolResponsesPending[0];\n if (firstPending != null) {\n const toolName = firstPending.toolName;\n if (toolName != null && customActionRenderers?.[toolName] != null) {\n return { kind: 'custom', toolName };\n }\n return { kind: 'ask-user' };\n }\n\n if (approvalsPending.length > 0) {\n return { kind: 'approval' };\n }\n\n return { kind: 'compose' };\n}\n","'use client';\n\nimport { useThreadIsRunning } from '@assistant-ui/core/react';\nimport { useTrueFoundryToolResponses } from '@truefoundry/assistant-ui-runtime';\nimport { useCallback } from 'react';\n\nimport { useOptionalCustomActionRenderers } from '../server/CustomActionRenderersContext.js';\n\n/** Host custom-action UI for a pending client-side tool response. */\nexport function CustomActionContainer({ disabled = false }: { disabled?: boolean }) {\n const renderers = useOptionalCustomActionRenderers();\n const { pending, respond } = useTrueFoundryToolResponses();\n const isRunning = useThreadIsRunning();\n const item = pending[0];\n\n const onSubmit = useCallback(\n (content: string) => {\n if (disabled || item == null) return;\n const trimmed = content.trim();\n if (!trimmed) return;\n respond({ toolCallId: item.toolCallId, content: trimmed });\n },\n [disabled, item, respond],\n );\n\n if (item == null || item.toolName == null) return null;\n const Renderer = renderers?.[item.toolName];\n if (Renderer == null) return null;\n\n return <Renderer args={item.args ?? {}} disabled={isRunning || disabled} onSubmit={onSubmit} />;\n}\n","'use client';\n\nimport { useThreadIsRunning } from '@assistant-ui/core/react';\nimport { useTrueFoundryMcpAuth } from '@truefoundry/assistant-ui-runtime';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useDraftCatalog } from '@/atoms/draft/DraftCatalogProvider.js';\nimport { useMCPAuth } from '@/hooks/useMcpAuth.js';\nimport { useOptionalCatalogServer } from '@/server/ServerContext.js';\nimport { useSlot } from '../theme/SlotsProvider.js';\n\ntype McpAuthPromptProps = {\n servers: NonNullable<ReturnType<typeof useTrueFoundryMcpAuth>['pending']>['mcpServers'];\n onContinue: () => Promise<void>;\n readOnly: boolean;\n};\n\nfunction CatalogMcpAuthPrompt({ servers, onContinue, readOnly }: McpAuthPromptProps) {\n const McpAuthPrompt = useSlot('McpAuthPrompt');\n const { handleAuthorize } = useMCPAuth();\n const { refreshConnectors } = useDraftCatalog();\n const [connectedServerIds, setConnectedServerIds] = useState<ReadonlySet<string>>(() => new Set());\n const connectedServerIdsRef = useRef(connectedServerIds);\n const [isResuming, setIsResuming] = useState(false);\n const resumedRef = useRef(false);\n const promptGenerationRef = useRef(0);\n\n useEffect(\n () => () => {\n promptGenerationRef.current += 1;\n },\n [],\n );\n\n const startResume = () => {\n if (readOnly || resumedRef.current) return;\n resumedRef.current = true;\n setIsResuming(true);\n void onContinue().catch(() => {\n resumedRef.current = false;\n setIsResuming(false);\n });\n };\n\n const handleConnect = (serverId: string) => {\n const generation = promptGenerationRef.current;\n void handleAuthorize(serverId, isSuccess => {\n if (generation !== promptGenerationRef.current || !isSuccess) return;\n const nextConnectedServerIds = new Set([...connectedServerIdsRef.current, serverId]);\n connectedServerIdsRef.current = nextConnectedServerIds;\n setConnectedServerIds(nextConnectedServerIds);\n void refreshConnectors();\n if (servers.every(server => nextConnectedServerIds.has(server.id))) startResume();\n });\n };\n\n return (\n <McpAuthPrompt\n servers={servers}\n connectedServerIds={connectedServerIds}\n continueLoading={isResuming}\n onConnect={handleConnect}\n onContinue={startResume}\n readOnly={readOnly}\n />\n );\n}\n\nexport function McpAuthContainer({ disabled = false }: { disabled?: boolean }) {\n const McpAuthPrompt = useSlot('McpAuthPrompt');\n const { pending, resume } = useTrueFoundryMcpAuth();\n const isRunning = useThreadIsRunning();\n const catalog = useOptionalCatalogServer();\n\n if (!pending) return null;\n\n if (catalog) {\n const pendingServerKey = JSON.stringify(pending.mcpServers.map(server => server.id));\n return (\n <CatalogMcpAuthPrompt\n key={pendingServerKey}\n servers={pending.mcpServers}\n onContinue={resume}\n readOnly={isRunning || disabled}\n />\n );\n }\n\n const handleConnect = (serverId: string) => {\n const server = pending.mcpServers.find(s => s.id === serverId);\n if (server?.authUrl) {\n window.open(server.authUrl, '_blank', 'noopener,noreferrer');\n }\n };\n\n return (\n <McpAuthPrompt\n servers={pending.mcpServers}\n onConnect={handleConnect}\n onContinue={() => {\n if (!disabled) void resume();\n }}\n readOnly={isRunning || disabled}\n />\n );\n}\n","'use client';\n\nimport { ComposerPrimitive, useAui, useAuiState } from '@assistant-ui/react';\nimport { useTrueFoundryAgentSpec, useTrueFoundryCancel } from '@truefoundry/assistant-ui-runtime';\nimport { useRef } from 'react';\n\nimport { DraftCatalogProvider } from '../atoms/draft/DraftCatalogProvider.js';\nimport { useComposerBusyState } from '../hooks/useComposerBusyState.js';\nimport { useComposerPauseView } from '../hooks/useComposerPauseView.js';\nimport { useActiveSessionCanManage } from '../hooks/useResourcePermissions.js';\nimport { useOptionalShellMode } from '../server/ShellModeContext.js';\nimport { SlotsProvider, useSlot, useSlotIsDefault } from '../theme/SlotsProvider.js';\nimport { ApprovalNavContainer } from './ApprovalNavContainer.js';\nimport { AskUserContainer } from './AskUserContainer.js';\nimport { ComposerAttachmentsContainer } from './AttachmentsContainer.js';\nimport { CustomActionContainer } from './CustomActionContainer.js';\nimport { McpAuthContainer } from './McpAuthContainer.js';\n\nexport type ComposerContainerProps = {\n placeholder?: string;\n};\n\nexport function canSubmitComposer({\n disabled,\n hasText,\n hasAttachments,\n requiresModel,\n hasModel,\n}: {\n disabled: boolean;\n hasText: boolean;\n hasAttachments: boolean;\n requiresModel: boolean;\n hasModel: boolean;\n}): boolean {\n return !disabled && (hasText || hasAttachments) && (!requiresModel || hasModel);\n}\n\nfunction ComposerBody({\n placeholder,\n forceDisabled = false,\n connectedToBanner = false,\n}: {\n placeholder: string;\n forceDisabled?: boolean;\n /** Flatten top radius/border so the approval banner sits flush above. */\n connectedToBanner?: boolean;\n}) {\n const ComposerShell = useSlot('ComposerShell');\n const aui = useAui();\n const shell = useOptionalShellMode();\n const hasText = useAuiState(s => s.composer.text.trim().length > 0);\n const hasAttachments = useAuiState(s => s.composer.attachments.length > 0);\n const { agentSpec } = useTrueFoundryAgentSpec();\n // Named (immutable) agents use a server-side model; only draft/mutable composers pick one here.\n const requiresModel = shell == null || (shell.mode.status === 'active' && shell.mode.isMutable);\n const hasModel = Boolean(agentSpec?.model?.name?.trim());\n const { isBusy, send, resetBusy } = useComposerBusyState();\n const canManageSession = useActiveSessionCanManage();\n const cancel = useTrueFoundryCancel();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const disabled = isBusy || forceDisabled || !canManageSession;\n const canSubmit = canSubmitComposer({ disabled, hasText, hasAttachments, requiresModel, hasModel });\n const submit = () => {\n if (!canSubmit) return;\n send(() => aui.composer().send());\n };\n\n return (\n <>\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n hidden\n onChange={event => {\n const files = event.target.files;\n if (files) {\n for (const file of files) {\n void aui.composer().addAttachment(file);\n }\n }\n event.target.value = '';\n }}\n />\n <ComposerPrimitive.AttachmentDropzone\n disabled={disabled}\n data-slot=\"aui_composer-attachment-dropzone\"\n className=\"w-full rounded-[0.75rem] transition-[box-shadow] data-[dragging=true]:ring-focus-ring/20 data-[dragging=true]:ring-3\"\n >\n <ComposerPrimitive.Root\n data-slot=\"aui_composer-root\"\n className=\"w-full\"\n onSubmit={event => {\n // Suppresses the primitive's own send so submits route through the busy-state wrapper.\n event.preventDefault();\n submit();\n }}\n >\n <ComposerShell\n className={\n connectedToBanner\n ? // Banner owns the top accent; composer keeps its normal chrome without a shared blue frame.\n 'rounded-t-none border-t-0 focus-within:ring-0'\n : undefined\n }\n attachments={<ComposerAttachmentsContainer />}\n input={\n <ComposerPrimitive.Input\n data-slot=\"aui_composer-input\"\n placeholder={placeholder}\n disabled={disabled}\n submitMode=\"enter\"\n aria-label=\"Message input\"\n className=\"text-text-primary placeholder:text-text-secondary/80 max-h-[10lh] min-h-10 w-full resize-none overflow-y-auto rounded-lg border-none bg-transparent px-1 py-1 text-base leading-normal shadow-none outline-none disabled:cursor-not-allowed\"\n />\n }\n disabled={disabled}\n canSubmit={canSubmit}\n isRunning={isBusy && !forceDisabled}\n onSubmit={submit}\n onCancel={\n canManageSession\n ? () => {\n resetBusy();\n void cancel();\n }\n : undefined\n }\n onAttach={canManageSession ? () => fileInputRef.current?.click() : undefined}\n />\n </ComposerPrimitive.Root>\n </ComposerPrimitive.AttachmentDropzone>\n </>\n );\n}\n\nfunction ComposerWithOptionalDraft({\n placeholder,\n forceDisabled = false,\n connectedToBanner = false,\n}: {\n placeholder: string;\n forceDisabled?: boolean;\n connectedToBanner?: boolean;\n}) {\n const shell = useOptionalShellMode();\n const parentLeftSection = useSlot('ComposerLeftSection');\n const parentRightSection = useSlot('ComposerRightSection');\n const usesDefaultLeftSection = useSlotIsDefault('ComposerLeftSection');\n const usesDefaultRightSection = useSlotIsDefault('ComposerRightSection');\n const DraftComposerLeftSection = useSlot('DraftComposerLeftSection');\n const DraftComposerRightSection = useSlot('DraftComposerRightSection');\n const canMutateSpec = shell?.mode.status === 'active' && shell.mode.isMutable;\n\n if (canMutateSpec) {\n return (\n <DraftCatalogProvider>\n <SlotsProvider\n overrides={{\n ComposerLeftSection: usesDefaultLeftSection ? DraftComposerLeftSection : parentLeftSection,\n ComposerRightSection: usesDefaultRightSection ? DraftComposerRightSection : parentRightSection,\n }}\n >\n <ComposerBody placeholder={placeholder} forceDisabled={forceDisabled} connectedToBanner={connectedToBanner} />\n </SlotsProvider>\n </DraftCatalogProvider>\n );\n }\n\n return <ComposerBody placeholder={placeholder} forceDisabled={forceDisabled} connectedToBanner={connectedToBanner} />;\n}\n\nexport function ComposerContainer({\n placeholder = 'Ask anything... (Shift+Enter for new line)',\n}: ComposerContainerProps) {\n const pauseView = useComposerPauseView();\n const canManageSession = useActiveSessionCanManage();\n\n if (pauseView.kind === 'mcp') {\n return <McpAuthContainer disabled={!canManageSession} />;\n }\n if (pauseView.kind === 'custom') {\n return <CustomActionContainer disabled={!canManageSession} />;\n }\n if (pauseView.kind === 'ask-user') {\n return <AskUserContainer disabled={!canManageSession} />;\n }\n if (pauseView.kind === 'approval') {\n return (\n <div data-slot=\"aui_composer-approval-pause\" className=\"flex w-full flex-col\">\n <ApprovalNavContainer />\n <ComposerWithOptionalDraft placeholder={placeholder} forceDisabled connectedToBanner />\n </div>\n );\n }\n\n return <ComposerWithOptionalDraft placeholder={placeholder} />;\n}\n","'use client';\n\nimport { useTrueFoundryHistoryPagination } from '@truefoundry/assistant-ui-runtime';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useSlot } from '../theme/SlotsProvider.js';\n\n/** How close to the viewport top (px) before the next older page is fetched. */\nconst TOP_THRESHOLD_PX = 200;\n\nconst VIEWPORT_SELECTOR = '[data-slot=\"aui_thread-viewport\"]';\n\n/**\n * Renders `HistoryLoader` at the top of the message list and fetches\n * the next older history page when the user scrolls near it. Scroll position\n * is preserved across the prepend so the list doesn't jump.\n *\n * Must be rendered inside `ThreadViewportShell` (it locates the scroll root\n * via the `aui_thread-viewport` data-slot on its nearest scrollable ancestor).\n */\nexport function HistoryLoaderContainer() {\n const HistoryLoader = useSlot('HistoryLoader');\n const { hasOlderHistory, isLoadingOlderHistory, loadOlderHistory } = useTrueFoundryHistoryPagination();\n\n const [sentinel, setSentinel] = useState<HTMLDivElement | null>(null);\n const inflightRef = useRef(false);\n\n const maybeLoadOlder = useCallback(async () => {\n if (inflightRef.current) return;\n inflightRef.current = true;\n\n const viewport = sentinel?.closest<HTMLElement>(VIEWPORT_SELECTOR) ?? null;\n const prevScrollHeight = viewport?.scrollHeight ?? 0;\n const prevScrollTop = viewport?.scrollTop ?? 0;\n\n try {\n await loadOlderHistory();\n // Wait for React to commit the prepended messages, then restore the\n // user's anchor so the list doesn't jump to the oldest message.\n requestAnimationFrame(() => {\n if (viewport == null) return;\n const delta = viewport.scrollHeight - prevScrollHeight;\n if (delta > 0) {\n viewport.scrollTo({ top: prevScrollTop + delta, behavior: 'instant' });\n }\n });\n } catch {\n // Runtime surfaces the error via onError; the sentinel stays retryable.\n } finally {\n inflightRef.current = false;\n }\n }, [sentinel, loadOlderHistory]);\n\n useEffect(() => {\n if (sentinel == null || !hasOlderHistory) return;\n\n const viewport = sentinel.closest<HTMLElement>(VIEWPORT_SELECTOR);\n const observer = new IntersectionObserver(\n entries => {\n if (entries.some(entry => entry.isIntersecting)) {\n void maybeLoadOlder();\n }\n },\n { root: viewport, rootMargin: `${TOP_THRESHOLD_PX}px 0px 0px 0px` },\n );\n observer.observe(sentinel);\n return () => observer.disconnect();\n }, [sentinel, hasOlderHistory, maybeLoadOlder]);\n\n if (!hasOlderHistory) return null;\n\n return <HistoryLoader ref={setSentinel} isLoading={isLoadingOlderHistory} />;\n}\n","'use client';\n\nimport { useTrueFoundryResumeUnavailable } from '@truefoundry/assistant-ui-runtime';\n\nimport { useSlot } from '../theme/SlotsProvider.js';\n\nexport function ResumeUnavailableContainer() {\n const ResumeUnavailable = useSlot('ResumeUnavailable');\n const resumeUnavailable = useTrueFoundryResumeUnavailable();\n\n if (!resumeUnavailable) return null;\n\n return <ResumeUnavailable />;\n}\n","'use client';\n\nimport { useComposerCancel, useComposerSend, useThreadIsRunning } from '@assistant-ui/core/react';\nimport { ComposerPrimitive, MessagePrimitive, useAuiState } from '@assistant-ui/react';\n\nimport { Button } from '../atoms/primitives/Button.js';\nimport { useActiveSessionCanManage } from '../hooks/useResourcePermissions.js';\nimport { useSlot } from '../theme/SlotsProvider.js';\nimport { MessageAttachmentsContainer } from './AttachmentsContainer.js';\n\nfunction ReadOnlyMessageAttachments() {\n const hasAttachments = useAuiState(s => (s.message.attachments?.length ?? 0) > 0);\n if (!hasAttachments) {\n return null;\n }\n return (\n <div className=\"pointer-events-none mb-2 opacity-90\">\n <MessageAttachmentsContainer />\n </div>\n );\n}\n\nexport function UserEditComposerContainer() {\n const UserMessageEdit = useSlot('UserMessageEdit');\n const MessageTimestamp = useSlot('MessageTimestamp');\n const isRunning = useThreadIsRunning();\n const canManageSession = useActiveSessionCanManage();\n const createdAt = useAuiState(s => s.message.createdAt);\n const { cancel, disabled: cancelDisabled } = useComposerCancel();\n const { disabled: sendDisabled } = useComposerSend();\n\n return (\n <MessagePrimitive.Root data-role=\"user\">\n <ComposerPrimitive.Root\n data-slot=\"aui_user-edit-composer-root\"\n className=\"fade-in slide-in-from-bottom-1 animate-in flex w-full justify-end px-2 duration-150\"\n >\n <UserMessageEdit\n timestamp={<MessageTimestamp createdAt={createdAt} />}\n attachments={<ReadOnlyMessageAttachments />}\n input={\n <div className=\"mt-1 rounded border border-border bg-secondary-bg p-2 text-text-primary\">\n <ComposerPrimitive.Input\n data-slot=\"aui_user-edit-input\"\n disabled={isRunning || !canManageSession}\n submitMode=\"enter\"\n aria-label=\"Edit message\"\n className=\"max-h-32 min-h-10 w-full resize-none border-none bg-transparent p-0 text-base leading-[1.34] outline-none focus:shadow-none\"\n />\n </div>\n }\n footer={\n <div className=\"flex items-center justify-end gap-2\">\n <Button.Secondary type=\"button\" disabled={cancelDisabled} onClick={cancel}>\n Cancel\n </Button.Secondary>\n <ComposerPrimitive.Send asChild>\n <Button.Primary type=\"submit\" disabled={sendDisabled || isRunning || !canManageSession}>\n Save &amp; Rerun\n </Button.Primary>\n </ComposerPrimitive.Send>\n </div>\n }\n />\n </ComposerPrimitive.Root>\n </MessagePrimitive.Root>\n );\n}\n","'use client';\n\nimport { ThreadPrimitive, useAuiState } from '@assistant-ui/react';\nimport { useEffect, type ReactNode } from 'react';\nimport { preloadMarkdownOpenUI } from '../atoms/Markdown.js';\nimport { ComposerBusyProvider } from '../hooks/useComposerBusyState.js';\nimport { useSyncSessionTitle } from '../hooks/useSyncSessionTitle.js';\nimport { useOptionalShellMode } from '../server/ShellModeContext.js';\nimport { useSlot } from '../theme/SlotsProvider.js';\nimport { isNewChatView } from '../utils/isNewChatView.js';\nimport { ApprovalFocusProvider } from './approvalFocus.js';\nimport { AssistantMessageContainer } from './AssistantMessageContainer.js';\nimport { HistoryLoaderContainer } from './HistoryLoaderContainer.js';\nimport { ResumeUnavailableContainer } from './ResumeUnavailableContainer.js';\nimport { UserEditComposerContainer } from './UserEditComposerContainer.js';\nimport { UserMessageContainer } from './UserMessageContainer.js';\n\nexport { isNewChatView } from '../utils/isNewChatView.js';\n\n/** Mount-only lift. Keyed by message.id via ThreadPrimitive.Messages — not content (streaming). */\nfunction AnimatedMessageShell({ children }: { children: ReactNode }) {\n return <div className=\"animate-in fade-in slide-in-from-bottom-1 fill-mode-both duration-200\">{children}</div>;\n}\n\nfunction ThreadMessage({ isEditing }: { isEditing: boolean }) {\n const role = useAuiState(s => s.message.role);\n if (role === 'user') {\n if (isEditing) {\n return <UserEditComposerContainer />;\n }\n return <UserMessageContainer />;\n }\n return <AssistantMessageContainer />;\n}\n\nexport type ThreadContainerProps = {\n /** Composer for the empty-welcome and docked bottom areas. `<Thread />` passes `<ComposerContainer />`. */\n composer?: ReactNode;\n};\n\nexport function ThreadContainer({ composer }: ThreadContainerProps) {\n useEffect(() => {\n void preloadMarkdownOpenUI();\n }, []);\n useSyncSessionTitle();\n\n const shell = useOptionalShellMode();\n const WelcomeScreen = useSlot('WelcomeScreen');\n const MessageListSkeleton = useSlot('MessageListSkeleton');\n const ScrollToBottomButton = useSlot('ScrollToBottomButton');\n const MessageGroup = useSlot('MessageGroup');\n const ThreadComposerAreaShell = useSlot('ThreadComposerAreaShell');\n const ThreadRootShell = useSlot('ThreadRootShell');\n const ThreadViewportShell = useSlot('ThreadViewportShell');\n\n const isEmpty = useAuiState(isNewChatView);\n const isLoading = useAuiState(s => s.thread.isLoading);\n const welcomeHeading =\n shell?.mode.status === 'active'\n ? shell.mode.agentName != null && shell.mode.agentName.length > 0\n ? shell.mode.agentName\n : shell.mode.isMutable && shell.mode.isCreateAgent\n ? 'Start building a new Agent'\n : undefined\n : undefined;\n\n return (\n <ComposerBusyProvider>\n <ApprovalFocusProvider>\n <ThreadPrimitive.Root asChild>\n <ThreadRootShell>\n <ThreadPrimitive.Viewport asChild autoScroll>\n <ThreadViewportShell isEmpty={isEmpty}>\n {isEmpty && <WelcomeScreen heading={welcomeHeading} />}\n {isEmpty && !isLoading && composer}\n {isLoading ? (\n <MessageListSkeleton />\n ) : (\n !isEmpty && (\n <>\n <HistoryLoaderContainer />\n <MessageGroup>\n <ThreadPrimitive.Messages>\n {({ message }) => (\n <AnimatedMessageShell>\n <ThreadMessage isEditing={message.role === 'user' && message.composer.isEditing} />\n </AnimatedMessageShell>\n )}\n </ThreadPrimitive.Messages>\n <ResumeUnavailableContainer />\n </MessageGroup>\n </>\n )\n )}\n </ThreadViewportShell>\n </ThreadPrimitive.Viewport>\n\n {!isLoading && !isEmpty && (\n <ThreadComposerAreaShell isEmpty={isEmpty}>\n <ThreadPrimitive.ScrollToBottom asChild>\n <ScrollToBottomButton />\n </ThreadPrimitive.ScrollToBottom>\n {composer}\n </ThreadComposerAreaShell>\n )}\n </ThreadRootShell>\n </ThreadPrimitive.Root>\n </ApprovalFocusProvider>\n </ComposerBusyProvider>\n );\n}\n","'use client';\n\nimport { useThreadIsRunning } from '@assistant-ui/core/react';\nimport { useEffect, useRef } from 'react';\n\nimport { useAui, useAuiState } from '../assistant-ui.js';\nimport { useOptionalServer } from '../server/ServerContext.js';\n\n/**\n * After a turn ends, read `session.title` from GET /sessions/{id} and rename the\n * thread-list row. Initialize only stores `remoteId`, so first chats stay\n * \"New Chat\" until this runs.\n */\nexport function useSyncSessionTitle(): void {\n const server = useOptionalServer();\n const aui = useAui();\n const remoteId = useAuiState(s => s.threadListItem.remoteId);\n const title = useAuiState(s => s.threadListItem.title);\n const isRunning = useThreadIsRunning();\n const wasRunningRef = useRef(false);\n const syncedRemoteIdRef = useRef<string | undefined>(undefined);\n\n useEffect(() => {\n syncedRemoteIdRef.current = undefined;\n }, [remoteId]);\n\n useEffect(() => {\n const finishedTurn = wasRunningRef.current && !isRunning;\n wasRunningRef.current = isRunning;\n\n if (!finishedTurn || server == null || remoteId == null) {\n return;\n }\n if (syncedRemoteIdRef.current === remoteId) {\n return;\n }\n // History rows already carry a title; only fill blank / \"new\" local rows.\n if (title != null && title.trim() !== '') {\n syncedRemoteIdRef.current = remoteId;\n return;\n }\n\n let cancelled = false;\n void server\n .getSession({ sessionId: remoteId })\n .then(session => {\n if (cancelled) return;\n const nextTitle = typeof session.title === 'string' ? session.title.trim() : '';\n if (nextTitle.length === 0) return;\n syncedRemoteIdRef.current = remoteId;\n return aui.threadListItem().rename(nextTitle);\n })\n .catch(() => undefined);\n\n return () => {\n cancelled = true;\n };\n }, [aui, isRunning, remoteId, server, title]);\n}\n","'use client';\n\nimport { ComposerContainer } from './ComposerContainer.js';\nimport { ThreadContainer } from './ThreadContainer.js';\n\n/** The full assembled thread view: message list + composer. */\nexport function Thread() {\n return <ThreadContainer composer={<ComposerContainer />} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,+BAA+B;AACxC,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAqBlD,SAAS,iBAAmC;AACjD,QAAM,EAAE,QAAQ,IAAI,wBAAwB;AAC5C,QAAM,WAAW,yBAAyB;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAuD;AAAA,IACvF,YAAY;AAAA,IACZ,OAAO;AAAA,EACT,CAAC;AACD,QAAM,eAAe,OAAsB,IAAI;AAE/C,QAAM,QAAQ,QAAQ;AACtB,QAAM,eACJ,UAAU,cAAc,OAAO,KAAK,QAAQ,UAAU,UAAQ,KAAK,eAAe,UAAU,UAAU;AACxG,QAAM,YAAY,gBAAgB,IAAI,eAAe,UAAU,IAAI,IAAI,KAAK,IAAI,UAAU,OAAO,QAAQ,CAAC;AAC1G,QAAM,YAAY,QAAQ,SAAS,GAAG;AAEtC,YAAU,MAAM;AACd,UAAM,aAAa,aAAa;AAChC,QAAI,UAAU,eAAe,cAAc,UAAU,UAAU,UAAW;AAC1E,iBAAa,EAAE,YAAY,OAAO,UAAU,CAAC;AAAA,EAC/C,GAAG,CAAC,WAAW,WAAW,UAAU,YAAY,UAAU,KAAK,CAAC;AAEhE,YAAU,MAAM;AACd,QAAI,aAAa,QAAQ,YAAY,MAAM;AACzC,UAAI,aAAa,KAAM,cAAa,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AAA,MACC;AAAA,OACH;AAAA,KAEJ,GACF,GACF,GACF;AAEJ;;;AEvGoC,gBAAAI,aAAA;AAD7B,SAAS,SAAS;AACvB,SAAO,gBAAAA,MAAC,mBAAgB,UAAU,gBAAAA,MAAC,qBAAkB,GAAI;AAC3D;","names":["useCallback","useEffect","useState","jsx","useState","useEffect","useCallback","useAuiState","useTrueFoundryApprovals","useTrueFoundryToolResponses","useAuiState","useTrueFoundryToolResponses","useTrueFoundryApprovals","useThreadIsRunning","useTrueFoundryToolResponses","useCallback","jsx","useTrueFoundryToolResponses","useThreadIsRunning","useCallback","useThreadIsRunning","useEffect","useRef","useState","jsx","useState","useRef","useEffect","useThreadIsRunning","useAui","useAuiState","useRef","jsx","useAui","useAuiState","useRef","useCallback","useEffect","useRef","useState","jsx","useState","useRef","useCallback","useEffect","jsx","useThreadIsRunning","ComposerPrimitive","useAuiState","jsx","jsxs","useAuiState","useThreadIsRunning","ComposerPrimitive","useAuiState","useEffect","useThreadIsRunning","useEffect","useRef","useThreadIsRunning","useRef","useEffect","Fragment","jsx","jsxs","useAuiState","useEffect","jsx"]}