@tutti-os/agent-gui 0.0.155 → 0.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-gui.js +2 -2
- package/dist/{chunk-SX5KN3LN.js → chunk-IFOIUN2O.js} +27 -21
- package/dist/chunk-IFOIUN2O.js.map +1 -0
- package/dist/{chunk-2K7NUYHG.js → chunk-M66OSHIF.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/workbench/contribution.js +1 -1
- package/dist/workbench/index.d.ts +11 -3
- package/dist/workbench/index.js +1 -1
- package/dist/workbench/tool-sidebar/index.d.ts +14 -4
- package/dist/workbench/tool-sidebar/index.js +118 -30
- package/dist/workbench/tool-sidebar/index.js.map +1 -1
- package/package.json +13 -13
- package/dist/chunk-SX5KN3LN.js.map +0 -1
- /package/dist/{chunk-2K7NUYHG.js.map → chunk-M66OSHIF.js.map} +0 -0
|
@@ -94,6 +94,14 @@ function reduceAgentToolSidebarState(state, action) {
|
|
|
94
94
|
}
|
|
95
95
|
case "add-panel":
|
|
96
96
|
return addTab(state, action);
|
|
97
|
+
case "ensure-panel": {
|
|
98
|
+
const existing = findLastTab(
|
|
99
|
+
state.mountedTabs,
|
|
100
|
+
action.panel,
|
|
101
|
+
action.resourceId
|
|
102
|
+
);
|
|
103
|
+
return existing ? state : addTab(state, action, { activate: false });
|
|
104
|
+
}
|
|
97
105
|
case "open-panel": {
|
|
98
106
|
const existing = findLastTab(
|
|
99
107
|
state.mountedTabs,
|
|
@@ -104,15 +112,16 @@ function reduceAgentToolSidebarState(state, action) {
|
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
|
-
function addTab(state, tab) {
|
|
115
|
+
function addTab(state, tab, options = {}) {
|
|
108
116
|
const nextTab = {
|
|
109
117
|
id: tab.tabId,
|
|
110
118
|
panel: tab.panel,
|
|
111
119
|
...tab.resourceId ? { resourceId: tab.resourceId } : {}
|
|
112
120
|
};
|
|
121
|
+
const activate = options.activate !== false;
|
|
113
122
|
return {
|
|
114
|
-
activePanel: nextTab.panel,
|
|
115
|
-
activeTabId: nextTab.id,
|
|
123
|
+
activePanel: activate ? nextTab.panel : state.activePanel,
|
|
124
|
+
activeTabId: activate ? nextTab.id : state.activeTabId,
|
|
116
125
|
mountedTabs: state.mountedTabs.some(
|
|
117
126
|
(candidate) => candidate.id === nextTab.id
|
|
118
127
|
) ? state.mountedTabs : [...state.mountedTabs, nextTab]
|
|
@@ -198,8 +207,15 @@ function formatAgentToolReminderCount(value) {
|
|
|
198
207
|
}
|
|
199
208
|
|
|
200
209
|
// workbench/tool-sidebar/AgentToolBrowserPanel.tsx
|
|
201
|
-
import { lazy, Suspense, useMemo, useState } from "react";
|
|
202
210
|
import {
|
|
211
|
+
lazy,
|
|
212
|
+
Suspense,
|
|
213
|
+
useCallback,
|
|
214
|
+
useMemo,
|
|
215
|
+
useState
|
|
216
|
+
} from "react";
|
|
217
|
+
import {
|
|
218
|
+
closeBrowserNodeTab,
|
|
203
219
|
createBrowserNodeFeature,
|
|
204
220
|
isBrowserNodeSurfaceEvent
|
|
205
221
|
} from "@tutti-os/browser-node";
|
|
@@ -211,6 +227,7 @@ var LazyBrowserNode = lazy(
|
|
|
211
227
|
);
|
|
212
228
|
var agentToolBrowserDefaultUrl = "https://www.google.com/";
|
|
213
229
|
function AgentToolBrowserPanel({
|
|
230
|
+
automationTarget = null,
|
|
214
231
|
browserApi,
|
|
215
232
|
chromeCookieImportPrompt,
|
|
216
233
|
defaultUrl = agentToolBrowserDefaultUrl,
|
|
@@ -219,6 +236,7 @@ function AgentToolBrowserPanel({
|
|
|
219
236
|
loadingFallback = null,
|
|
220
237
|
navigationActions,
|
|
221
238
|
nodeIdPrefix = "browser:agent-tool",
|
|
239
|
+
onControllerReady,
|
|
222
240
|
profileId = null,
|
|
223
241
|
sessionMode = "shared",
|
|
224
242
|
sessionPartition = null
|
|
@@ -233,15 +251,60 @@ function AgentToolBrowserPanel({
|
|
|
233
251
|
}),
|
|
234
252
|
[browserApi, chromeCookieImportPrompt, i18n, nodeId]
|
|
235
253
|
);
|
|
254
|
+
const controller = useMemo(() => {
|
|
255
|
+
const getPage = (pageNodeId) => {
|
|
256
|
+
const state = feature.tabsStore.getSurfaceState(nodeId);
|
|
257
|
+
const tab = state?.tabs.find(
|
|
258
|
+
(candidate) => candidate.nodeId === pageNodeId
|
|
259
|
+
);
|
|
260
|
+
return state && tab ? { state, tab } : null;
|
|
261
|
+
};
|
|
262
|
+
return {
|
|
263
|
+
closePage(pageNodeId) {
|
|
264
|
+
const page = getPage(pageNodeId);
|
|
265
|
+
if (!page) return "not-found";
|
|
266
|
+
if (page.state.tabs.length === 1) return "last-page";
|
|
267
|
+
closeBrowserNodeTab(feature, nodeId, page.tab.id);
|
|
268
|
+
return "closed";
|
|
269
|
+
},
|
|
270
|
+
createPage(url) {
|
|
271
|
+
const resolvedUrl = url?.trim() || "about:blank";
|
|
272
|
+
const state = feature.tabsStore.ensureSurface(nodeId, defaultUrl);
|
|
273
|
+
const activeTab = state.tabs.find(
|
|
274
|
+
(tab) => tab.id === state.activeTabId
|
|
275
|
+
);
|
|
276
|
+
const activeRuntime = activeTab ? feature.runtimeStore.getNodeState(activeTab.nodeId) : null;
|
|
277
|
+
if (state.tabs.length === 1 && activeTab?.defaultUrl === "about:blank" && !activeRuntime?.url) {
|
|
278
|
+
feature.tabsStore.syncDefaultUrl(nodeId, resolvedUrl);
|
|
279
|
+
return activeTab.nodeId;
|
|
280
|
+
}
|
|
281
|
+
return feature.tabsStore.addTab(nodeId, resolvedUrl).nodeId;
|
|
282
|
+
},
|
|
283
|
+
ownsPage: (pageNodeId) => getPage(pageNodeId) !== null,
|
|
284
|
+
selectPage(pageNodeId) {
|
|
285
|
+
const page = getPage(pageNodeId);
|
|
286
|
+
if (!page) return false;
|
|
287
|
+
feature.tabsStore.selectTab(nodeId, page.tab.id);
|
|
288
|
+
return true;
|
|
289
|
+
},
|
|
290
|
+
surfaceNodeId: nodeId
|
|
291
|
+
};
|
|
292
|
+
}, [defaultUrl, feature, nodeId]);
|
|
293
|
+
const bindController = useCallback(
|
|
294
|
+
(node) => onControllerReady?.(node ? controller : null),
|
|
295
|
+
[controller, onControllerReady]
|
|
296
|
+
);
|
|
236
297
|
return /* @__PURE__ */ jsx(
|
|
237
298
|
"div",
|
|
238
299
|
{
|
|
239
300
|
className: "relative h-full min-h-0 overflow-hidden",
|
|
240
301
|
"data-agent-tool-browser-surface": "true",
|
|
241
302
|
"data-agent-tool-browser-surface-id": nodeId,
|
|
303
|
+
ref: bindController,
|
|
242
304
|
children: /* @__PURE__ */ jsx(Suspense, { fallback: loadingFallback, children: /* @__PURE__ */ jsx(
|
|
243
305
|
LazyBrowserNode,
|
|
244
306
|
{
|
|
307
|
+
automationTarget: automationTarget ? { ...automationTarget, focused: !hidden } : null,
|
|
245
308
|
defaultUrl,
|
|
246
309
|
feature,
|
|
247
310
|
hidden,
|
|
@@ -525,7 +588,7 @@ function AgentToolSidebarPicker({
|
|
|
525
588
|
|
|
526
589
|
// workbench/tool-sidebar/useAgentToolSidebarController.ts
|
|
527
590
|
import {
|
|
528
|
-
useCallback as
|
|
591
|
+
useCallback as useCallback3,
|
|
529
592
|
useReducer,
|
|
530
593
|
useRef as useRef2,
|
|
531
594
|
useState as useState3
|
|
@@ -533,7 +596,7 @@ import {
|
|
|
533
596
|
|
|
534
597
|
// workbench/tool-sidebar/useAgentToolSidebarLayout.ts
|
|
535
598
|
import {
|
|
536
|
-
useCallback,
|
|
599
|
+
useCallback as useCallback2,
|
|
537
600
|
useRef,
|
|
538
601
|
useState as useState2
|
|
539
602
|
} from "react";
|
|
@@ -598,7 +661,7 @@ function useAgentToolSidebarLayout({
|
|
|
598
661
|
containerWidth: resolvedContainerWidth,
|
|
599
662
|
panelWidth: activePanelWidth
|
|
600
663
|
}) : 0;
|
|
601
|
-
const resetPanelExpansion =
|
|
664
|
+
const resetPanelExpansion = useCallback2(
|
|
602
665
|
(nextPanel) => {
|
|
603
666
|
const reset = resolveAgentToolPanelExpansionReset({
|
|
604
667
|
expandedPanel: expandedPanelRef.current,
|
|
@@ -637,7 +700,7 @@ function useAgentToolSidebarLayout({
|
|
|
637
700
|
},
|
|
638
701
|
[manuallyResizedWidth, panelWidths]
|
|
639
702
|
);
|
|
640
|
-
const resizeForPanel =
|
|
703
|
+
const resizeForPanel = useCallback2(
|
|
641
704
|
async (nextPanel, preferredWidth, options) => {
|
|
642
705
|
const requestId = ++resizeRequestRef.current;
|
|
643
706
|
const expansionTransition = resetPanelExpansion(nextPanel);
|
|
@@ -694,10 +757,10 @@ function useAgentToolSidebarLayout({
|
|
|
694
757
|
resolvedContainerWidth
|
|
695
758
|
]
|
|
696
759
|
);
|
|
697
|
-
const resetContainerResizeBaseline =
|
|
760
|
+
const resetContainerResizeBaseline = useCallback2(() => {
|
|
698
761
|
baselineContainerWidthRef.current = null;
|
|
699
762
|
}, []);
|
|
700
|
-
const updatePanelWidth =
|
|
763
|
+
const updatePanelWidth = useCallback2(
|
|
701
764
|
(panel, width) => {
|
|
702
765
|
const nextWidth = clampAgentToolPanelWidth({
|
|
703
766
|
allowFullWidth: expandedPanel === panel,
|
|
@@ -711,7 +774,7 @@ function useAgentToolSidebarLayout({
|
|
|
711
774
|
},
|
|
712
775
|
[expandedPanel, mainContentMinWidthPx, resolvedContainerWidth]
|
|
713
776
|
);
|
|
714
|
-
const togglePanelExpansion =
|
|
777
|
+
const togglePanelExpansion = useCallback2(
|
|
715
778
|
(panel) => {
|
|
716
779
|
if (expandedPanelRef.current === panel) {
|
|
717
780
|
resetPanelExpansion(null);
|
|
@@ -731,7 +794,7 @@ function useAgentToolSidebarLayout({
|
|
|
731
794
|
},
|
|
732
795
|
[manuallyResizedWidth, resetPanelExpansion]
|
|
733
796
|
);
|
|
734
|
-
const stopResizing =
|
|
797
|
+
const stopResizing = useCallback2(() => {
|
|
735
798
|
dragRef.current = null;
|
|
736
799
|
const styles = resizeStyleRef.current;
|
|
737
800
|
if (!styles) return;
|
|
@@ -739,13 +802,13 @@ function useAgentToolSidebarLayout({
|
|
|
739
802
|
document.body.style.userSelect = styles.userSelect;
|
|
740
803
|
resizeStyleRef.current = null;
|
|
741
804
|
}, []);
|
|
742
|
-
const bindLayoutRoot =
|
|
805
|
+
const bindLayoutRoot = useCallback2(
|
|
743
806
|
(node) => {
|
|
744
807
|
if (!node) stopResizing();
|
|
745
808
|
},
|
|
746
809
|
[stopResizing]
|
|
747
810
|
);
|
|
748
|
-
const handleResizePointerDown =
|
|
811
|
+
const handleResizePointerDown = useCallback2(
|
|
749
812
|
(event) => {
|
|
750
813
|
if (event.button !== 0 || activePanel === null) return;
|
|
751
814
|
event.preventDefault();
|
|
@@ -765,7 +828,7 @@ function useAgentToolSidebarLayout({
|
|
|
765
828
|
},
|
|
766
829
|
[activePanel, activePanelWidth]
|
|
767
830
|
);
|
|
768
|
-
const handleResizePointerMove =
|
|
831
|
+
const handleResizePointerMove = useCallback2(
|
|
769
832
|
(event) => {
|
|
770
833
|
const resizeState = dragRef.current;
|
|
771
834
|
if (!resizeState || resizeState.pointerId !== event.pointerId) return;
|
|
@@ -776,7 +839,7 @@ function useAgentToolSidebarLayout({
|
|
|
776
839
|
},
|
|
777
840
|
[updatePanelWidth]
|
|
778
841
|
);
|
|
779
|
-
const handleResizeKeyDown =
|
|
842
|
+
const handleResizeKeyDown = useCallback2(
|
|
780
843
|
(event) => {
|
|
781
844
|
if (activePanel === null) return;
|
|
782
845
|
if (event.key === "Home") {
|
|
@@ -877,7 +940,7 @@ function useAgentToolSidebarController({
|
|
|
877
940
|
const resizeAnimationFrameRef = useRef2(null);
|
|
878
941
|
const contentAnimationFrameIdsRef = useRef2(/* @__PURE__ */ new Set());
|
|
879
942
|
const toolActionsResizeObserverRef = useRef2(null);
|
|
880
|
-
const scheduleResizeForPanel =
|
|
943
|
+
const scheduleResizeForPanel = useCallback3(
|
|
881
944
|
(panel, preferredWidth, options) => {
|
|
882
945
|
if (resizeAnimationFrameRef.current !== null) {
|
|
883
946
|
window.cancelAnimationFrame(resizeAnimationFrameRef.current);
|
|
@@ -889,11 +952,11 @@ function useAgentToolSidebarController({
|
|
|
889
952
|
},
|
|
890
953
|
[layout.resizeForPanel]
|
|
891
954
|
);
|
|
892
|
-
const showSidebar =
|
|
955
|
+
const showSidebar = useCallback3(() => {
|
|
893
956
|
setIsEmptySidebarClosing(false);
|
|
894
957
|
setIsSidebarOpen(true);
|
|
895
958
|
}, []);
|
|
896
|
-
const markContentReady =
|
|
959
|
+
const markContentReady = useCallback3((tabId) => {
|
|
897
960
|
if (prefersReducedMotion()) {
|
|
898
961
|
setContentReadyTabIds(
|
|
899
962
|
(current) => current.includes(tabId) ? current : [...current, tabId]
|
|
@@ -913,7 +976,7 @@ function useAgentToolSidebarController({
|
|
|
913
976
|
contentAnimationFrameIdsRef.current.add(frameId);
|
|
914
977
|
}
|
|
915
978
|
}, []);
|
|
916
|
-
const closePanel =
|
|
979
|
+
const closePanel = useCallback3(() => {
|
|
917
980
|
setIsSidebarOpen(false);
|
|
918
981
|
dispatch({ type: "close" });
|
|
919
982
|
onActivePanelChange?.(null);
|
|
@@ -928,7 +991,7 @@ function useAgentToolSidebarController({
|
|
|
928
991
|
preserveBaseline: true
|
|
929
992
|
});
|
|
930
993
|
}, [onActivePanelChange, scheduleResizeForPanel, state.mountedTabs.length]);
|
|
931
|
-
const openPanel =
|
|
994
|
+
const openPanel = useCallback3(
|
|
932
995
|
(panel, resourceId) => {
|
|
933
996
|
if (!panelIds.has(panel)) return null;
|
|
934
997
|
showSidebar();
|
|
@@ -956,7 +1019,7 @@ function useAgentToolSidebarController({
|
|
|
956
1019
|
state
|
|
957
1020
|
]
|
|
958
1021
|
);
|
|
959
|
-
const addPanel =
|
|
1022
|
+
const addPanel = useCallback3(
|
|
960
1023
|
(panel, resourceId) => {
|
|
961
1024
|
if (!panelIds.has(panel)) return null;
|
|
962
1025
|
showSidebar();
|
|
@@ -982,7 +1045,29 @@ function useAgentToolSidebarController({
|
|
|
982
1045
|
state
|
|
983
1046
|
]
|
|
984
1047
|
);
|
|
985
|
-
const
|
|
1048
|
+
const ensurePanel = useCallback3(
|
|
1049
|
+
(panel, resourceId) => {
|
|
1050
|
+
if (!panelIds.has(panel)) return null;
|
|
1051
|
+
const existing = state.mountedTabs.find(
|
|
1052
|
+
(tab) => tab.panel === panel && (tab.resourceId ?? void 0) === resourceId
|
|
1053
|
+
);
|
|
1054
|
+
if (existing) return existing.id;
|
|
1055
|
+
const tabId = createToolTabId(panel);
|
|
1056
|
+
const action = {
|
|
1057
|
+
panel,
|
|
1058
|
+
resourceId,
|
|
1059
|
+
tabId,
|
|
1060
|
+
type: "ensure-panel"
|
|
1061
|
+
};
|
|
1062
|
+
const nextState = reduceAgentToolSidebarState(state, action);
|
|
1063
|
+
dispatch(action);
|
|
1064
|
+
onTabsChange?.(nextState.mountedTabs);
|
|
1065
|
+
markContentReady(tabId);
|
|
1066
|
+
return tabId;
|
|
1067
|
+
},
|
|
1068
|
+
[markContentReady, onTabsChange, panelIds, state]
|
|
1069
|
+
);
|
|
1070
|
+
const closePanelTab = useCallback3(
|
|
986
1071
|
(tabId) => {
|
|
987
1072
|
const closingIndex = state.mountedTabs.findIndex(
|
|
988
1073
|
(tab) => tab.id === tabId
|
|
@@ -1015,7 +1100,7 @@ function useAgentToolSidebarController({
|
|
|
1015
1100
|
state
|
|
1016
1101
|
]
|
|
1017
1102
|
);
|
|
1018
|
-
const activatePanelTab =
|
|
1103
|
+
const activatePanelTab = useCallback3(
|
|
1019
1104
|
(tab) => {
|
|
1020
1105
|
onPanelOpen?.(tab.panel, tab.resourceId);
|
|
1021
1106
|
dispatch({ tabId: tab.id, type: "activate-tab" });
|
|
@@ -1025,7 +1110,7 @@ function useAgentToolSidebarController({
|
|
|
1025
1110
|
},
|
|
1026
1111
|
[markContentReady, onActivePanelChange, onPanelOpen, scheduleResizeForPanel]
|
|
1027
1112
|
);
|
|
1028
|
-
const toggleSidebar =
|
|
1113
|
+
const toggleSidebar = useCallback3(() => {
|
|
1029
1114
|
const nextPanel = activePanel ?? fallbackPanel;
|
|
1030
1115
|
if (isSidebarOpen) {
|
|
1031
1116
|
closePanel();
|
|
@@ -1055,7 +1140,7 @@ function useAgentToolSidebarController({
|
|
|
1055
1140
|
showSidebar,
|
|
1056
1141
|
state.mountedTabs
|
|
1057
1142
|
]);
|
|
1058
|
-
const handleSidebarTransitionEnd =
|
|
1143
|
+
const handleSidebarTransitionEnd = useCallback3(
|
|
1059
1144
|
(event) => {
|
|
1060
1145
|
if (event.currentTarget !== event.target || event.propertyName !== "width" || isSidebarOpen || !isEmptySidebarClosing) {
|
|
1061
1146
|
return;
|
|
@@ -1065,7 +1150,7 @@ function useAgentToolSidebarController({
|
|
|
1065
1150
|
},
|
|
1066
1151
|
[isEmptySidebarClosing, isSidebarOpen, layout.resetContainerResizeBaseline]
|
|
1067
1152
|
);
|
|
1068
|
-
const bindLayoutWidthProjection =
|
|
1153
|
+
const bindLayoutWidthProjection = useCallback3(
|
|
1069
1154
|
(node) => {
|
|
1070
1155
|
if (node) {
|
|
1071
1156
|
onLayoutWidthChange?.(
|
|
@@ -1075,7 +1160,7 @@ function useAgentToolSidebarController({
|
|
|
1075
1160
|
},
|
|
1076
1161
|
[isSidebarOpen, layout.activePanelLayoutWidth, onLayoutWidthChange]
|
|
1077
1162
|
);
|
|
1078
|
-
const bindLifecycle =
|
|
1163
|
+
const bindLifecycle = useCallback3(
|
|
1079
1164
|
(node) => {
|
|
1080
1165
|
if (node) return;
|
|
1081
1166
|
if (resizeAnimationFrameRef.current !== null) {
|
|
@@ -1092,7 +1177,7 @@ function useAgentToolSidebarController({
|
|
|
1092
1177
|
},
|
|
1093
1178
|
[layout.bindLayoutRoot]
|
|
1094
1179
|
);
|
|
1095
|
-
const measureToolActions =
|
|
1180
|
+
const measureToolActions = useCallback3((node) => {
|
|
1096
1181
|
toolActionsResizeObserverRef.current?.disconnect();
|
|
1097
1182
|
toolActionsResizeObserverRef.current = null;
|
|
1098
1183
|
if (!node) return;
|
|
@@ -1117,6 +1202,7 @@ function useAgentToolSidebarController({
|
|
|
1117
1202
|
closePanel,
|
|
1118
1203
|
closePanelTab,
|
|
1119
1204
|
contentReadyTabIds,
|
|
1205
|
+
ensurePanel,
|
|
1120
1206
|
handleSidebarTransitionEnd,
|
|
1121
1207
|
isEmptySidebar,
|
|
1122
1208
|
isEmptySidebarClosing,
|
|
@@ -1192,6 +1278,7 @@ var AgentToolSidebar = forwardRef(function AgentToolSidebar2({
|
|
|
1192
1278
|
closePanel,
|
|
1193
1279
|
closePanelTab,
|
|
1194
1280
|
contentReadyTabIds,
|
|
1281
|
+
ensurePanel,
|
|
1195
1282
|
handleSidebarTransitionEnd,
|
|
1196
1283
|
isEmptySidebar,
|
|
1197
1284
|
isEmptySidebarClosing,
|
|
@@ -1222,9 +1309,10 @@ var AgentToolSidebar = forwardRef(function AgentToolSidebar2({
|
|
|
1222
1309
|
addPanel,
|
|
1223
1310
|
close: closePanel,
|
|
1224
1311
|
closeTab: closePanelTab,
|
|
1312
|
+
ensurePanel,
|
|
1225
1313
|
openPanel
|
|
1226
1314
|
}),
|
|
1227
|
-
[addPanel, closePanel, closePanelTab, openPanel]
|
|
1315
|
+
[addPanel, closePanel, closePanelTab, ensurePanel, openPanel]
|
|
1228
1316
|
);
|
|
1229
1317
|
const isHostHeaderDrag = headerDrag?.mode === "host";
|
|
1230
1318
|
const handleHeaderDoubleClick = (event) => {
|