@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
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { LuArrowLeft, LuSearch, LuX } from 'react-icons/lu';
|
|
3
|
+
import { t } from '@/i18n';
|
|
4
|
+
import { getHostBridge } from '@/lib/host-bridge';
|
|
5
|
+
import {
|
|
6
|
+
filterSettingsEntries,
|
|
7
|
+
groupSettingsNavEntries,
|
|
8
|
+
type SettingsNavEntry,
|
|
9
|
+
} from './settings-registry';
|
|
10
|
+
|
|
11
|
+
export interface SettingsSidebarProps {
|
|
12
|
+
readonly entries: readonly SettingsNavEntry[];
|
|
13
|
+
readonly activeTabId: string;
|
|
14
|
+
readonly onSelectTab: (tabId: string) => void;
|
|
15
|
+
readonly onBack: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function detectMacPlatform(): boolean {
|
|
19
|
+
const hostPlatform = getHostBridge()?.platform;
|
|
20
|
+
if (hostPlatform) return hostPlatform === 'darwin';
|
|
21
|
+
if (typeof navigator !== 'undefined') {
|
|
22
|
+
return /mac/i.test(navigator.platform || navigator.userAgent || '');
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `/settings` 激活时原地替换主会话侧边栏的 Codex 式设置导航栏:
|
|
29
|
+
* - 顶部提供 `← 返回对话`(支持 `⌘,` / `Ctrl+,` 往返);
|
|
30
|
+
* - 内置实时搜索框(匹配标题、描述与隐藏别名词条,支持上下键与回车);
|
|
31
|
+
* - 下方按「应用 · 能力与扩展 · 数据与安全」三级语义分组展示。
|
|
32
|
+
*/
|
|
33
|
+
export function SettingsSidebar({
|
|
34
|
+
entries,
|
|
35
|
+
activeTabId,
|
|
36
|
+
onSelectTab,
|
|
37
|
+
onBack,
|
|
38
|
+
}: SettingsSidebarProps) {
|
|
39
|
+
const [query, setQuery] = useState('');
|
|
40
|
+
const [highlightedIdx, setHighlightedIdx] = useState(0);
|
|
41
|
+
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
42
|
+
const isMac = detectMacPlatform();
|
|
43
|
+
const shortcutLabel = isMac ? '⌘,' : 'Ctrl+,';
|
|
44
|
+
|
|
45
|
+
const trimmedQuery = query.trim();
|
|
46
|
+
const isSearching = trimmedQuery.length > 0;
|
|
47
|
+
|
|
48
|
+
const filteredEntries = useMemo(
|
|
49
|
+
() => filterSettingsEntries(entries, query),
|
|
50
|
+
[entries, query],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const groupedSections = useMemo(
|
|
54
|
+
() => groupSettingsNavEntries(entries),
|
|
55
|
+
[entries],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const clampedHighlight =
|
|
59
|
+
filteredEntries.length === 0
|
|
60
|
+
? -1
|
|
61
|
+
: Math.min(highlightedIdx, filteredEntries.length - 1);
|
|
62
|
+
|
|
63
|
+
const renderNavButton = (item: SettingsNavEntry, isKeyboardHighlighted = false) => {
|
|
64
|
+
const isActive = item.id === activeTabId;
|
|
65
|
+
return (
|
|
66
|
+
<button
|
|
67
|
+
key={item.id}
|
|
68
|
+
type="button"
|
|
69
|
+
aria-current={isActive ? 'page' : undefined}
|
|
70
|
+
data-testid={`settings-nav-item-${item.id}`}
|
|
71
|
+
onClick={() => onSelectTab(item.id)}
|
|
72
|
+
className={[
|
|
73
|
+
'flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors',
|
|
74
|
+
isActive
|
|
75
|
+
? 'bg-agent-foreground/10 font-medium text-agent-foreground'
|
|
76
|
+
: isKeyboardHighlighted
|
|
77
|
+
? 'bg-agent-foreground/6 text-agent-foreground'
|
|
78
|
+
: 'text-agent-muted-foreground hover:bg-agent-foreground/5 hover:text-agent-foreground',
|
|
79
|
+
].join(' ')}
|
|
80
|
+
>
|
|
81
|
+
<item.Icon
|
|
82
|
+
className={`h-3.5 w-3.5 shrink-0 ${
|
|
83
|
+
isActive ? 'text-agent-foreground' : 'text-agent-muted-foreground'
|
|
84
|
+
}`}
|
|
85
|
+
/>
|
|
86
|
+
<div className="min-w-0 flex-1">
|
|
87
|
+
<div className="truncate">{item.label}</div>
|
|
88
|
+
{isSearching && item.matchHint ? (
|
|
89
|
+
<div className="truncate text-[10px] font-normal text-agent-muted-foreground">
|
|
90
|
+
{item.matchHint}
|
|
91
|
+
</div>
|
|
92
|
+
) : null}
|
|
93
|
+
</div>
|
|
94
|
+
{item.badge ? (
|
|
95
|
+
<span className="shrink-0 font-mono text-[10px] tabular-nums text-agent-muted-foreground/80">
|
|
96
|
+
{item.badge}
|
|
97
|
+
</span>
|
|
98
|
+
) : null}
|
|
99
|
+
</button>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<aside
|
|
105
|
+
data-testid="settings-side-nav"
|
|
106
|
+
aria-label={t('Settings section navigation')}
|
|
107
|
+
className="flex h-full w-full flex-col border-r border-agent-border/60 bg-agent-muted/70 backdrop-blur-md select-none"
|
|
108
|
+
>
|
|
109
|
+
{/* ───── 返回原对话顶栏 ───── */}
|
|
110
|
+
<div className="flex h-11 shrink-0 items-center justify-between px-2.5">
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
data-testid="settings-back"
|
|
114
|
+
onClick={onBack}
|
|
115
|
+
title={`${t('Back to chat')} (${shortcutLabel})`}
|
|
116
|
+
className="group/back inline-flex h-7 items-center gap-1.5 rounded-full px-2 text-xs font-medium text-agent-muted-foreground transition-colors hover:bg-agent-foreground/6 hover:text-agent-foreground"
|
|
117
|
+
>
|
|
118
|
+
<LuArrowLeft className="h-3.5 w-3.5 shrink-0 transition-transform group-hover/back:-translate-x-0.5" />
|
|
119
|
+
<span>{t('Back to chat')}</span>
|
|
120
|
+
</button>
|
|
121
|
+
<kbd
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
className="px-1.5 font-sans text-[10px] text-agent-muted-foreground/60"
|
|
124
|
+
>
|
|
125
|
+
{shortcutLabel}
|
|
126
|
+
</kbd>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
{/* ───── 标题 + 搜索框 ───── */}
|
|
130
|
+
<div className="shrink-0 space-y-2 px-2.5 pb-2">
|
|
131
|
+
<div className="px-2 text-sm font-semibold tracking-tight text-agent-foreground">
|
|
132
|
+
{t('Settings')}
|
|
133
|
+
</div>
|
|
134
|
+
<div className="group/search relative flex h-7 w-full items-center rounded-full bg-agent-canvas/70 px-2.5 text-xs text-agent-muted-foreground ring-1 ring-inset ring-agent-border/60 transition-colors focus-within:bg-agent-canvas focus-within:text-agent-foreground focus-within:ring-agent-border">
|
|
135
|
+
<LuSearch
|
|
136
|
+
className="mr-1.5 h-3.5 w-3.5 shrink-0 text-agent-muted-foreground"
|
|
137
|
+
aria-hidden="true"
|
|
138
|
+
/>
|
|
139
|
+
<input
|
|
140
|
+
ref={searchInputRef}
|
|
141
|
+
type="search"
|
|
142
|
+
value={query}
|
|
143
|
+
onChange={(event) => {
|
|
144
|
+
setQuery(event.target.value);
|
|
145
|
+
setHighlightedIdx(0);
|
|
146
|
+
}}
|
|
147
|
+
onKeyDown={(event) => {
|
|
148
|
+
if (event.key === 'Escape') {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
if (query) {
|
|
152
|
+
setQuery('');
|
|
153
|
+
setHighlightedIdx(0);
|
|
154
|
+
} else {
|
|
155
|
+
searchInputRef.current?.blur();
|
|
156
|
+
onBack();
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (event.key === 'ArrowDown') {
|
|
161
|
+
if (filteredEntries.length === 0) return;
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
setHighlightedIdx((prev) => (prev + 1) % filteredEntries.length);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (event.key === 'ArrowUp') {
|
|
167
|
+
if (filteredEntries.length === 0) return;
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
setHighlightedIdx((prev) =>
|
|
170
|
+
prev <= 0 ? filteredEntries.length - 1 : prev - 1,
|
|
171
|
+
);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (event.key === 'Enter' && isSearching && clampedHighlight >= 0) {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
const target = filteredEntries[clampedHighlight];
|
|
177
|
+
if (target) onSelectTab(target.id);
|
|
178
|
+
}
|
|
179
|
+
}}
|
|
180
|
+
placeholder={t('Search settings…')}
|
|
181
|
+
aria-label={t('Search settings…')}
|
|
182
|
+
data-testid="settings-search-input"
|
|
183
|
+
className="w-full min-w-0 bg-transparent text-xs text-agent-foreground placeholder:text-agent-muted-foreground focus:outline-none [&::-webkit-search-cancel-button]:hidden"
|
|
184
|
+
/>
|
|
185
|
+
{query ? (
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
onClick={() => {
|
|
189
|
+
setQuery('');
|
|
190
|
+
setHighlightedIdx(0);
|
|
191
|
+
searchInputRef.current?.focus();
|
|
192
|
+
}}
|
|
193
|
+
aria-label={t('Clear search')}
|
|
194
|
+
data-testid="settings-search-clear"
|
|
195
|
+
className="-mr-1 ml-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-agent-muted-foreground hover:bg-agent-foreground/10 hover:text-agent-foreground"
|
|
196
|
+
>
|
|
197
|
+
<LuX className="h-3 w-3" />
|
|
198
|
+
</button>
|
|
199
|
+
) : null}
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
{/* ───── 三级语义分组树 / 搜索结果 ───── */}
|
|
204
|
+
<nav
|
|
205
|
+
aria-label={t('Settings')}
|
|
206
|
+
className="min-h-0 flex-1 space-y-3 overflow-y-auto px-2.5 pb-3 pt-1"
|
|
207
|
+
>
|
|
208
|
+
{isSearching ? (
|
|
209
|
+
filteredEntries.length === 0 ? (
|
|
210
|
+
<p
|
|
211
|
+
data-testid="settings-search-empty"
|
|
212
|
+
className="px-2 py-4 text-center text-xs text-agent-muted-foreground"
|
|
213
|
+
>
|
|
214
|
+
{t('No matching settings')}
|
|
215
|
+
</p>
|
|
216
|
+
) : (
|
|
217
|
+
<div className="space-y-0.5">
|
|
218
|
+
{filteredEntries.map((item, idx) =>
|
|
219
|
+
renderNavButton(item, idx === clampedHighlight),
|
|
220
|
+
)}
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
223
|
+
) : (
|
|
224
|
+
groupedSections.map((section) => (
|
|
225
|
+
<div key={section.group} className="space-y-0.5">
|
|
226
|
+
<div className="px-2.5 pb-1 pt-1 text-[11px] font-medium text-agent-muted-foreground/80">
|
|
227
|
+
{section.title}
|
|
228
|
+
</div>
|
|
229
|
+
{section.items.map((item) => renderNavButton(item))}
|
|
230
|
+
</div>
|
|
231
|
+
))
|
|
232
|
+
)}
|
|
233
|
+
</nav>
|
|
234
|
+
</aside>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default SettingsSidebar;
|
|
@@ -154,11 +154,10 @@ export function SkillsSettingsPanel() {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
return (
|
|
157
|
-
<div className="space-y-
|
|
157
|
+
<div className="space-y-5">
|
|
158
158
|
{/* Import Skill Bar */}
|
|
159
|
-
<div className="
|
|
160
|
-
<h4 className="text-xs font-
|
|
161
|
-
<LuBlocks className="h-3.5 w-3.5 text-agent-muted-foreground" />
|
|
159
|
+
<div className="space-y-2.5 border-t border-b border-agent-border/60 py-4">
|
|
160
|
+
<h4 className="text-xs font-medium text-agent-foreground">
|
|
162
161
|
{t('Import local skill directory')}
|
|
163
162
|
</h4>
|
|
164
163
|
<p className="text-[11px] text-agent-muted-foreground">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { LuLoaderCircle
|
|
2
|
+
import { LuLoaderCircle } from 'react-icons/lu';
|
|
3
3
|
import { t } from '@/i18n';
|
|
4
4
|
import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
|
|
5
5
|
|
|
@@ -85,12 +85,7 @@ export function TelemetrySettingsPanel() {
|
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
87
|
<div className="space-y-3">
|
|
88
|
-
<div className="
|
|
89
|
-
<h4 className="text-xs font-semibold text-agent-foreground flex items-center gap-1.5">
|
|
90
|
-
<LuActivity className="h-3.5 w-3.5 text-agent-muted-foreground" />
|
|
91
|
-
OTLP Collector
|
|
92
|
-
</h4>
|
|
93
|
-
|
|
88
|
+
<div className="space-y-3">
|
|
94
89
|
{loading ? (
|
|
95
90
|
<div className="flex items-center gap-2 py-2 text-xs text-agent-muted-foreground">
|
|
96
91
|
<LuLoaderCircle className="h-3.5 w-3.5 animate-spin" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { LuLoaderCircle,
|
|
2
|
+
import { LuLoaderCircle, LuRefreshCw } from 'react-icons/lu';
|
|
3
3
|
import { t } from '@/i18n';
|
|
4
4
|
import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
|
|
5
5
|
|
|
@@ -89,39 +89,32 @@ export function UsagePanel() {
|
|
|
89
89
|
}, [fetchSummary, days]);
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
|
-
<div className="space-y-3">
|
|
93
|
-
<div className="
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
className="h-6 w-6 rounded-full border border-agent-border bg-agent-canvas text-agent-muted-foreground hover:bg-agent-muted/40 flex items-center justify-center"
|
|
119
|
-
title={t('Refresh')}
|
|
120
|
-
>
|
|
121
|
-
<LuRefreshCw className={`h-3 w-3 ${loading ? 'animate-spin' : ''}`} />
|
|
122
|
-
</button>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
92
|
+
<div className="space-y-3 border-t border-agent-border/60 pt-3">
|
|
93
|
+
<div className="flex items-center justify-end gap-1.5">
|
|
94
|
+
{WINDOW_OPTIONS.map((opt) => (
|
|
95
|
+
<button
|
|
96
|
+
key={opt.days}
|
|
97
|
+
type="button"
|
|
98
|
+
onClick={() => setDays(opt.days)}
|
|
99
|
+
className={`h-6 rounded-md px-2.5 text-xs font-medium transition-colors ${
|
|
100
|
+
days === opt.days
|
|
101
|
+
? 'bg-agent-foreground text-agent-canvas'
|
|
102
|
+
: 'border border-agent-border bg-agent-canvas text-agent-muted-foreground hover:bg-agent-muted/40'
|
|
103
|
+
}`}
|
|
104
|
+
>
|
|
105
|
+
{t('Last {days} days', { days: opt.days })}
|
|
106
|
+
</button>
|
|
107
|
+
))}
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
onClick={() => void fetchSummary(days)}
|
|
111
|
+
disabled={loading}
|
|
112
|
+
className="flex h-6 w-6 items-center justify-center rounded-md border border-agent-border bg-agent-canvas text-agent-muted-foreground hover:bg-agent-muted/40"
|
|
113
|
+
title={t('Refresh')}
|
|
114
|
+
>
|
|
115
|
+
<LuRefreshCw className={`h-3 w-3 ${loading ? 'animate-spin' : ''}`} />
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
125
118
|
|
|
126
119
|
{loading && !summary ? (
|
|
127
120
|
<div className="flex items-center gap-2 py-4 text-xs text-agent-muted-foreground">
|
|
@@ -199,7 +192,6 @@ export function UsagePanel() {
|
|
|
199
192
|
)}
|
|
200
193
|
</>
|
|
201
194
|
)}
|
|
202
|
-
</div>
|
|
203
195
|
|
|
204
196
|
{error && (
|
|
205
197
|
<div className="rounded-agent-md border border-agent-destructive/20 bg-agent-destructive/10 p-2.5 text-xs text-agent-destructive">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { LuLoaderCircle
|
|
2
|
+
import { LuLoaderCircle } from 'react-icons/lu';
|
|
3
3
|
import { t } from '@/i18n';
|
|
4
4
|
import { getHostBridge, hasHostBridge } from '@/lib/host-bridge';
|
|
5
5
|
|
|
@@ -72,7 +72,9 @@ export function WebSearchSettingsPanel() {
|
|
|
72
72
|
setProvider(nextProvider);
|
|
73
73
|
setApiKey(saved?.apiKey ?? '');
|
|
74
74
|
if (nextProvider === 'ddg') {
|
|
75
|
-
setStatus(
|
|
75
|
+
setStatus(
|
|
76
|
+
t('Saved. After you restart the app, the sidecar registers free search (DuckDuckGo).'),
|
|
77
|
+
);
|
|
76
78
|
} else if (saved?.apiKey) {
|
|
77
79
|
setStatus(t('Saved. After you restart the app, the sidecar registers web_search.'));
|
|
78
80
|
} else {
|
|
@@ -90,97 +92,96 @@ export function WebSearchSettingsPanel() {
|
|
|
90
92
|
};
|
|
91
93
|
|
|
92
94
|
return (
|
|
93
|
-
<div className="space-y-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
{t('
|
|
98
|
-
</
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<div className="
|
|
102
|
-
<
|
|
103
|
-
|
|
95
|
+
<div className="space-y-4">
|
|
96
|
+
{loading ? (
|
|
97
|
+
<div className="flex items-center gap-2 py-2 text-xs text-agent-muted-foreground">
|
|
98
|
+
<LuLoaderCircle className="h-3.5 w-3.5 animate-spin" />
|
|
99
|
+
{t('Loading search settings...')}
|
|
100
|
+
</div>
|
|
101
|
+
) : (
|
|
102
|
+
<div className="divide-y divide-agent-border/60 border-t border-b border-agent-border/60">
|
|
103
|
+
<div className="space-y-2 py-3.5">
|
|
104
|
+
<label className="block text-xs font-medium text-agent-foreground">
|
|
105
|
+
{t('Search backend')}
|
|
106
|
+
</label>
|
|
107
|
+
<div className="grid grid-cols-2 gap-2.5">
|
|
108
|
+
{(
|
|
109
|
+
[
|
|
110
|
+
{ value: 'ddg', label: 'Free', hint: 'DuckDuckGo, no key needed' },
|
|
111
|
+
{
|
|
112
|
+
value: 'tavily',
|
|
113
|
+
label: 'Tavily',
|
|
114
|
+
hint: 'Needs an API key, more reliable results',
|
|
115
|
+
},
|
|
116
|
+
] as const
|
|
117
|
+
).map((opt) => (
|
|
118
|
+
<button
|
|
119
|
+
key={opt.value}
|
|
120
|
+
type="button"
|
|
121
|
+
data-testid={`web-search-provider-${opt.value}`}
|
|
122
|
+
onClick={() => setProvider(opt.value)}
|
|
123
|
+
className={`rounded-lg border px-3 py-2.5 text-left transition-colors ${
|
|
124
|
+
provider === opt.value
|
|
125
|
+
? 'border-agent-foreground/40 bg-agent-foreground/5'
|
|
126
|
+
: 'border-agent-border bg-agent-canvas hover:bg-agent-muted/40'
|
|
127
|
+
}`}
|
|
128
|
+
>
|
|
129
|
+
<div className="text-xs font-medium text-agent-foreground">{t(opt.label)}</div>
|
|
130
|
+
<div className="mt-0.5 text-[11px] text-agent-muted-foreground">
|
|
131
|
+
{t(opt.hint)}
|
|
132
|
+
</div>
|
|
133
|
+
</button>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
104
136
|
</div>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<div className="space-y-1.5">
|
|
108
|
-
<label className="text-
|
|
109
|
-
|
|
137
|
+
|
|
138
|
+
{provider === 'tavily' && (
|
|
139
|
+
<div className="space-y-1.5 py-3.5">
|
|
140
|
+
<label className="block text-xs font-medium text-agent-foreground">
|
|
141
|
+
Tavily API Key
|
|
110
142
|
</label>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
key={opt.value}
|
|
120
|
-
type="button"
|
|
121
|
-
data-testid={`web-search-provider-${opt.value}`}
|
|
122
|
-
onClick={() => setProvider(opt.value)}
|
|
123
|
-
className={`flex-1 rounded-agent-md border px-3 py-2 text-left transition-colors ${
|
|
124
|
-
provider === opt.value
|
|
125
|
-
? 'border-agent-foreground/40 bg-agent-foreground/5'
|
|
126
|
-
: 'border-agent-border bg-agent-canvas hover:bg-agent-muted/40'
|
|
127
|
-
}`}
|
|
128
|
-
>
|
|
129
|
-
<div className="text-xs font-medium text-agent-foreground">{t(opt.label)}</div>
|
|
130
|
-
<div className="text-[10px] text-agent-muted-foreground">{t(opt.hint)}</div>
|
|
131
|
-
</button>
|
|
132
|
-
))}
|
|
133
|
-
</div>
|
|
143
|
+
<input
|
|
144
|
+
type="password"
|
|
145
|
+
value={apiKey}
|
|
146
|
+
onChange={(e) => setApiKey(e.target.value)}
|
|
147
|
+
placeholder={t('tvly-... (leave blank = do not register Tavily)')}
|
|
148
|
+
className="h-8 w-full rounded-md border border-agent-border bg-agent-canvas px-3 font-mono text-xs text-agent-foreground focus:outline-none focus:ring-2 focus:ring-agent-foreground/30"
|
|
149
|
+
autoComplete="off"
|
|
150
|
+
/>
|
|
134
151
|
</div>
|
|
152
|
+
)}
|
|
135
153
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
</p>
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
onClick={handleSave}
|
|
165
|
-
disabled={saving}
|
|
166
|
-
className={`h-8 shrink-0 px-4 rounded-full text-xs font-medium transition-all ${
|
|
167
|
-
saving
|
|
168
|
-
? 'bg-agent-muted text-agent-muted-foreground cursor-not-allowed'
|
|
169
|
-
: 'bg-agent-foreground text-agent-canvas hover:opacity-90'
|
|
170
|
-
}`}
|
|
171
|
-
>
|
|
172
|
-
{saving ? <LuLoaderCircle className="h-3 w-3 animate-spin" /> : t('Save')}
|
|
173
|
-
</button>
|
|
174
|
-
</div>
|
|
154
|
+
<div className="flex items-center justify-between gap-4 py-3.5">
|
|
155
|
+
<p className="text-xs leading-relaxed text-agent-muted-foreground">
|
|
156
|
+
{provider === 'ddg'
|
|
157
|
+
? t(
|
|
158
|
+
'The free backend uses the public DuckDuckGo search page and needs no key. Quality and reliability are lower than Tavily, and networks in mainland China may need a system proxy. Harbor evaluations still turn off network tools.',
|
|
159
|
+
)
|
|
160
|
+
: t(
|
|
161
|
+
'GLM / OpenRouter / DeepSeek need this key. OpenAI (api.openai.com) can use the chat credentials for hosted search with no extra setup. Harbor evaluations still turn off network tools.',
|
|
162
|
+
)}
|
|
163
|
+
</p>
|
|
164
|
+
<button
|
|
165
|
+
type="button"
|
|
166
|
+
onClick={handleSave}
|
|
167
|
+
disabled={saving}
|
|
168
|
+
className={`h-8 shrink-0 rounded-full px-4 text-xs font-medium transition-all ${
|
|
169
|
+
saving
|
|
170
|
+
? 'cursor-not-allowed bg-agent-muted text-agent-muted-foreground'
|
|
171
|
+
: 'bg-agent-foreground text-agent-canvas hover:opacity-90'
|
|
172
|
+
}`}
|
|
173
|
+
>
|
|
174
|
+
{saving ? <LuLoaderCircle className="h-3 w-3 animate-spin" /> : t('Save')}
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
)}
|
|
175
179
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</>
|
|
182
|
-
)}
|
|
183
|
-
</div>
|
|
180
|
+
{status && (
|
|
181
|
+
<p className="rounded-md border border-agent-border/50 bg-agent-muted/30 px-3 py-2 text-xs text-agent-muted-foreground">
|
|
182
|
+
{status}
|
|
183
|
+
</p>
|
|
184
|
+
)}
|
|
184
185
|
|
|
185
186
|
{error && (
|
|
186
187
|
<div className="rounded-agent-md border border-agent-destructive/20 bg-agent-destructive/10 p-2.5 text-xs text-agent-destructive">
|