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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/README.md +35 -12
  3. package/dist/AgentCodeSnippets-RJBB4DDE.js +89 -0
  4. package/dist/AgentCodeSnippets-RJBB4DDE.js.map +1 -0
  5. package/dist/AgentMetricChart-UPGSJ2WP.js +15 -0
  6. package/dist/AgentOverview-U5WIQXZN.js +169 -0
  7. package/dist/AgentOverview-U5WIQXZN.js.map +1 -0
  8. package/dist/AgentSessionEventTimeline-GRGIQTRE.js +88 -0
  9. package/dist/AgentSessionEventTimeline-GRGIQTRE.js.map +1 -0
  10. package/dist/AgentSessionEventTimelineChart-GNF4VOUT.js +591 -0
  11. package/dist/AgentSessionEventTimelineChart-GNF4VOUT.js.map +1 -0
  12. package/dist/AgentSessions-5OTF2BUW.js +323 -0
  13. package/dist/AgentSessions-5OTF2BUW.js.map +1 -0
  14. package/dist/{ConnectorSettings-FXQ5B7TN.js → ConnectorSettings-HDKGLDCY.js} +163 -125
  15. package/dist/ConnectorSettings-HDKGLDCY.js.map +1 -0
  16. package/dist/{DockLayout-LBNQJZNF.js → DockLayout-D2FPQCAL.js} +11 -10
  17. package/dist/{DockLayout-LBNQJZNF.js.map → DockLayout-D2FPQCAL.js.map} +1 -1
  18. package/dist/DrawerLayout-HUV7RAWL.js +186 -0
  19. package/dist/DrawerLayout-HUV7RAWL.js.map +1 -0
  20. package/dist/{ModelSettings-4L4LOQJA.js → ModelSettings-VNQ7HPKH.js} +23 -27
  21. package/dist/ModelSettings-VNQ7HPKH.js.map +1 -0
  22. package/dist/OpenUiFenceBlock-KPZFLUSC.js +9 -0
  23. package/dist/OpenUiFenceBlock-KPZFLUSC.js.map +1 -0
  24. package/dist/{SandboxSettings-Z4ZG6ZX4.js → SandboxSettings-ZLXGMFBF.js} +18 -20
  25. package/dist/SandboxSettings-ZLXGMFBF.js.map +1 -0
  26. package/dist/SchedulesPage-QKYI2Z3A.js +15 -0
  27. package/dist/SchedulesPage-QKYI2Z3A.js.map +1 -0
  28. package/dist/{SettingsBuilder-WF7ZWKQW.js → SettingsBuilder-RVVYXOJW.js} +27 -23
  29. package/dist/SettingsBuilder-RVVYXOJW.js.map +1 -0
  30. package/dist/ShellRouteSync-SJXFKUAJ.js +390 -0
  31. package/dist/ShellRouteSync-SJXFKUAJ.js.map +1 -0
  32. package/dist/SidebarLayout-KYA76FQ7.js +330 -0
  33. package/dist/SidebarLayout-KYA76FQ7.js.map +1 -0
  34. package/dist/{SkillSettings-3EPPC3IT.js → SkillSettings-7OHT7FPI.js} +25 -21
  35. package/dist/SkillSettings-7OHT7FPI.js.map +1 -0
  36. package/dist/{TrueForgeUIWithRouter-NZ4FGPE4.js → TrueForgeUIWithRouter-LKG4XLW6.js} +14 -10
  37. package/dist/{TrueForgeUIWithRouter-NZ4FGPE4.js.map → TrueForgeUIWithRouter-LKG4XLW6.js.map} +1 -1
  38. package/dist/{WidgetLayout-3QZ357FL.js → WidgetLayout-W2RGGOQ3.js} +17 -13
  39. package/dist/WidgetLayout-W2RGGOQ3.js.map +1 -0
  40. package/dist/chunk-2GIZY3JJ.js +1062 -0
  41. package/dist/chunk-2GIZY3JJ.js.map +1 -0
  42. package/dist/chunk-2QTH6JHX.js +217 -0
  43. package/dist/chunk-2QTH6JHX.js.map +1 -0
  44. package/dist/{chunk-FJ5RSSMA.js → chunk-3ZW74FHC.js} +118 -164
  45. package/dist/chunk-3ZW74FHC.js.map +1 -0
  46. package/dist/chunk-67ZO7Z2W.js +184 -0
  47. package/dist/chunk-67ZO7Z2W.js.map +1 -0
  48. package/dist/{chunk-CFLVPV5M.js → chunk-7AAO4UDQ.js} +8 -2
  49. package/dist/chunk-7AAO4UDQ.js.map +1 -0
  50. package/dist/{chunk-B52K63AW.js → chunk-CG75X77Q.js} +2 -2
  51. package/dist/chunk-DJUFS2BW.js +27 -0
  52. package/dist/chunk-DJUFS2BW.js.map +1 -0
  53. package/dist/chunk-DPPOEFBD.js +517 -0
  54. package/dist/chunk-DPPOEFBD.js.map +1 -0
  55. package/dist/chunk-EPAL2HD5.js +1629 -0
  56. package/dist/chunk-EPAL2HD5.js.map +1 -0
  57. package/dist/chunk-GG23N2GW.js +15018 -0
  58. package/dist/chunk-GG23N2GW.js.map +1 -0
  59. package/dist/chunk-JCL3Q7RW.js +587 -0
  60. package/dist/chunk-JCL3Q7RW.js.map +1 -0
  61. package/dist/chunk-JKEBMGLH.js +682 -0
  62. package/dist/chunk-JKEBMGLH.js.map +1 -0
  63. package/dist/chunk-KSGNKS2D.js +296 -0
  64. package/dist/chunk-KSGNKS2D.js.map +1 -0
  65. package/dist/{chunk-WREC7D54.js → chunk-PCI6VMB5.js} +268 -48
  66. package/dist/chunk-PCI6VMB5.js.map +1 -0
  67. package/dist/chunk-PQ7VWBQQ.js +121 -0
  68. package/dist/chunk-PQ7VWBQQ.js.map +1 -0
  69. package/dist/chunk-RDXBMTP5.js +32 -0
  70. package/dist/chunk-RDXBMTP5.js.map +1 -0
  71. package/dist/chunk-T6QQV5LK.js +238 -0
  72. package/dist/chunk-T6QQV5LK.js.map +1 -0
  73. package/dist/chunk-Y6S4OVVQ.js +16 -0
  74. package/dist/chunk-Y6S4OVVQ.js.map +1 -0
  75. package/dist/{createTrueFoundryServer-B72bU-J7.d.ts → createTrueFoundryServer-B_FYhSdn.d.ts} +18 -4
  76. package/dist/index.d.ts +1287 -46
  77. package/dist/index.js +266 -63
  78. package/dist/index.js.map +1 -1
  79. package/dist/plugins/trueforge-agent-server-adapter/index.d.ts +590 -11
  80. package/dist/plugins/trueforge-agent-server-adapter/index.js +607 -204
  81. package/dist/plugins/trueforge-agent-server-adapter/index.js.map +1 -1
  82. package/dist/styles.css +1 -1
  83. package/package.json +10 -8
  84. package/dist/ConnectorSettings-FXQ5B7TN.js.map +0 -1
  85. package/dist/DrawerLayout-Q6UK4VMI.js +0 -159
  86. package/dist/DrawerLayout-Q6UK4VMI.js.map +0 -1
  87. package/dist/ModelSettings-4L4LOQJA.js.map +0 -1
  88. package/dist/OpenUiFenceBlock-6UIIAVBX.js +0 -9
  89. package/dist/SandboxSettings-Z4ZG6ZX4.js.map +0 -1
  90. package/dist/SettingsBuilder-WF7ZWKQW.js.map +0 -1
  91. package/dist/ShellRouteSync-T4WLY57Q.js +0 -172
  92. package/dist/ShellRouteSync-T4WLY57Q.js.map +0 -1
  93. package/dist/SidebarLayout-3WZ3CVON.js +0 -256
  94. package/dist/SidebarLayout-3WZ3CVON.js.map +0 -1
  95. package/dist/SkillSettings-3EPPC3IT.js.map +0 -1
  96. package/dist/WidgetLayout-3QZ357FL.js.map +0 -1
  97. package/dist/chunk-36KOSC2J.js +0 -567
  98. package/dist/chunk-36KOSC2J.js.map +0 -1
  99. package/dist/chunk-3S6KHO7H.js +0 -2121
  100. package/dist/chunk-3S6KHO7H.js.map +0 -1
  101. package/dist/chunk-7L63OK3O.js +0 -91
  102. package/dist/chunk-7L63OK3O.js.map +0 -1
  103. package/dist/chunk-CFLVPV5M.js.map +0 -1
  104. package/dist/chunk-FJ5RSSMA.js.map +0 -1
  105. package/dist/chunk-OSV3HI5M.js +0 -6891
  106. package/dist/chunk-OSV3HI5M.js.map +0 -1
  107. package/dist/chunk-WQULF5AT.js +0 -460
  108. package/dist/chunk-WQULF5AT.js.map +0 -1
  109. package/dist/chunk-WREC7D54.js.map +0 -1
  110. package/dist/chunk-YIWUG6MC.js +0 -101
  111. package/dist/chunk-YIWUG6MC.js.map +0 -1
  112. package/dist/chunk-ZXOADNF3.js +0 -75
  113. package/dist/chunk-ZXOADNF3.js.map +0 -1
  114. /package/dist/{OpenUiFenceBlock-6UIIAVBX.js.map → AgentMetricChart-UPGSJ2WP.js.map} +0 -0
  115. /package/dist/{chunk-B52K63AW.js.map → chunk-CG75X77Q.js.map} +0 -0
