@steerable/agent-shell-web 0.14.5 → 0.14.7
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/package.json +4 -4
- package/src/components/AgentSidebar.tsx +6 -2
- package/src/components/ChatHeader.tsx +17 -2
- package/src/components/chat/AssistantMessage.tsx +60 -1
- package/src/components/chat/ChatInput.tsx +16 -4
- package/src/components/chat/LocalChatPanel.tsx +32 -1
- package/src/components/chat/MemorySaveNoticeBar.tsx +24 -3
- package/src/components/chat/MessageList.tsx +6 -0
- package/src/components/settings/AgentsSettingsPanel.tsx +3 -3
- package/src/components/settings/AppUpdateSettingsPanel.tsx +67 -43
- package/src/components/settings/AppearanceSettingsPanel.tsx +101 -134
- package/src/components/settings/CliInstallSettingsPanel.tsx +25 -23
- package/src/components/settings/DiagnoseSettingsPanel.tsx +3 -3
- package/src/components/settings/InsightsSettingsPanel.tsx +5 -7
- package/src/components/settings/LlmSettingsPanel.tsx +22 -2
- package/src/components/settings/McpSettingsPanel.tsx +4 -5
- package/src/components/settings/MemorySettingsPanel.tsx +302 -169
- package/src/components/settings/OrchestrationSettingsPanel.tsx +79 -121
- package/src/components/settings/PortableSettingsPanel.tsx +62 -49
- package/src/components/settings/PythonRunnerSettingsPanel.tsx +2 -4
- package/src/components/settings/SecuritySettingsPanel.tsx +91 -70
- package/src/components/settings/SettingsSidebar.tsx +238 -0
- package/src/components/settings/SkillsSettingsPanel.tsx +3 -4
- package/src/components/settings/TelemetrySettingsPanel.tsx +2 -7
- package/src/components/settings/UsagePanel.tsx +27 -35
- package/src/components/settings/WebSearchSettingsPanel.tsx +89 -88
- package/src/components/settings/primitives.tsx +302 -0
- package/src/components/settings/settings-registry.ts +371 -0
- package/src/layouts/AgentLayout.tsx +106 -6
- package/src/lib/chat-draft-store.ts +43 -0
- package/src/lib/chat-mode-store.ts +27 -0
- package/src/lib/chat-title.ts +13 -0
- package/src/lib/local-api.ts +35 -0
- package/src/packs/registry.ts +2 -0
- package/src/pages/AgentPage.tsx +333 -3
- package/src/pages/SettingsPage.tsx +337 -487
- package/src/styles/index.css +6 -0
|
@@ -2,6 +2,12 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
3
3
|
import { LuBlocks, LuPanelLeftOpen, LuSettings, LuSquarePen } from 'react-icons/lu';
|
|
4
4
|
import { AgentSidebar } from '@/components/AgentSidebar';
|
|
5
|
+
import { useAppRelease } from '@/components/SidebarRelease';
|
|
6
|
+
import { SettingsSidebar } from '@/components/settings/SettingsSidebar';
|
|
7
|
+
import {
|
|
8
|
+
buildSettingsNavEntries,
|
|
9
|
+
resolveSettingsRoute,
|
|
10
|
+
} from '@/components/settings/settings-registry';
|
|
5
11
|
import { TerminalPanel } from '@/components/TerminalPanel';
|
|
6
12
|
import { RightPanelTabBar } from '@/layouts/RightPanelTabBar';
|
|
7
13
|
import { TaskProcessPanel, type InspectedTask } from '@/components/chat/TaskProcessPanel';
|
|
@@ -154,6 +160,10 @@ export type AgentOutletContext = UseChatsAndAgentsResult & {
|
|
|
154
160
|
hiddenPanelTitle: string | null;
|
|
155
161
|
/** 标题栏开关:整栏收着或空着时打开。 */
|
|
156
162
|
onOpenRightPanel: () => void;
|
|
163
|
+
/** 当前应用隐藏的导航项列表(供设置页与侧栏保持一致裁剪)。 */
|
|
164
|
+
hiddenNavItems?: readonly HiddenNavItem[];
|
|
165
|
+
/** 退出设置页并返回上一次聊天路由。 */
|
|
166
|
+
onExitSettings?: () => void;
|
|
157
167
|
};
|
|
158
168
|
|
|
159
169
|
function AgentLayoutContent() {
|
|
@@ -798,6 +808,45 @@ function AgentLayoutContent() {
|
|
|
798
808
|
(!(hiddenSet.has('agents') && hiddenSet.has('skills') && hiddenSet.has('mcp')) &&
|
|
799
809
|
settingsChrome('web-search'));
|
|
800
810
|
const onSettingsPage = location.pathname === '/settings';
|
|
811
|
+
const release = useAppRelease();
|
|
812
|
+
const lastChatLocationRef = useRef<string>('/agent');
|
|
813
|
+
useEffect(() => {
|
|
814
|
+
if (location.pathname !== '/settings') {
|
|
815
|
+
lastChatLocationRef.current = `${location.pathname}${location.search}`;
|
|
816
|
+
}
|
|
817
|
+
}, [location.pathname, location.search]);
|
|
818
|
+
|
|
819
|
+
const exitSettings = useCallback(() => {
|
|
820
|
+
navigate(lastChatLocationRef.current || '/agent');
|
|
821
|
+
}, [navigate]);
|
|
822
|
+
|
|
823
|
+
const settingsEntries = useMemo(
|
|
824
|
+
() =>
|
|
825
|
+
onSettingsPage
|
|
826
|
+
? buildSettingsNavEntries({
|
|
827
|
+
hiddenNavItems,
|
|
828
|
+
releaseVersion: release.version,
|
|
829
|
+
})
|
|
830
|
+
: [],
|
|
831
|
+
[onSettingsPage, hiddenNavItems, release.version],
|
|
832
|
+
);
|
|
833
|
+
const resolvedSettings = useMemo(
|
|
834
|
+
() =>
|
|
835
|
+
onSettingsPage
|
|
836
|
+
? resolveSettingsRoute(
|
|
837
|
+
new URLSearchParams(location.search),
|
|
838
|
+
settingsEntries.map((item) => item.id),
|
|
839
|
+
)
|
|
840
|
+
: { tabId: 'general', anchorId: null },
|
|
841
|
+
[onSettingsPage, location.search, settingsEntries],
|
|
842
|
+
);
|
|
843
|
+
const handleSelectSettingsTab = useCallback(
|
|
844
|
+
(tabId: string) => {
|
|
845
|
+
navigate(`/settings?tab=${encodeURIComponent(tabId)}`);
|
|
846
|
+
},
|
|
847
|
+
[navigate],
|
|
848
|
+
);
|
|
849
|
+
|
|
801
850
|
const settingsSection = useMemo(
|
|
802
851
|
() => new URLSearchParams(location.search).get('section'),
|
|
803
852
|
[location.search],
|
|
@@ -812,9 +861,9 @@ function AgentLayoutContent() {
|
|
|
812
861
|
const onGeneralSettings = onSettingsPage && !onPluginsSettings;
|
|
813
862
|
const onNewChatHome = !chatId && !onSettingsPage;
|
|
814
863
|
|
|
815
|
-
//
|
|
864
|
+
// 收起侧边栏或处在设置页时 AgentSidebar 未挂载,由外层补接菜单 Cmd+N。
|
|
816
865
|
useEffect(() => {
|
|
817
|
-
if (!sidebarCollapsed) return;
|
|
866
|
+
if (!sidebarCollapsed && !onSettingsPage) return;
|
|
818
867
|
const bridge = getHostBridge();
|
|
819
868
|
if (!bridge?.onMenuNewChat) return;
|
|
820
869
|
bridge.onMenuNewChat(() => {
|
|
@@ -823,22 +872,71 @@ function AgentLayoutContent() {
|
|
|
823
872
|
return () => {
|
|
824
873
|
bridge.offMenuNewChat?.();
|
|
825
874
|
};
|
|
826
|
-
}, [sidebarCollapsed, navigate]);
|
|
875
|
+
}, [sidebarCollapsed, onSettingsPage, navigate]);
|
|
827
876
|
|
|
828
877
|
useEffect(() => {
|
|
829
878
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
830
879
|
if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey && event.key.toLowerCase() === 'o') {
|
|
831
880
|
event.preventDefault();
|
|
832
881
|
navigate('/agent');
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey && event.key === ',') {
|
|
885
|
+
if (!hasGeneralSettingsChrome() && !pluginsAvailable) return;
|
|
886
|
+
event.preventDefault();
|
|
887
|
+
if (onSettingsPage) {
|
|
888
|
+
exitSettings();
|
|
889
|
+
} else {
|
|
890
|
+
navigate('/settings');
|
|
891
|
+
}
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (onSettingsPage && event.key === 'Escape' && !event.defaultPrevented) {
|
|
895
|
+
const active = document.activeElement as HTMLElement | null;
|
|
896
|
+
const tag = active?.tagName?.toLowerCase();
|
|
897
|
+
if (
|
|
898
|
+
tag === 'input' ||
|
|
899
|
+
tag === 'textarea' ||
|
|
900
|
+
tag === 'select' ||
|
|
901
|
+
active?.isContentEditable ||
|
|
902
|
+
active?.closest('[role="dialog"], [role="menu"], [role="listbox"]')
|
|
903
|
+
) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
event.preventDefault();
|
|
907
|
+
exitSettings();
|
|
833
908
|
}
|
|
834
909
|
};
|
|
835
910
|
window.addEventListener('keydown', onKeyDown);
|
|
836
911
|
return () => window.removeEventListener('keydown', onKeyDown);
|
|
837
|
-
}, [navigate]);
|
|
912
|
+
}, [navigate, onSettingsPage, exitSettings, pluginsAvailable]);
|
|
838
913
|
|
|
839
914
|
return (
|
|
840
915
|
<div className="relative flex h-full w-full bg-agent-muted/30">
|
|
841
|
-
{
|
|
916
|
+
{onSettingsPage ? (
|
|
917
|
+
<>
|
|
918
|
+
<div
|
|
919
|
+
className="hidden h-full flex-shrink-0 sm:block"
|
|
920
|
+
style={{ width: Math.max(sidebarWidth, 224) }}
|
|
921
|
+
>
|
|
922
|
+
<SettingsSidebar
|
|
923
|
+
entries={settingsEntries}
|
|
924
|
+
activeTabId={resolvedSettings.tabId}
|
|
925
|
+
onSelectTab={handleSelectSettingsTab}
|
|
926
|
+
onBack={exitSettings}
|
|
927
|
+
/>
|
|
928
|
+
</div>
|
|
929
|
+
<div
|
|
930
|
+
role="separator"
|
|
931
|
+
aria-orientation="vertical"
|
|
932
|
+
aria-label={t('Resize sidebar')}
|
|
933
|
+
onMouseDown={() => setIsResizing(true)}
|
|
934
|
+
onDoubleClick={resetWidth}
|
|
935
|
+
className="hidden w-1 flex-shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-agent-border/60 sm:block"
|
|
936
|
+
title={t('Drag to resize the sidebar (double-click to reset)')}
|
|
937
|
+
/>
|
|
938
|
+
</>
|
|
939
|
+
) : sidebarCollapsed ? (
|
|
842
940
|
// 收起态:窄 rail 提供展开、新对话、插件与底部设置快捷入口。
|
|
843
941
|
<div className="flex h-full w-10 flex-shrink-0 flex-col items-center border-r border-agent-border/60 bg-agent-muted/70 backdrop-blur-md">
|
|
844
942
|
<div className="flex h-11 w-full items-center justify-center">
|
|
@@ -956,12 +1054,14 @@ function AgentLayoutContent() {
|
|
|
956
1054
|
hiddenPanelCount,
|
|
957
1055
|
hiddenPanelTitle,
|
|
958
1056
|
onOpenRightPanel: expandRightSide,
|
|
1057
|
+
hiddenNavItems,
|
|
1058
|
+
onExitSettings: exitSettings,
|
|
959
1059
|
} satisfies AgentOutletContext}
|
|
960
1060
|
/>
|
|
961
1061
|
</div>
|
|
962
1062
|
{settingsChrome('insights') && <InsightsConsentBanner />}
|
|
963
1063
|
</div>
|
|
964
|
-
{(panelOpen || inspectedTask !== null) && (
|
|
1064
|
+
{!onSettingsPage && (panelOpen || inspectedTask !== null) && (
|
|
965
1065
|
<>
|
|
966
1066
|
<div
|
|
967
1067
|
role="separator"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 进程内会话输入草稿缓存(按 chatId 或首屏 '__hero__' 键控)。
|
|
3
|
+
*
|
|
4
|
+
* 用于从对话页切往 `/settings`(或切换不同会话)再返回时,无损恢复尚未发送的
|
|
5
|
+
* 输入框文本,不落盘、不污染持久化数据库。上限 50 条按最近写入顺序淘汰。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_DRAFT_ENTRIES = 50;
|
|
9
|
+
const HERO_DRAFT_KEY = '__hero__';
|
|
10
|
+
|
|
11
|
+
const drafts = new Map<string, string>();
|
|
12
|
+
|
|
13
|
+
export function resolveChatDraftKey(chatId?: string | null): string {
|
|
14
|
+
const trimmed = chatId?.trim();
|
|
15
|
+
return trimmed ? trimmed : HERO_DRAFT_KEY;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getChatDraft(chatId?: string | null): string {
|
|
19
|
+
return drafts.get(resolveChatDraftKey(chatId)) ?? '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setChatDraft(chatId: string | null | undefined, value: string): void {
|
|
23
|
+
const key = resolveChatDraftKey(chatId);
|
|
24
|
+
if (!value) {
|
|
25
|
+
drafts.delete(key);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (drafts.has(key)) {
|
|
29
|
+
drafts.delete(key);
|
|
30
|
+
} else if (drafts.size >= MAX_DRAFT_ENTRIES) {
|
|
31
|
+
const oldest = drafts.keys().next().value;
|
|
32
|
+
if (oldest !== undefined) drafts.delete(oldest);
|
|
33
|
+
}
|
|
34
|
+
drafts.set(key, value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function clearChatDraft(chatId?: string | null): void {
|
|
38
|
+
drafts.delete(resolveChatDraftKey(chatId));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function resetChatDraftsForTests(): void {
|
|
42
|
+
drafts.clear();
|
|
43
|
+
}
|
|
@@ -161,6 +161,33 @@ export function parseModeSlashCommand(rawText: string): ParsedModeSlashCommand |
|
|
|
161
161
|
return null;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
export type ParsedMemorySlashCommand =
|
|
165
|
+
| { kind: 'open-settings' }
|
|
166
|
+
| { kind: 'propose'; content: string }
|
|
167
|
+
| { kind: 'missing-content' };
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Parse built-in `/memory` and `/refine` composer commands:
|
|
171
|
+
* - `/memory` -> open long-term memory settings without spending an LLM turn
|
|
172
|
+
* - `/memory <rule>` -> propose `<rule>` directly into long-term memory
|
|
173
|
+
* - `/refine <rule>` -> propose `<rule>` directly into long-term memory
|
|
174
|
+
* - `/refine` (empty) -> report missing content without sending to LLM
|
|
175
|
+
*/
|
|
176
|
+
export function parseMemorySlashCommand(rawText: string): ParsedMemorySlashCommand | null {
|
|
177
|
+
const trimmed = rawText.trim();
|
|
178
|
+
const memoryMatch = trimmed.match(/^\/memory(?:\s+([\s\S]*))?$/i);
|
|
179
|
+
if (memoryMatch) {
|
|
180
|
+
const rest = (memoryMatch[1] ?? '').trim();
|
|
181
|
+
return rest ? { kind: 'propose', content: rest } : { kind: 'open-settings' };
|
|
182
|
+
}
|
|
183
|
+
const refineMatch = trimmed.match(/^\/refine(?:\s+([\s\S]*))?$/i);
|
|
184
|
+
if (refineMatch) {
|
|
185
|
+
const rest = (refineMatch[1] ?? '').trim();
|
|
186
|
+
return rest ? { kind: 'propose', content: rest } : { kind: 'missing-content' };
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
164
191
|
export interface ActionablePlanState {
|
|
165
192
|
messageId: string;
|
|
166
193
|
plan: ParsedProposedPlan;
|
package/src/lib/chat-title.ts
CHANGED
|
@@ -8,12 +8,25 @@
|
|
|
8
8
|
// 与后端 automation.py 的标题前缀是同一条持久化约定,不能按界面语言改写。
|
|
9
9
|
export const AUTOMATION_TITLE_PREFIX = '[自动化] '; // i18n:allow
|
|
10
10
|
const BARE_BRACKET_PREFIX = '[自动化]'; // i18n:allow
|
|
11
|
+
export const DEFAULT_STORED_CHAT_TITLE = '新对话'; // i18n:allow
|
|
11
12
|
|
|
12
13
|
export interface ParsedChatTitle {
|
|
13
14
|
displayTitle: string;
|
|
14
15
|
isAutomation: boolean;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
export function resolveChatDisplayTitle(
|
|
19
|
+
displayTitle: string,
|
|
20
|
+
fallback: string,
|
|
21
|
+
titleSource?: string | null,
|
|
22
|
+
): string {
|
|
23
|
+
if (!displayTitle) return fallback;
|
|
24
|
+
if (displayTitle === DEFAULT_STORED_CHAT_TITLE && titleSource !== 'user') {
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
return displayTitle;
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
export function parseChatTitle(
|
|
18
31
|
rawTitle: string | null | undefined,
|
|
19
32
|
): ParsedChatTitle {
|
package/src/lib/local-api.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface LocalChat {
|
|
|
20
20
|
projectId: string | null;
|
|
21
21
|
userId: string;
|
|
22
22
|
title: string;
|
|
23
|
+
titleSource?: 'user' | 'auto' | null;
|
|
23
24
|
agentId: string | null;
|
|
24
25
|
createdAt: string;
|
|
25
26
|
updatedAt: string;
|
|
@@ -1023,3 +1024,37 @@ export async function diagnoseLlmConnection(input: {
|
|
|
1023
1024
|
body: input,
|
|
1024
1025
|
});
|
|
1025
1026
|
}
|
|
1027
|
+
|
|
1028
|
+
/* ---------------- Long-term memory ---------------- */
|
|
1029
|
+
|
|
1030
|
+
export interface SavedMemoryNotice {
|
|
1031
|
+
refinementId: string;
|
|
1032
|
+
scope: 'user' | 'workspace' | 'tenant';
|
|
1033
|
+
scopeId: string;
|
|
1034
|
+
summary?: string;
|
|
1035
|
+
withdrawn?: boolean;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
export interface ProposeMemoryRefinementResponse {
|
|
1039
|
+
accepted: boolean;
|
|
1040
|
+
reason?: 'user_revoked' | 'human_edited_conflict';
|
|
1041
|
+
meta?: {
|
|
1042
|
+
id: string;
|
|
1043
|
+
scope: 'user' | 'workspace' | 'tenant';
|
|
1044
|
+
content: string;
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
export async function proposeMemoryRefinement(input: {
|
|
1049
|
+
scope: 'user' | 'workspace' | 'tenant';
|
|
1050
|
+
scopeId?: string;
|
|
1051
|
+
chatId?: string;
|
|
1052
|
+
turnId?: string;
|
|
1053
|
+
content: string;
|
|
1054
|
+
}) {
|
|
1055
|
+
return bridge().localBackend.request<ProposeMemoryRefinementResponse>({
|
|
1056
|
+
method: 'POST',
|
|
1057
|
+
path: '/api/v2/memory/propose',
|
|
1058
|
+
body: input,
|
|
1059
|
+
});
|
|
1060
|
+
}
|
package/src/packs/registry.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
PackRendererContributions,
|
|
19
19
|
PackRouteContribution,
|
|
20
20
|
PackSettingsPanelContribution,
|
|
21
|
+
SettingsNavGroup,
|
|
21
22
|
} from '@steerable/pack-sdk/web';
|
|
22
23
|
|
|
23
24
|
// 类型单一真源在 @steerable/pack-sdk/web(阶段 2.2);re-export 兼容既有调用方。
|
|
@@ -29,6 +30,7 @@ export type {
|
|
|
29
30
|
PackRendererContributions,
|
|
30
31
|
PackRouteContribution,
|
|
31
32
|
PackSettingsPanelContribution,
|
|
33
|
+
SettingsNavGroup,
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const routes: PackRouteContribution[] = [];
|