@@ -0,0 +1,390 @@
1
+ "use client";
2
+ import {
3
+ buildPath,
4
+ matchLocation,
5
+ placesEqual,
6
+ sanitizeSearchForPlace
7
+ } from "./chunk-2QTH6JHX.js";
8
+ import {
9
+ sessionIsCreateAgent
10
+ } from "./chunk-RDXBMTP5.js";
11
+ import {
12
+ findAgentByName
13
+ } from "./chunk-T6QQV5LK.js";
14
+ import {
15
+ libraryAgentId,
16
+ toEffectiveRoutes,
17
+ useOptionalAgentSessionsServer,
18
+ useOptionalCatalogServer,
19
+ useOptionalScheduleServer,
20
+ useOptionalServer,
21
+ useServerCapabilities,
22
+ useServerCapabilitiesSettled,
23
+ useShellMode
24
+ } from "./chunk-2GIZY3JJ.js";
25
+
26
+ // src/routing/ShellRouteSync.tsx
27
+ import { useCallback, useEffect, useMemo, useRef } from "react";
28
+ import { useLocation, useNavigate } from "react-router-dom";
29
+
30
+ // src/utils/historyAgentSearch.ts
31
+ var TRY_AGENT_NAME_QUERY = "try_agent_name";
32
+ var HISTORY_AGENT_NAME_QUERY = "history_agent_name";
33
+ function nonEmpty(value) {
34
+ return value != null && value.length > 0 ? value : null;
35
+ }
36
+ function readHistoryAgentSearch(search) {
37
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
38
+ const tryAgentName = nonEmpty(params.get(TRY_AGENT_NAME_QUERY));
39
+ if (tryAgentName != null) return { intent: "try-agent", agentName: tryAgentName };
40
+ const historyAgentName = nonEmpty(params.get(HISTORY_AGENT_NAME_QUERY));
41
+ return historyAgentName == null ? null : { intent: "history", agentName: historyAgentName };
42
+ }
43
+ function writeHistoryAgentSearch(params, next) {
44
+ params.delete(TRY_AGENT_NAME_QUERY);
45
+ params.delete(HISTORY_AGENT_NAME_QUERY);
46
+ if (next == null) return;
47
+ params.set(next.intent === "try-agent" ? TRY_AGENT_NAME_QUERY : HISTORY_AGENT_NAME_QUERY, next.agentName);
48
+ }
49
+ function updateHistoryAgentSearch(search, next) {
50
+ const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
51
+ writeHistoryAgentSearch(params, next);
52
+ const updated = params.toString();
53
+ return updated.length > 0 ? `?${updated}` : "";
54
+ }
55
+
56
+ // src/routing/derivePlace.ts
57
+ function deriveChatPlace(snapshot) {
58
+ const sessionId = snapshot.activeRemoteId ?? snapshot.pendingSessionId;
59
+ if (sessionId != null) return { type: "session", sessionId };
60
+ const { mode, agentConfigMode } = snapshot;
61
+ if (mode.status === "active" && mode.isMutable && mode.isCreateAgent) {
62
+ return { type: "buildAgent" };
63
+ }
64
+ if (mode.status === "active" && !mode.isMutable && agentConfigMode !== "SingleAgent") {
65
+ const agentName = mode.agentName ?? mode.agentId;
66
+ if (agentName != null) return { type: "agent", agentName };
67
+ }
68
+ return { type: "root" };
69
+ }
70
+ function derivePlace(snapshot) {
71
+ if (snapshot.settingsOpen) return { type: "settings" };
72
+ if (snapshot.schedulesOpen) return { type: "schedules" };
73
+ if (snapshot.sessionsOpen) return { type: "sessionsBrowser" };
74
+ if (snapshot.libraryOpen && snapshot.libraryAgentId != null) {
75
+ return { type: "libraryAgent", agentId: snapshot.libraryAgentId };
76
+ }
77
+ if (snapshot.libraryOpen) return { type: "library" };
78
+ return deriveChatPlace(snapshot);
79
+ }
80
+
81
+ // src/routing/ShellRouteSync.tsx
82
+ function placeOwnsHistoryAgentSearch(place) {
83
+ return place.type === "root" || place.type === "agent" || place.type === "session";
84
+ }
85
+ function ShellRouteSync({
86
+ routes,
87
+ activeRemoteId,
88
+ initialSettingsOpen
89
+ }) {
90
+ const shell = useShellMode();
91
+ const server = useOptionalServer();
92
+ const catalog = useOptionalCatalogServer();
93
+ const sessions = useOptionalAgentSessionsServer();
94
+ const schedules = useOptionalScheduleServer();
95
+ const capabilities = useServerCapabilities();
96
+ const capabilitiesSettled = useServerCapabilitiesSettled();
97
+ const navigate = useNavigate();
98
+ const location = useLocation();
99
+ const effectiveRoutes = useMemo(
100
+ () => toEffectiveRoutes({ routes, catalog, capabilities, sessions, schedules }),
101
+ [routes, catalog, capabilities, sessions, schedules]
102
+ );
103
+ const settingsChromeEnabled = effectiveRoutes.settings != null;
104
+ const routeGatesKey = [
105
+ effectiveRoutes.settings,
106
+ effectiveRoutes.sessionsBrowser,
107
+ effectiveRoutes.libraryAgent,
108
+ effectiveRoutes.schedules
109
+ ].join("\0");
110
+ const snapshot = {
111
+ settingsOpen: shell.settingsOpen,
112
+ libraryOpen: shell.libraryOpen,
113
+ sessionsOpen: shell.sessionsOpen,
114
+ libraryAgentId: shell.libraryAgentId,
115
+ schedulesOpen: shell.schedulesOpen,
116
+ pendingSessionId: shell.pendingSessionId,
117
+ activeRemoteId,
118
+ mode: shell.mode,
119
+ agentConfigMode: shell.agentConfigMode
120
+ };
121
+ const place = derivePlace(snapshot);
122
+ const placeKey = JSON.stringify(place);
123
+ const selfNavPathRef = useRef(null);
124
+ const prevPlaceRef = useRef(null);
125
+ const appliedUrlPlaceRef = useRef(null);
126
+ const bootedRef = useRef(false);
127
+ const bootPlaceRef = useRef(null);
128
+ const bootHistoryAgentRef = useRef(null);
129
+ const requestedSessionRef = useRef(null);
130
+ const requestedHistoryAgentRef = useRef(null);
131
+ const shellSyncStartedRef = useRef(false);
132
+ const urlSyncStartedRef = useRef(false);
133
+ const openSession = useCallback(
134
+ (sessionId) => {
135
+ requestedSessionRef.current = sessionId;
136
+ if (server == null) {
137
+ shell.openHistorySession({ sessionId });
138
+ return;
139
+ }
140
+ void server.getSession({ sessionId }).then((session) => {
141
+ if (requestedSessionRef.current !== sessionId) return;
142
+ shell.openHistorySession({
143
+ sessionId,
144
+ isMutable: session.isMutable,
145
+ isCreateAgent: sessionIsCreateAgent(session),
146
+ ...session.agentName != null ? { agentName: session.agentName } : {}
147
+ });
148
+ }).catch(() => {
149
+ if (requestedSessionRef.current !== sessionId) return;
150
+ shell.openHistorySession({ sessionId });
151
+ });
152
+ },
153
+ [server, shell]
154
+ );
155
+ const applyHistoryAgentSearch = useCallback(
156
+ (next) => {
157
+ if (next == null) {
158
+ requestedHistoryAgentRef.current = null;
159
+ bootHistoryAgentRef.current = null;
160
+ shell.setHistoryAgentFilter(null);
161
+ return;
162
+ }
163
+ const requestKey = `${next.intent}\0${next.agentName}`;
164
+ const current = shell.historyAgentFilter;
165
+ if (current?.intent === next.intent && current.agentName === next.agentName && current.agentId != null) {
166
+ requestedHistoryAgentRef.current = null;
167
+ return;
168
+ }
169
+ requestedHistoryAgentRef.current = requestKey;
170
+ shell.setHistoryAgentFilter(next);
171
+ if (server == null) return;
172
+ void findAgentByName({ server, agentName: next.agentName }).then((agent) => {
173
+ if (requestedHistoryAgentRef.current !== requestKey) return;
174
+ if (agent == null) {
175
+ requestedHistoryAgentRef.current = null;
176
+ bootHistoryAgentRef.current = null;
177
+ shell.setHistoryAgentFilter(null);
178
+ return;
179
+ }
180
+ requestedHistoryAgentRef.current = null;
181
+ shell.setHistoryAgentFilter({
182
+ agentId: libraryAgentId(agent),
183
+ agentName: agent.name,
184
+ intent: next.intent
185
+ });
186
+ }).catch(() => {
187
+ if (requestedHistoryAgentRef.current !== requestKey) return;
188
+ requestedHistoryAgentRef.current = null;
189
+ bootHistoryAgentRef.current = null;
190
+ shell.setHistoryAgentFilter(null);
191
+ });
192
+ },
193
+ [server, shell]
194
+ );
195
+ const openAgent = useCallback(
196
+ (agentName) => {
197
+ shell.selectLibraryAgent({ isMutable: false, agentName });
198
+ applyHistoryAgentSearch({ intent: "try-agent", agentName });
199
+ },
200
+ [applyHistoryAgentSearch, shell]
201
+ );
202
+ const applyPlace = useCallback(
203
+ (target) => {
204
+ switch (target.type) {
205
+ case "settings":
206
+ shell.setSettingsOpen(true);
207
+ return;
208
+ case "library":
209
+ shell.setLibraryOpen(true);
210
+ return;
211
+ case "sessionsBrowser":
212
+ shell.setSessionsOpen(true);
213
+ return;
214
+ case "libraryAgent":
215
+ shell.openLibraryAgent(target.agentId);
216
+ return;
217
+ case "schedules":
218
+ shell.setSchedulesOpen(true);
219
+ return;
220
+ case "buildAgent":
221
+ shell.openAgentBuilder();
222
+ return;
223
+ case "session":
224
+ shell.setLibraryOpen(false);
225
+ if (shell.pendingSessionId === target.sessionId || activeRemoteId === target.sessionId) return;
226
+ openSession(target.sessionId);
227
+ return;
228
+ case "agent":
229
+ shell.setLibraryOpen(false);
230
+ openAgent(target.agentName);
231
+ return;
232
+ case "root":
233
+ shell.setSettingsOpen(false);
234
+ shell.setLibraryOpen(false);
235
+ shell.setSchedulesOpen(false);
236
+ switch (shell.agentConfigMode) {
237
+ case "AgentLibrary":
238
+ shell.openLibraryHome();
239
+ return;
240
+ case "AgentComposer":
241
+ case "AgentLibraryWithComposer":
242
+ shell.openDraft();
243
+ return;
244
+ case "SingleAgent":
245
+ shell.clearChat();
246
+ return;
247
+ }
248
+ }
249
+ },
250
+ [shell, activeRemoteId, openAgent, openSession]
251
+ );
252
+ useEffect(() => {
253
+ if (bootedRef.current) return;
254
+ const configuredUrlPlace = matchLocation({
255
+ pathname: location.pathname,
256
+ search: location.search,
257
+ routes
258
+ });
259
+ if (!capabilitiesSettled && configuredUrlPlace?.type === "settings") return;
260
+ bootedRef.current = true;
261
+ const urlPlace = matchLocation({
262
+ pathname: location.pathname,
263
+ search: location.search,
264
+ routes: effectiveRoutes
265
+ }) ?? { type: "root" };
266
+ const historyAgentSearch = urlPlace.type === "agent" ? { intent: "try-agent", agentName: urlPlace.agentName } : placeOwnsHistoryAgentSearch(urlPlace) ? readHistoryAgentSearch(location.search) : null;
267
+ bootHistoryAgentRef.current = historyAgentSearch;
268
+ appliedUrlPlaceRef.current = urlPlace;
269
+ const settingsOnBoot = settingsChromeEnabled && (initialSettingsOpen || urlPlace.type === "settings");
270
+ if (urlPlace.type === "settings") {
271
+ if (settingsChromeEnabled) shell.setSettingsOpen(true);
272
+ } else if (urlPlace.type === "library") {
273
+ shell.setLibraryOpen(true);
274
+ } else if (urlPlace.type === "sessionsBrowser") {
275
+ shell.setSessionsOpen(true);
276
+ } else if (urlPlace.type === "libraryAgent") {
277
+ shell.openLibraryAgent(urlPlace.agentId);
278
+ } else if (urlPlace.type === "schedules") {
279
+ shell.setSchedulesOpen(true);
280
+ } else {
281
+ const chatPlace = deriveChatPlace(snapshot);
282
+ if (!placesEqual(chatPlace, urlPlace)) applyPlace(urlPlace);
283
+ if (settingsOnBoot) shell.setSettingsOpen(true);
284
+ }
285
+ if (urlPlace.type !== "agent" && historyAgentSearch != null) {
286
+ applyHistoryAgentSearch(historyAgentSearch);
287
+ } else if (!placeOwnsHistoryAgentSearch(urlPlace)) {
288
+ applyHistoryAgentSearch(null);
289
+ }
290
+ const desiredPlace = settingsOnBoot ? { type: "settings" } : urlPlace;
291
+ bootPlaceRef.current = placesEqual(place, desiredPlace) ? null : desiredPlace;
292
+ const desiredPath = buildPath(desiredPlace, effectiveRoutes);
293
+ const desiredSearch = updateHistoryAgentSearch(
294
+ sanitizeSearchForPlace(desiredPlace, location.search),
295
+ historyAgentSearch
296
+ );
297
+ prevPlaceRef.current = desiredPlace;
298
+ if (desiredPath != null && (desiredPath !== location.pathname || desiredSearch !== location.search)) {
299
+ selfNavPathRef.current = desiredPath !== location.pathname ? desiredPath : null;
300
+ navigate({ pathname: desiredPath, search: desiredSearch, hash: location.hash }, { replace: true });
301
+ }
302
+ }, [capabilitiesSettled]);
303
+ useEffect(() => {
304
+ if (!bootedRef.current) return;
305
+ if (!shellSyncStartedRef.current) {
306
+ shellSyncStartedRef.current = true;
307
+ return;
308
+ }
309
+ const bootPlace = bootPlaceRef.current;
310
+ if (bootPlace != null) {
311
+ if (!placesEqual(place, bootPlace)) return;
312
+ bootPlaceRef.current = null;
313
+ }
314
+ const target = buildPath(place, effectiveRoutes);
315
+ if (target == null) return;
316
+ const basename = effectiveRoutes.basename.endsWith("/") ? effectiveRoutes.basename.slice(0, -1) : effectiveRoutes.basename;
317
+ const browserPathname = `${basename}${location.pathname}` || "/";
318
+ const latestSearch = window.location.pathname === browserPathname ? window.location.search : location.search;
319
+ const ownsHistoryAgentSearch = placeOwnsHistoryAgentSearch(place);
320
+ const historyAgentSearch = ownsHistoryAgentSearch ? shell.historyAgentFilter == null ? bootHistoryAgentRef.current : {
321
+ intent: shell.historyAgentFilter.intent,
322
+ agentName: shell.historyAgentFilter.agentName
323
+ } : null;
324
+ if (!ownsHistoryAgentSearch && shell.historyAgentFilter != null) {
325
+ requestedHistoryAgentRef.current = null;
326
+ shell.setHistoryAgentFilter(null);
327
+ }
328
+ if (shell.historyAgentFilter != null) bootHistoryAgentRef.current = null;
329
+ const targetSearch = updateHistoryAgentSearch(sanitizeSearchForPlace(place, latestSearch), historyAgentSearch);
330
+ const prev = prevPlaceRef.current;
331
+ prevPlaceRef.current = place;
332
+ if (target === location.pathname && targetSearch === location.search) return;
333
+ const replace = place.type === "session" && shell.pendingSessionId == null && prev != null && prev.type !== "session";
334
+ selfNavPathRef.current = target !== location.pathname ? target : null;
335
+ navigate({ pathname: target, search: targetSearch, hash: location.hash }, { replace });
336
+ }, [placeKey, routeGatesKey, shell.historyAgentFilter?.agentName, shell.historyAgentFilter?.intent]);
337
+ useEffect(() => {
338
+ if (!bootedRef.current) return;
339
+ if (!urlSyncStartedRef.current) {
340
+ urlSyncStartedRef.current = true;
341
+ return;
342
+ }
343
+ if (selfNavPathRef.current === location.pathname) {
344
+ selfNavPathRef.current = null;
345
+ appliedUrlPlaceRef.current = place;
346
+ return;
347
+ }
348
+ const urlPlace = matchLocation({
349
+ pathname: location.pathname,
350
+ search: location.search,
351
+ routes: effectiveRoutes
352
+ });
353
+ if (urlPlace == null) {
354
+ const rootPath = effectiveRoutes.root;
355
+ const rootSearch = sanitizeSearchForPlace({ type: "root" }, location.search);
356
+ selfNavPathRef.current = rootPath;
357
+ navigate({ pathname: rootPath, search: rootSearch, hash: location.hash }, { replace: true });
358
+ applyPlace({ type: "root" });
359
+ applyHistoryAgentSearch(readHistoryAgentSearch(rootSearch));
360
+ return;
361
+ }
362
+ const previousUrlPlace = appliedUrlPlaceRef.current;
363
+ appliedUrlPlaceRef.current = urlPlace;
364
+ if (previousUrlPlace == null || !placesEqual(previousUrlPlace, urlPlace)) {
365
+ if (urlPlace.type !== "settings" && shell.settingsOpen) {
366
+ shell.setSettingsOpen(false);
367
+ }
368
+ if (urlPlace.type !== "library" && urlPlace.type !== "libraryAgent" && shell.libraryOpen) {
369
+ shell.setLibraryOpen(false);
370
+ }
371
+ if (urlPlace.type !== "sessionsBrowser" && shell.sessionsOpen) {
372
+ shell.setSessionsOpen(false);
373
+ }
374
+ if (urlPlace.type !== "schedules" && shell.schedulesOpen) {
375
+ shell.setSchedulesOpen(false);
376
+ }
377
+ applyPlace(urlPlace);
378
+ }
379
+ if (urlPlace.type !== "agent" && placeOwnsHistoryAgentSearch(urlPlace)) {
380
+ applyHistoryAgentSearch(readHistoryAgentSearch(location.search));
381
+ } else if (!placeOwnsHistoryAgentSearch(urlPlace)) {
382
+ applyHistoryAgentSearch(null);
383
+ }
384
+ }, [location.pathname, location.search]);
385
+ return null;
386
+ }
387
+ export {
388
+ ShellRouteSync
389
+ };
390
+ //# sourceMappingURL=ShellRouteSync-SJXFKUAJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routing/ShellRouteSync.tsx","../src/utils/historyAgentSearch.ts","../src/routing/derivePlace.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useLocation, useNavigate } from 'react-router-dom';\n\nimport { sessionIsCreateAgent } from '../atoms/lib/sessionCreateAgent.js';\nimport { findAgentByName } from '../atoms/lib/useSearchAgentsList.js';\nimport {\n useOptionalAgentSessionsServer,\n useOptionalCatalogServer,\n useOptionalScheduleServer,\n useOptionalServer,\n useServerCapabilities,\n useServerCapabilitiesSettled,\n} from '../server/ServerContext.js';\nimport { libraryAgentId, useShellMode } from '../server/ShellModeContext.js';\nimport { toEffectiveRoutes } from '../server/serverChrome.js';\nimport {\n readHistoryAgentSearch,\n updateHistoryAgentSearch,\n type HistoryAgentSearch,\n} from '../utils/historyAgentSearch.js';\nimport { deriveChatPlace, derivePlace } from './derivePlace.js';\nimport { buildPath, matchLocation, placesEqual, sanitizeSearchForPlace } from './paths.js';\nimport type { ResolvedRoutes, RoutePlace, ShellSnapshot } from './types.js';\n\n// Filter intent follows chat history across chat/session URLs, but must not leak into unrelated surfaces.\nfunction placeOwnsHistoryAgentSearch(place: RoutePlace): boolean {\n return place.type === 'root' || place.type === 'agent' || place.type === 'session';\n}\n\n/**\n * Single bidirectional bridge between shell state and the URL. Mounted under\n * `ShellModeProvider` but outside the keyed chat runtime so boot applies once.\n */\nexport function ShellRouteSync({\n routes,\n activeRemoteId,\n initialSettingsOpen,\n}: {\n routes: ResolvedRoutes;\n activeRemoteId: string | undefined;\n initialSettingsOpen: boolean;\n}) {\n const shell = useShellMode();\n const server = useOptionalServer();\n const catalog = useOptionalCatalogServer();\n const sessions = useOptionalAgentSessionsServer();\n const schedules = useOptionalScheduleServer();\n const capabilities = useServerCapabilities();\n const capabilitiesSettled = useServerCapabilitiesSettled();\n const navigate = useNavigate();\n const location = useLocation();\n // Same gates as sidebar chrome: missing optional ports unregister their paths.\n const effectiveRoutes = useMemo(\n () => toEffectiveRoutes({ routes, catalog, capabilities, sessions, schedules }),\n [routes, catalog, capabilities, sessions, schedules],\n );\n const settingsChromeEnabled = effectiveRoutes.settings != null;\n // Gate identity only — avoid re-syncing when capabilities object identity churns\n // without changing which paths are registered (would clobber window share query).\n const routeGatesKey = [\n effectiveRoutes.settings,\n effectiveRoutes.sessionsBrowser,\n effectiveRoutes.libraryAgent,\n effectiveRoutes.schedules,\n ].join('\\0');\n\n const snapshot: ShellSnapshot = {\n settingsOpen: shell.settingsOpen,\n libraryOpen: shell.libraryOpen,\n sessionsOpen: shell.sessionsOpen,\n libraryAgentId: shell.libraryAgentId,\n schedulesOpen: shell.schedulesOpen,\n pendingSessionId: shell.pendingSessionId,\n activeRemoteId,\n mode: shell.mode,\n agentConfigMode: shell.agentConfigMode,\n };\n\n const place = derivePlace(snapshot);\n const placeKey = JSON.stringify(place);\n\n // Guards. `selfNavPathRef` marks a path we navigated to ourselves so the\n // URL->shell effect does not re-apply it. `prevPlaceRef` powers push/replace.\n const selfNavPathRef = useRef<string | null>(null);\n const prevPlaceRef = useRef<RoutePlace | null>(null);\n const appliedUrlPlaceRef = useRef<RoutePlace | null>(null);\n const bootedRef = useRef(false);\n const bootPlaceRef = useRef<RoutePlace | null>(null);\n const bootHistoryAgentRef = useRef<HistoryAgentSearch | null>(null);\n // Latest session id the URL asked for, so slower lookups cannot bind over it.\n const requestedSessionRef = useRef<string | null>(null);\n const requestedHistoryAgentRef = useRef<string | null>(null);\n // Boot owns the first URL; the ongoing effects skip their initial commit so\n // they do not fight boot with the stale first-render place.\n const shellSyncStartedRef = useRef(false);\n const urlSyncStartedRef = useRef(false);\n\n /**\n * A URL carries only the id, so ask the server whether it names a mutable\n * draft or an agent chat; guessing \"mutable\" opens an agent session as a\n * blank draft. `requestedSessionRef` drops replies a later place superseded.\n */\n const openSession = useCallback(\n (sessionId: string) => {\n requestedSessionRef.current = sessionId;\n if (server == null) {\n shell.openHistorySession({ sessionId });\n return;\n }\n void server\n .getSession({ sessionId })\n .then(session => {\n if (requestedSessionRef.current !== sessionId) return;\n shell.openHistorySession({\n sessionId,\n isMutable: session.isMutable,\n isCreateAgent: sessionIsCreateAgent(session),\n ...(session.agentName != null ? { agentName: session.agentName } : {}),\n });\n })\n .catch(() => {\n if (requestedSessionRef.current !== sessionId) return;\n // Unreachable session: bind by id alone rather than stranding the shell.\n shell.openHistorySession({ sessionId });\n });\n },\n [server, shell],\n );\n\n const applyHistoryAgentSearch = useCallback(\n (next: HistoryAgentSearch | null) => {\n if (next == null) {\n requestedHistoryAgentRef.current = null;\n bootHistoryAgentRef.current = null;\n shell.setHistoryAgentFilter(null);\n return;\n }\n\n const requestKey = `${next.intent}\\0${next.agentName}`;\n const current = shell.historyAgentFilter;\n if (current?.intent === next.intent && current.agentName === next.agentName && current.agentId != null) {\n requestedHistoryAgentRef.current = null;\n return;\n }\n\n requestedHistoryAgentRef.current = requestKey;\n shell.setHistoryAgentFilter(next);\n if (server == null) return;\n\n void findAgentByName({ server, agentName: next.agentName })\n .then(agent => {\n if (requestedHistoryAgentRef.current !== requestKey) return;\n if (agent == null) {\n requestedHistoryAgentRef.current = null;\n bootHistoryAgentRef.current = null;\n shell.setHistoryAgentFilter(null);\n return;\n }\n requestedHistoryAgentRef.current = null;\n shell.setHistoryAgentFilter({\n agentId: libraryAgentId(agent),\n agentName: agent.name,\n intent: next.intent,\n });\n })\n .catch(() => {\n if (requestedHistoryAgentRef.current !== requestKey) return;\n requestedHistoryAgentRef.current = null;\n bootHistoryAgentRef.current = null;\n shell.setHistoryAgentFilter(null);\n });\n },\n [server, shell],\n );\n\n const openAgent = useCallback(\n (agentName: string) => {\n shell.selectLibraryAgent({ isMutable: false, agentName });\n applyHistoryAgentSearch({ intent: 'try-agent', agentName });\n },\n [applyHistoryAgentSearch, shell],\n );\n\n const applyPlace = useCallback(\n (target: RoutePlace) => {\n switch (target.type) {\n case 'settings':\n shell.setSettingsOpen(true);\n return;\n case 'library':\n shell.setLibraryOpen(true);\n return;\n case 'sessionsBrowser':\n shell.setSessionsOpen(true);\n return;\n case 'libraryAgent':\n shell.openLibraryAgent(target.agentId);\n return;\n case 'schedules':\n shell.setSchedulesOpen(true);\n return;\n case 'buildAgent':\n shell.openAgentBuilder();\n return;\n case 'session':\n shell.setLibraryOpen(false);\n if (shell.pendingSessionId === target.sessionId || activeRemoteId === target.sessionId) return;\n openSession(target.sessionId);\n return;\n case 'agent':\n shell.setLibraryOpen(false);\n openAgent(target.agentName);\n return;\n case 'root':\n shell.setSettingsOpen(false);\n shell.setLibraryOpen(false);\n shell.setSchedulesOpen(false);\n switch (shell.agentConfigMode) {\n case 'AgentLibrary':\n shell.openLibraryHome();\n return;\n case 'AgentComposer':\n case 'AgentLibraryWithComposer':\n shell.openDraft();\n return;\n case 'SingleAgent':\n shell.clearChat();\n return;\n }\n }\n },\n [shell, activeRemoteId, openAgent, openSession],\n );\n\n // Boot: URL wins, except an explicit `initialSettingsOpen` overlay. Boot is the\n // sole authority for the first commit and sets the final URL + `prevPlaceRef`.\n useEffect(() => {\n if (bootedRef.current) return;\n const configuredUrlPlace = matchLocation({\n pathname: location.pathname,\n search: location.search,\n routes,\n });\n if (!capabilitiesSettled && configuredUrlPlace?.type === 'settings') return;\n bootedRef.current = true;\n\n const urlPlace = matchLocation({\n pathname: location.pathname,\n search: location.search,\n routes: effectiveRoutes,\n }) ?? { type: 'root' };\n const historyAgentSearch: HistoryAgentSearch | null =\n urlPlace.type === 'agent'\n ? { intent: 'try-agent', agentName: urlPlace.agentName }\n : placeOwnsHistoryAgentSearch(urlPlace)\n ? readHistoryAgentSearch(location.search)\n : null;\n bootHistoryAgentRef.current = historyAgentSearch;\n appliedUrlPlaceRef.current = urlPlace;\n const settingsOnBoot = settingsChromeEnabled && (initialSettingsOpen || urlPlace.type === 'settings');\n\n if (urlPlace.type === 'settings') {\n if (settingsChromeEnabled) shell.setSettingsOpen(true);\n } else if (urlPlace.type === 'library') {\n shell.setLibraryOpen(true);\n } else if (urlPlace.type === 'sessionsBrowser') {\n shell.setSessionsOpen(true);\n } else if (urlPlace.type === 'libraryAgent') {\n shell.openLibraryAgent(urlPlace.agentId);\n } else if (urlPlace.type === 'schedules') {\n shell.setSchedulesOpen(true);\n } else {\n const chatPlace = deriveChatPlace(snapshot);\n if (!placesEqual(chatPlace, urlPlace)) applyPlace(urlPlace);\n if (settingsOnBoot) shell.setSettingsOpen(true);\n }\n if (urlPlace.type !== 'agent' && historyAgentSearch != null) {\n applyHistoryAgentSearch(historyAgentSearch);\n } else if (!placeOwnsHistoryAgentSearch(urlPlace)) {\n applyHistoryAgentSearch(null);\n }\n\n const desiredPlace: RoutePlace = settingsOnBoot ? { type: 'settings' } : urlPlace;\n bootPlaceRef.current = placesEqual(place, desiredPlace) ? null : desiredPlace;\n const desiredPath = buildPath(desiredPlace, effectiveRoutes);\n const desiredSearch = updateHistoryAgentSearch(\n sanitizeSearchForPlace(desiredPlace, location.search),\n historyAgentSearch,\n );\n prevPlaceRef.current = desiredPlace;\n if (desiredPath != null && (desiredPath !== location.pathname || desiredSearch !== location.search)) {\n selfNavPathRef.current = desiredPath !== location.pathname ? desiredPath : null;\n navigate({ pathname: desiredPath, search: desiredSearch, hash: location.hash }, { replace: true });\n }\n // Boot runs once after any capability-dependent Settings destination resolves.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [capabilitiesSettled]);\n\n // Shell -> URL: mirror the derived place. Skip the first commit (boot owns it).\n useEffect(() => {\n if (!bootedRef.current) return;\n if (!shellSyncStartedRef.current) {\n shellSyncStartedRef.current = true;\n return;\n }\n const bootPlace = bootPlaceRef.current;\n if (bootPlace != null) {\n if (!placesEqual(place, bootPlace)) return;\n bootPlaceRef.current = null;\n }\n const target = buildPath(place, effectiveRoutes);\n if (target == null) return; // place has no configured URL (e.g. settings disabled)\n const basename = effectiveRoutes.basename.endsWith('/')\n ? effectiveRoutes.basename.slice(0, -1)\n : effectiveRoutes.basename;\n const browserPathname = `${basename}${location.pathname}` || '/';\n const latestSearch = window.location.pathname === browserPathname ? window.location.search : location.search;\n const ownsHistoryAgentSearch = placeOwnsHistoryAgentSearch(place);\n const historyAgentSearch = ownsHistoryAgentSearch\n ? shell.historyAgentFilter == null\n ? bootHistoryAgentRef.current\n : {\n intent: shell.historyAgentFilter.intent,\n agentName: shell.historyAgentFilter.agentName,\n }\n : null;\n if (!ownsHistoryAgentSearch && shell.historyAgentFilter != null) {\n requestedHistoryAgentRef.current = null;\n shell.setHistoryAgentFilter(null);\n }\n if (shell.historyAgentFilter != null) bootHistoryAgentRef.current = null;\n const targetSearch = updateHistoryAgentSearch(sanitizeSearchForPlace(place, latestSearch), historyAgentSearch);\n\n const prev = prevPlaceRef.current;\n prevPlaceRef.current = place;\n\n if (target === location.pathname && targetSearch === location.search) return;\n\n // Replace when a fresh chat just acquired its session id (same place, new id).\n const replace =\n place.type === 'session' && shell.pendingSessionId == null && prev != null && prev.type !== 'session';\n\n selfNavPathRef.current = target !== location.pathname ? target : null;\n // Query keys owned by other shell places are removed; host keys and hash survive.\n navigate({ pathname: target, search: targetSearch, hash: location.hash }, { replace });\n // location.pathname intentionally excluded: only react to shell-derived place changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [placeKey, routeGatesKey, shell.historyAgentFilter?.agentName, shell.historyAgentFilter?.intent]);\n\n // URL -> shell: apply on genuine location changes (Back/Forward, manual edits).\n useEffect(() => {\n if (!bootedRef.current) return;\n if (!urlSyncStartedRef.current) {\n urlSyncStartedRef.current = true;\n return;\n }\n if (selfNavPathRef.current === location.pathname) {\n selfNavPathRef.current = null;\n appliedUrlPlaceRef.current = place;\n return;\n }\n const urlPlace = matchLocation({\n pathname: location.pathname,\n search: location.search,\n routes: effectiveRoutes,\n });\n if (urlPlace == null) {\n // Unknown path: normalize to root.\n const rootPath = effectiveRoutes.root;\n const rootSearch = sanitizeSearchForPlace({ type: 'root' }, location.search);\n selfNavPathRef.current = rootPath;\n navigate({ pathname: rootPath, search: rootSearch, hash: location.hash }, { replace: true });\n applyPlace({ type: 'root' });\n applyHistoryAgentSearch(readHistoryAgentSearch(rootSearch));\n return;\n }\n const previousUrlPlace = appliedUrlPlaceRef.current;\n appliedUrlPlaceRef.current = urlPlace;\n if (previousUrlPlace == null || !placesEqual(previousUrlPlace, urlPlace)) {\n if (urlPlace.type !== 'settings' && shell.settingsOpen) {\n // Leaving settings via Back to a chat place.\n shell.setSettingsOpen(false);\n }\n if (urlPlace.type !== 'library' && urlPlace.type !== 'libraryAgent' && shell.libraryOpen) {\n shell.setLibraryOpen(false);\n }\n if (urlPlace.type !== 'sessionsBrowser' && shell.sessionsOpen) {\n shell.setSessionsOpen(false);\n }\n if (urlPlace.type !== 'schedules' && shell.schedulesOpen) {\n // Leaving schedules via Back to a chat place.\n shell.setSchedulesOpen(false);\n }\n applyPlace(urlPlace);\n }\n if (urlPlace.type !== 'agent' && placeOwnsHistoryAgentSearch(urlPlace)) {\n applyHistoryAgentSearch(readHistoryAgentSearch(location.search));\n } else if (!placeOwnsHistoryAgentSearch(urlPlace)) {\n applyHistoryAgentSearch(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [location.pathname, location.search]);\n\n return null;\n}\n","export const TRY_AGENT_NAME_QUERY = 'try_agent_name';\nexport const HISTORY_AGENT_NAME_QUERY = 'history_agent_name';\n\nexport type HistoryAgentIntent = 'try-agent' | 'history';\n\nexport type HistoryAgentSearch = {\n intent: HistoryAgentIntent;\n agentName: string;\n};\n\nfunction nonEmpty(value: string | null): string | null {\n return value != null && value.length > 0 ? value : null;\n}\n\nexport function readHistoryAgentSearch(search: string): HistoryAgentSearch | null {\n const params = new URLSearchParams(search.startsWith('?') ? search.slice(1) : search);\n const tryAgentName = nonEmpty(params.get(TRY_AGENT_NAME_QUERY));\n if (tryAgentName != null) return { intent: 'try-agent', agentName: tryAgentName };\n const historyAgentName = nonEmpty(params.get(HISTORY_AGENT_NAME_QUERY));\n return historyAgentName == null ? null : { intent: 'history', agentName: historyAgentName };\n}\n\nexport function writeHistoryAgentSearch(params: URLSearchParams, next: HistoryAgentSearch | null): void {\n params.delete(TRY_AGENT_NAME_QUERY);\n params.delete(HISTORY_AGENT_NAME_QUERY);\n if (next == null) return;\n params.set(next.intent === 'try-agent' ? TRY_AGENT_NAME_QUERY : HISTORY_AGENT_NAME_QUERY, next.agentName);\n}\n\nexport function updateHistoryAgentSearch(search: string, next: HistoryAgentSearch | null): string {\n const params = new URLSearchParams(search.startsWith('?') ? search.slice(1) : search);\n writeHistoryAgentSearch(params, next);\n const updated = params.toString();\n return updated.length > 0 ? `?${updated}` : '';\n}\n","import type { RoutePlace, ShellSnapshot } from './types.js';\n\n/**\n * The chat place implied by shell state, ignoring settings, schedules,\n * sessions-browser, and library overlays.\n * SingleAgent canonicalizes to `root` so `/` and `/agents/{name}` alias.\n */\nexport function deriveChatPlace(snapshot: ShellSnapshot): RoutePlace {\n // The live thread wins: reusing a mutable shell switches thread without a\n // remount, leaving `pendingSessionId` on the session the shell last opened.\n // It only leads while a requested session has not reported its thread yet.\n const sessionId = snapshot.activeRemoteId ?? snapshot.pendingSessionId;\n if (sessionId != null) return { type: 'session', sessionId };\n\n const { mode, agentConfigMode } = snapshot;\n if (mode.status === 'active' && mode.isMutable && mode.isCreateAgent) {\n return { type: 'buildAgent' };\n }\n\n if (mode.status === 'active' && !mode.isMutable && agentConfigMode !== 'SingleAgent') {\n const agentName = mode.agentName ?? mode.agentId;\n if (agentName != null) return { type: 'agent', agentName };\n }\n return { type: 'root' };\n}\n\n/** Full place with overlay priority: settings, schedules, sessions, library, chat. */\nexport function derivePlace(snapshot: ShellSnapshot): RoutePlace {\n if (snapshot.settingsOpen) return { type: 'settings' };\n if (snapshot.schedulesOpen) return { type: 'schedules' };\n if (snapshot.sessionsOpen) return { type: 'sessionsBrowser' };\n if (snapshot.libraryOpen && snapshot.libraryAgentId != null) {\n return { type: 'libraryAgent', agentId: snapshot.libraryAgentId };\n }\n if (snapshot.libraryOpen) return { type: 'library' };\n return deriveChatPlace(snapshot);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa,WAAW,SAAS,cAAc;AACxD,SAAS,aAAa,mBAAmB;;;ACHlC,IAAM,uBAAuB;AAC7B,IAAM,2BAA2B;AASxC,SAAS,SAAS,OAAqC;AACrD,SAAO,SAAS,QAAQ,MAAM,SAAS,IAAI,QAAQ;AACrD;AAEO,SAAS,uBAAuB,QAA2C;AAChF,QAAM,SAAS,IAAI,gBAAgB,OAAO,WAAW,GAAG,IAAI,OAAO,MAAM,CAAC,IAAI,MAAM;AACpF,QAAM,eAAe,SAAS,OAAO,IAAI,oBAAoB,CAAC;AAC9D,MAAI,gBAAgB,KAAM,QAAO,EAAE,QAAQ,aAAa,WAAW,aAAa;AAChF,QAAM,mBAAmB,SAAS,OAAO,IAAI,wBAAwB,CAAC;AACtE,SAAO,oBAAoB,OAAO,OAAO,EAAE,QAAQ,WAAW,WAAW,iBA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