dsh-web-search-enhanced 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +77 -0
- package/cordis.patch.yml +20 -0
- package/docs/design.zh-CN.md +79 -0
- package/docs/harness-contract.md +30 -0
- package/docs/template-comparison.md +35 -0
- package/lib/client.js +872 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +507 -0
- package/lib/types/client/SearchSettingsCard.d.ts +62 -0
- package/lib/types/client/index.d.ts +11 -0
- package/lib/types/client/locales.d.ts +61 -0
- package/lib/types/index.d.ts +54 -0
- package/lib/types/protocols.d.ts +45 -0
- package/lib/types/provider.d.ts +16 -0
- package/package.json +129 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-web-search-enhanced",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region lib/types/client/SearchSettingsCard.js
|
|
10
|
+
const editableFields = [
|
|
11
|
+
"modelMode",
|
|
12
|
+
"protocol",
|
|
13
|
+
"baseURL",
|
|
14
|
+
"model",
|
|
15
|
+
"fallbackModel",
|
|
16
|
+
"apiKeyEnv",
|
|
17
|
+
"apiVersion",
|
|
18
|
+
"toolIdentifier",
|
|
19
|
+
"maxTokens",
|
|
20
|
+
"maxUses",
|
|
21
|
+
"chatSearchMode",
|
|
22
|
+
"searchContextSize"
|
|
23
|
+
];
|
|
24
|
+
/** Convert resolved settings into a stable form draft. */
|
|
25
|
+
function draftFrom(value) {
|
|
26
|
+
return {
|
|
27
|
+
modelMode: value?.modelMode ?? "configured",
|
|
28
|
+
protocol: value?.protocol ?? "anthropic-messages",
|
|
29
|
+
baseURL: value?.baseURL ?? "https://api.deepseek.com/anthropic/v1",
|
|
30
|
+
model: value?.model ?? "deepseek-v4-flash",
|
|
31
|
+
fallbackModel: value?.fallbackModel ?? "",
|
|
32
|
+
apiKeyEnv: value?.apiKeyEnv ?? "WEB_SEARCH_ENHANCED_API",
|
|
33
|
+
apiVersion: value?.apiVersion ?? "2023-06-01",
|
|
34
|
+
toolIdentifier: value?.toolIdentifier ?? "",
|
|
35
|
+
maxTokens: String(value?.maxTokens ?? 4096),
|
|
36
|
+
maxUses: String(value?.maxUses ?? 5),
|
|
37
|
+
chatSearchMode: value?.chatSearchMode ?? "search-model",
|
|
38
|
+
searchContextSize: value?.searchContextSize ?? ""
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Validate a draft and return field-specific locale keys. */
|
|
42
|
+
async function saveCredential(credentials, ref, value) {
|
|
43
|
+
const secret = value.trim();
|
|
44
|
+
if (secret.length === 0) return false;
|
|
45
|
+
const result = await credentials.set(ref.trim(), secret);
|
|
46
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
function validateDraft(draft) {
|
|
50
|
+
const errors = {};
|
|
51
|
+
try {
|
|
52
|
+
const url = new URL(draft.baseURL);
|
|
53
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") errors.baseURL = "invalidURL";
|
|
54
|
+
} catch {
|
|
55
|
+
errors.baseURL = "invalidURL";
|
|
56
|
+
}
|
|
57
|
+
if (draft.model.trim().length === 0) errors.model = "invalidRequired";
|
|
58
|
+
if (draft.apiKeyEnv.trim().length === 0) errors.apiKeyEnv = "invalidRequired";
|
|
59
|
+
if (draft.apiKeyEnv.trim().length > 0 && !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(draft.apiKeyEnv.trim())) errors.apiKeyEnv = "invalidCredentialRef";
|
|
60
|
+
if (draft.apiVersion.trim().length === 0) errors.apiVersion = "invalidRequired";
|
|
61
|
+
if (draft.toolIdentifier.length > 0 && !/^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/u.test(draft.toolIdentifier)) errors.toolIdentifier = "invalidIdentifier";
|
|
62
|
+
if (!positiveInteger(draft.maxTokens)) errors.maxTokens = "invalidInteger";
|
|
63
|
+
if (!positiveInteger(draft.maxUses)) errors.maxUses = "invalidInteger";
|
|
64
|
+
return errors;
|
|
65
|
+
}
|
|
66
|
+
const cardCss = `
|
|
67
|
+
.wse-card {
|
|
68
|
+
list-style: none;
|
|
69
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
70
|
+
border-radius: 12px;
|
|
71
|
+
background: var(--dsw-alias-bg-layer-3);
|
|
72
|
+
color: var(--dsw-alias-label-primary);
|
|
73
|
+
transition: border-color .16s, background .16s;
|
|
74
|
+
}
|
|
75
|
+
.wse-card:hover {
|
|
76
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
77
|
+
}
|
|
78
|
+
.wse-card[data-open='true'] {
|
|
79
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
80
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
81
|
+
}
|
|
82
|
+
.wse-header {
|
|
83
|
+
width: 100%;
|
|
84
|
+
appearance: none;
|
|
85
|
+
border: 0;
|
|
86
|
+
background: none;
|
|
87
|
+
font: inherit;
|
|
88
|
+
color: inherit;
|
|
89
|
+
text-align: left;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: 12px;
|
|
94
|
+
padding: 14px 16px;
|
|
95
|
+
border-radius: 12px;
|
|
96
|
+
}
|
|
97
|
+
.wse-header:focus-visible {
|
|
98
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
99
|
+
outline-offset: -2px;
|
|
100
|
+
}
|
|
101
|
+
.wse-head {
|
|
102
|
+
flex: 1;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
gap: 4px;
|
|
107
|
+
}
|
|
108
|
+
.wse-name {
|
|
109
|
+
color: var(--dsw-alias-label-primary);
|
|
110
|
+
font-size: 15px;
|
|
111
|
+
font-weight: 600;
|
|
112
|
+
line-height: 1.4;
|
|
113
|
+
}
|
|
114
|
+
.wse-desc {
|
|
115
|
+
color: var(--dsw-alias-label-tertiary);
|
|
116
|
+
font-size: 13px;
|
|
117
|
+
line-height: 1.5;
|
|
118
|
+
}
|
|
119
|
+
.wse-pending {
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
background: var(--dsw-alias-bg-module-platform);
|
|
122
|
+
color: var(--dsw-alias-label-secondary);
|
|
123
|
+
border-radius: 999px;
|
|
124
|
+
flex: none;
|
|
125
|
+
padding: 1px 8px;
|
|
126
|
+
font-size: 11px;
|
|
127
|
+
font-weight: 500;
|
|
128
|
+
line-height: 17px;
|
|
129
|
+
}
|
|
130
|
+
.wse-chevron {
|
|
131
|
+
box-sizing: border-box;
|
|
132
|
+
flex: none;
|
|
133
|
+
width: 8px;
|
|
134
|
+
height: 8px;
|
|
135
|
+
margin-right: 3px;
|
|
136
|
+
border-right: 1.5px solid var(--dsw-alias-label-tertiary);
|
|
137
|
+
border-bottom: 1.5px solid var(--dsw-alias-label-tertiary);
|
|
138
|
+
transform: rotate(45deg);
|
|
139
|
+
transition: transform .16s;
|
|
140
|
+
}
|
|
141
|
+
.wse-card[data-open='true'] .wse-chevron {
|
|
142
|
+
transform: rotate(225deg);
|
|
143
|
+
}
|
|
144
|
+
.wse-body {
|
|
145
|
+
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
146
|
+
margin: 0 16px;
|
|
147
|
+
padding-bottom: 8px;
|
|
148
|
+
}
|
|
149
|
+
.wse-fields {
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
}
|
|
153
|
+
.wse-field {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
gap: 6px;
|
|
157
|
+
padding: 12px 0;
|
|
158
|
+
}
|
|
159
|
+
.wse-field + .wse-field {
|
|
160
|
+
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
161
|
+
}
|
|
162
|
+
.wse-label {
|
|
163
|
+
color: var(--dsw-alias-label-primary);
|
|
164
|
+
font-size: 13px;
|
|
165
|
+
font-weight: 500;
|
|
166
|
+
line-height: 1.5;
|
|
167
|
+
}
|
|
168
|
+
.wse-input, .wse-select {
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
width: 100%;
|
|
171
|
+
height: 34px;
|
|
172
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
173
|
+
border-radius: 8px;
|
|
174
|
+
padding: 0 12px;
|
|
175
|
+
background: var(--dsw-alias-bg-layer-3);
|
|
176
|
+
color: var(--dsw-alias-label-primary);
|
|
177
|
+
font: inherit;
|
|
178
|
+
font-size: 13px;
|
|
179
|
+
line-height: 1.5;
|
|
180
|
+
outline: none;
|
|
181
|
+
transition: border-color .16s, background .16s;
|
|
182
|
+
}
|
|
183
|
+
.wse-input:focus-visible, .wse-select:focus-visible,
|
|
184
|
+
.wse-input:focus, .wse-select:focus {
|
|
185
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
186
|
+
outline: none;
|
|
187
|
+
}
|
|
188
|
+
.wse-input[aria-invalid='true'] {
|
|
189
|
+
border-color: var(--dsw-alias-label-error);
|
|
190
|
+
}
|
|
191
|
+
.wse-input:disabled, .wse-select:disabled {
|
|
192
|
+
cursor: default;
|
|
193
|
+
color: var(--dsw-alias-label-tertiary);
|
|
194
|
+
opacity: .55;
|
|
195
|
+
}
|
|
196
|
+
.wse-hint, .wse-error, .wse-readonly, .wse-failed {
|
|
197
|
+
margin: 0;
|
|
198
|
+
font-size: 12px;
|
|
199
|
+
line-height: 1.5;
|
|
200
|
+
}
|
|
201
|
+
.wse-hint {
|
|
202
|
+
color: var(--dsw-alias-label-tertiary);
|
|
203
|
+
}
|
|
204
|
+
.wse-error, .wse-failed {
|
|
205
|
+
color: var(--dsw-alias-label-error);
|
|
206
|
+
}
|
|
207
|
+
.wse-readonly {
|
|
208
|
+
margin: 12px 0 0;
|
|
209
|
+
color: var(--dsw-alias-label-tertiary);
|
|
210
|
+
}
|
|
211
|
+
.wse-footer {
|
|
212
|
+
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
213
|
+
margin-top: 4px;
|
|
214
|
+
display: flex;
|
|
215
|
+
align-items: center;
|
|
216
|
+
justify-content: flex-end;
|
|
217
|
+
gap: 8px;
|
|
218
|
+
padding: 12px 0 4px;
|
|
219
|
+
}
|
|
220
|
+
.wse-failed {
|
|
221
|
+
flex: 1;
|
|
222
|
+
min-width: 0;
|
|
223
|
+
margin: 0;
|
|
224
|
+
}
|
|
225
|
+
.wse-actions {
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
gap: 8px;
|
|
229
|
+
margin-left: auto;
|
|
230
|
+
}
|
|
231
|
+
.wse-button {
|
|
232
|
+
appearance: none;
|
|
233
|
+
font: inherit;
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
236
|
+
border-radius: 8px;
|
|
237
|
+
padding: 5px 14px;
|
|
238
|
+
font-size: 13px;
|
|
239
|
+
line-height: 1.5;
|
|
240
|
+
background: transparent;
|
|
241
|
+
color: var(--dsw-alias-label-secondary);
|
|
242
|
+
transition: color .16s, border-color .16s, background .16s, opacity .16s;
|
|
243
|
+
}
|
|
244
|
+
.wse-button:hover:not(:disabled) {
|
|
245
|
+
color: var(--dsw-alias-label-primary);
|
|
246
|
+
border-color: var(--dsw-alias-label-dimmed);
|
|
247
|
+
background: var(--dsw-alias-bg-layer-4);
|
|
248
|
+
}
|
|
249
|
+
.wse-button:focus-visible {
|
|
250
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
251
|
+
outline-offset: 1px;
|
|
252
|
+
}
|
|
253
|
+
.wse-button:disabled {
|
|
254
|
+
opacity: .4;
|
|
255
|
+
cursor: default;
|
|
256
|
+
}
|
|
257
|
+
.wse-save {
|
|
258
|
+
border-color: transparent;
|
|
259
|
+
background: var(--dsw-alias-label-primary);
|
|
260
|
+
color: var(--dsw-alias-label-primary-foreground, var(--dsw-alias-bg-layer-3));
|
|
261
|
+
}
|
|
262
|
+
.wse-save:hover:not(:disabled) {
|
|
263
|
+
background: var(--dsw-alias-label-primary);
|
|
264
|
+
opacity: .9;
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
267
|
+
function SearchSettingsCard({ scope, credentials, t }) {
|
|
268
|
+
const snapshot = (0, react.useSyncExternalStore)(scope.subscribe.bind(scope), scope.getSnapshot.bind(scope));
|
|
269
|
+
const resolved = (0, react.useMemo)(() => draftFrom(snapshot.value), [snapshot.value]);
|
|
270
|
+
const [draft, setDraft] = (0, react.useState)(resolved);
|
|
271
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
272
|
+
const [saving, setSaving] = (0, react.useState)(false);
|
|
273
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
274
|
+
const [hasDraft, setHasDraft] = (0, react.useState)(false);
|
|
275
|
+
const [resetToProfile, setResetToProfile] = (0, react.useState)(false);
|
|
276
|
+
const [apiKey, setApiKey] = (0, react.useState)("");
|
|
277
|
+
const [credentialConfigured, setCredentialConfigured] = (0, react.useState)(false);
|
|
278
|
+
const bodyId = (0, react.useId)();
|
|
279
|
+
(0, react.useEffect)(() => {
|
|
280
|
+
if (!saving && !hasDraft) setDraft(resolved);
|
|
281
|
+
}, [
|
|
282
|
+
hasDraft,
|
|
283
|
+
resolved,
|
|
284
|
+
saving
|
|
285
|
+
]);
|
|
286
|
+
(0, react.useEffect)(() => {
|
|
287
|
+
const ref = draft.apiKeyEnv.trim();
|
|
288
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(ref)) {
|
|
289
|
+
setCredentialConfigured(false);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
let active = true;
|
|
293
|
+
credentials.describe([ref]).then((result) => {
|
|
294
|
+
if (active) setCredentialConfigured(result.ok && result.value[ref]?.configured === true);
|
|
295
|
+
}).catch(() => {
|
|
296
|
+
if (active) setCredentialConfigured(false);
|
|
297
|
+
});
|
|
298
|
+
return () => {
|
|
299
|
+
active = false;
|
|
300
|
+
};
|
|
301
|
+
}, [credentials, draft.apiKeyEnv]);
|
|
302
|
+
const errors = (0, react.useMemo)(() => validateDraft(draft), [draft]);
|
|
303
|
+
const dirty = resetToProfile || apiKey.length > 0 || JSON.stringify(draft) !== JSON.stringify(resolved);
|
|
304
|
+
const invalid = Object.keys(errors).length > 0;
|
|
305
|
+
const disabled = snapshot.status !== "ready" || !snapshot.writable || saving;
|
|
306
|
+
const edit = (field, value) => {
|
|
307
|
+
setDraft((current) => ({
|
|
308
|
+
...current,
|
|
309
|
+
[field]: value
|
|
310
|
+
}));
|
|
311
|
+
setResetToProfile(false);
|
|
312
|
+
setHasDraft(true);
|
|
313
|
+
setFailed(false);
|
|
314
|
+
};
|
|
315
|
+
const save = async () => {
|
|
316
|
+
if (disabled || !dirty || invalid) return;
|
|
317
|
+
setSaving(true);
|
|
318
|
+
setFailed(false);
|
|
319
|
+
try {
|
|
320
|
+
if (await saveCredential(credentials, draft.apiKeyEnv, apiKey)) setCredentialConfigured(true);
|
|
321
|
+
if (resetToProfile) for (const field of editableFields) await scope.unset(field);
|
|
322
|
+
else {
|
|
323
|
+
await scope.set("modelMode", draft.modelMode);
|
|
324
|
+
await scope.set("protocol", draft.protocol);
|
|
325
|
+
await scope.set("baseURL", draft.baseURL.trim());
|
|
326
|
+
await scope.set("model", draft.model.trim());
|
|
327
|
+
if (draft.fallbackModel.trim().length === 0) await scope.unset("fallbackModel");
|
|
328
|
+
else await scope.set("fallbackModel", draft.fallbackModel.trim());
|
|
329
|
+
await scope.set("apiKeyEnv", draft.apiKeyEnv.trim());
|
|
330
|
+
await scope.set("apiVersion", draft.apiVersion.trim());
|
|
331
|
+
if (draft.toolIdentifier.trim().length === 0) await scope.unset("toolIdentifier");
|
|
332
|
+
else await scope.set("toolIdentifier", draft.toolIdentifier.trim());
|
|
333
|
+
await scope.set("maxTokens", Number(draft.maxTokens));
|
|
334
|
+
await scope.set("maxUses", Number(draft.maxUses));
|
|
335
|
+
await scope.set("chatSearchMode", draft.chatSearchMode);
|
|
336
|
+
if (draft.searchContextSize === "") await scope.unset("searchContextSize");
|
|
337
|
+
else await scope.set("searchContextSize", draft.searchContextSize);
|
|
338
|
+
}
|
|
339
|
+
setApiKey("");
|
|
340
|
+
setHasDraft(false);
|
|
341
|
+
setResetToProfile(false);
|
|
342
|
+
setOpen(false);
|
|
343
|
+
} catch {
|
|
344
|
+
setFailed(true);
|
|
345
|
+
} finally {
|
|
346
|
+
setSaving(false);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const reset = () => {
|
|
350
|
+
setApiKey("");
|
|
351
|
+
setDraft(draftFrom(asSearchSettings(snapshot.base)));
|
|
352
|
+
setResetToProfile(true);
|
|
353
|
+
setHasDraft(true);
|
|
354
|
+
setFailed(false);
|
|
355
|
+
};
|
|
356
|
+
const discard = () => {
|
|
357
|
+
setApiKey("");
|
|
358
|
+
setDraft(resolved);
|
|
359
|
+
setResetToProfile(false);
|
|
360
|
+
setHasDraft(false);
|
|
361
|
+
setFailed(false);
|
|
362
|
+
};
|
|
363
|
+
if (snapshot.status === "unavailable") return null;
|
|
364
|
+
const toolHint = draft.protocol === "anthropic-messages" ? "toolHintAnthropic" : draft.protocol === "openai-responses" ? "toolHintResponses" : draft.chatSearchMode === "search-model" ? "toolHintChatOfficial" : "toolHintChatVendor";
|
|
365
|
+
return (0, react_jsx_runtime.jsxs)("li", {
|
|
366
|
+
className: "wse-card",
|
|
367
|
+
"data-open": open,
|
|
368
|
+
children: [
|
|
369
|
+
(0, react_jsx_runtime.jsx)("style", { children: cardCss }),
|
|
370
|
+
(0, react_jsx_runtime.jsxs)("button", {
|
|
371
|
+
type: "button",
|
|
372
|
+
className: "wse-header",
|
|
373
|
+
"aria-expanded": open,
|
|
374
|
+
"aria-controls": bodyId,
|
|
375
|
+
"aria-label": `${t(open ? "collapse" : "expand")}: ${t("title")}`,
|
|
376
|
+
onClick: () => {
|
|
377
|
+
setOpen((value) => !value);
|
|
378
|
+
},
|
|
379
|
+
children: [
|
|
380
|
+
(0, react_jsx_runtime.jsxs)("span", {
|
|
381
|
+
className: "wse-head",
|
|
382
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
383
|
+
className: "wse-name",
|
|
384
|
+
children: t("title")
|
|
385
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
386
|
+
className: "wse-desc",
|
|
387
|
+
children: t("description")
|
|
388
|
+
})]
|
|
389
|
+
}),
|
|
390
|
+
dirty ? (0, react_jsx_runtime.jsx)("span", {
|
|
391
|
+
className: "wse-pending",
|
|
392
|
+
children: t("unsaved")
|
|
393
|
+
}) : null,
|
|
394
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
395
|
+
className: "wse-chevron",
|
|
396
|
+
"aria-hidden": "true"
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
}),
|
|
400
|
+
open ? (0, react_jsx_runtime.jsxs)("div", {
|
|
401
|
+
className: "wse-body",
|
|
402
|
+
id: bodyId,
|
|
403
|
+
children: [
|
|
404
|
+
!snapshot.writable && snapshot.status === "ready" ? (0, react_jsx_runtime.jsx)("p", {
|
|
405
|
+
className: "wse-readonly",
|
|
406
|
+
role: "status",
|
|
407
|
+
children: t("readOnly")
|
|
408
|
+
}) : null,
|
|
409
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
410
|
+
className: "wse-fields",
|
|
411
|
+
children: [
|
|
412
|
+
(0, react_jsx_runtime.jsx)(SelectField, {
|
|
413
|
+
label: t("modelMode"),
|
|
414
|
+
hint: t("modelModeHint"),
|
|
415
|
+
value: draft.modelMode,
|
|
416
|
+
disabled,
|
|
417
|
+
onChange: (value) => {
|
|
418
|
+
edit("modelMode", value);
|
|
419
|
+
},
|
|
420
|
+
options: [["configured", t("configuredMode")], ["current-session", t("currentSessionMode")]]
|
|
421
|
+
}),
|
|
422
|
+
(0, react_jsx_runtime.jsx)(SelectField, {
|
|
423
|
+
label: t("protocol"),
|
|
424
|
+
hint: t("protocolHint"),
|
|
425
|
+
value: draft.protocol,
|
|
426
|
+
disabled,
|
|
427
|
+
onChange: (value) => {
|
|
428
|
+
edit("protocol", value);
|
|
429
|
+
},
|
|
430
|
+
options: [
|
|
431
|
+
["anthropic-messages", t("anthropic")],
|
|
432
|
+
["openai-responses", t("responses")],
|
|
433
|
+
["openai-chat-completions", t("chat")]
|
|
434
|
+
]
|
|
435
|
+
}),
|
|
436
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
437
|
+
label: t("toolIdentifier"),
|
|
438
|
+
hint: t(toolHint),
|
|
439
|
+
value: draft.toolIdentifier,
|
|
440
|
+
error: errors.toolIdentifier === void 0 ? void 0 : t(errors.toolIdentifier),
|
|
441
|
+
disabled: disabled || draft.protocol === "openai-chat-completions" && draft.chatSearchMode === "search-model",
|
|
442
|
+
onChange: (value) => {
|
|
443
|
+
edit("toolIdentifier", value);
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
447
|
+
label: t("baseURL"),
|
|
448
|
+
hint: t("baseURLHint"),
|
|
449
|
+
value: draft.baseURL,
|
|
450
|
+
error: errors.baseURL === void 0 ? void 0 : t(errors.baseURL),
|
|
451
|
+
disabled,
|
|
452
|
+
onChange: (value) => {
|
|
453
|
+
edit("baseURL", value);
|
|
454
|
+
}
|
|
455
|
+
}),
|
|
456
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
457
|
+
label: t("model"),
|
|
458
|
+
hint: t("modelHint"),
|
|
459
|
+
value: draft.model,
|
|
460
|
+
error: errors.model === void 0 ? void 0 : t(errors.model),
|
|
461
|
+
disabled,
|
|
462
|
+
onChange: (value) => {
|
|
463
|
+
edit("model", value);
|
|
464
|
+
}
|
|
465
|
+
}),
|
|
466
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
467
|
+
label: t("fallbackModel"),
|
|
468
|
+
hint: t("fallbackModelHint"),
|
|
469
|
+
value: draft.fallbackModel,
|
|
470
|
+
error: errors.fallbackModel === void 0 ? void 0 : t(errors.fallbackModel),
|
|
471
|
+
disabled,
|
|
472
|
+
onChange: (value) => {
|
|
473
|
+
edit("fallbackModel", value);
|
|
474
|
+
}
|
|
475
|
+
}),
|
|
476
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
477
|
+
label: t("apiKeyEnv"),
|
|
478
|
+
hint: credentialConfigured ? t("credentialConfigured") : t("apiKeyEnvHint"),
|
|
479
|
+
value: draft.apiKeyEnv,
|
|
480
|
+
error: errors.apiKeyEnv === void 0 ? void 0 : t(errors.apiKeyEnv),
|
|
481
|
+
disabled,
|
|
482
|
+
onChange: (value) => {
|
|
483
|
+
edit("apiKeyEnv", value);
|
|
484
|
+
}
|
|
485
|
+
}),
|
|
486
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
487
|
+
type: "password",
|
|
488
|
+
label: t("apiKey"),
|
|
489
|
+
hint: t("apiKeyHint"),
|
|
490
|
+
value: apiKey,
|
|
491
|
+
disabled,
|
|
492
|
+
onChange: (value) => {
|
|
493
|
+
setApiKey(value);
|
|
494
|
+
setHasDraft(true);
|
|
495
|
+
setFailed(false);
|
|
496
|
+
}
|
|
497
|
+
}),
|
|
498
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
499
|
+
inputMode: "numeric",
|
|
500
|
+
label: t("maxTokens"),
|
|
501
|
+
hint: t("maxTokensHint"),
|
|
502
|
+
value: draft.maxTokens,
|
|
503
|
+
error: errors.maxTokens === void 0 ? void 0 : t(errors.maxTokens),
|
|
504
|
+
disabled,
|
|
505
|
+
onChange: (value) => {
|
|
506
|
+
edit("maxTokens", value);
|
|
507
|
+
}
|
|
508
|
+
}),
|
|
509
|
+
draft.modelMode === "current-session" ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
510
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
511
|
+
inputMode: "numeric",
|
|
512
|
+
label: t("maxUses"),
|
|
513
|
+
hint: t("maxUsesHint"),
|
|
514
|
+
value: draft.maxUses,
|
|
515
|
+
error: errors.maxUses === void 0 ? void 0 : t(errors.maxUses),
|
|
516
|
+
disabled,
|
|
517
|
+
onChange: (value) => {
|
|
518
|
+
edit("maxUses", value);
|
|
519
|
+
}
|
|
520
|
+
}),
|
|
521
|
+
(0, react_jsx_runtime.jsx)(TextField, {
|
|
522
|
+
label: t("apiVersion"),
|
|
523
|
+
hint: t("apiVersionHint"),
|
|
524
|
+
value: draft.apiVersion,
|
|
525
|
+
error: errors.apiVersion === void 0 ? void 0 : t(errors.apiVersion),
|
|
526
|
+
disabled,
|
|
527
|
+
onChange: (value) => {
|
|
528
|
+
edit("apiVersion", value);
|
|
529
|
+
}
|
|
530
|
+
}),
|
|
531
|
+
(0, react_jsx_runtime.jsx)(SelectField, {
|
|
532
|
+
label: t("chatSearchMode"),
|
|
533
|
+
hint: t("chatSearchModeHint"),
|
|
534
|
+
value: draft.chatSearchMode,
|
|
535
|
+
disabled,
|
|
536
|
+
onChange: (value) => {
|
|
537
|
+
edit("chatSearchMode", value);
|
|
538
|
+
},
|
|
539
|
+
options: [["search-model", t("chatOfficial")], ["vendor-options", t("chatVendor")]]
|
|
540
|
+
}),
|
|
541
|
+
(0, react_jsx_runtime.jsx)(SelectField, {
|
|
542
|
+
label: t("searchContextSize"),
|
|
543
|
+
hint: t("searchContextSizeHint"),
|
|
544
|
+
value: draft.searchContextSize,
|
|
545
|
+
disabled,
|
|
546
|
+
onChange: (value) => {
|
|
547
|
+
edit("searchContextSize", value);
|
|
548
|
+
},
|
|
549
|
+
options: [
|
|
550
|
+
["", t("contextDefault")],
|
|
551
|
+
["low", t("contextLow")],
|
|
552
|
+
["medium", t("contextMedium")],
|
|
553
|
+
["high", t("contextHigh")]
|
|
554
|
+
]
|
|
555
|
+
})
|
|
556
|
+
] }) : draft.protocol === "anthropic-messages" ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(TextField, {
|
|
557
|
+
inputMode: "numeric",
|
|
558
|
+
label: t("maxUses"),
|
|
559
|
+
hint: t("maxUsesHint"),
|
|
560
|
+
value: draft.maxUses,
|
|
561
|
+
error: errors.maxUses === void 0 ? void 0 : t(errors.maxUses),
|
|
562
|
+
disabled,
|
|
563
|
+
onChange: (value) => {
|
|
564
|
+
edit("maxUses", value);
|
|
565
|
+
}
|
|
566
|
+
}), (0, react_jsx_runtime.jsx)(TextField, {
|
|
567
|
+
label: t("apiVersion"),
|
|
568
|
+
hint: t("apiVersionHint"),
|
|
569
|
+
value: draft.apiVersion,
|
|
570
|
+
error: errors.apiVersion === void 0 ? void 0 : t(errors.apiVersion),
|
|
571
|
+
disabled,
|
|
572
|
+
onChange: (value) => {
|
|
573
|
+
edit("apiVersion", value);
|
|
574
|
+
}
|
|
575
|
+
})] }) : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [draft.protocol === "openai-chat-completions" ? (0, react_jsx_runtime.jsx)(SelectField, {
|
|
576
|
+
label: t("chatSearchMode"),
|
|
577
|
+
hint: t("chatSearchModeHint"),
|
|
578
|
+
value: draft.chatSearchMode,
|
|
579
|
+
disabled,
|
|
580
|
+
onChange: (value) => {
|
|
581
|
+
edit("chatSearchMode", value);
|
|
582
|
+
},
|
|
583
|
+
options: [["search-model", t("chatOfficial")], ["vendor-options", t("chatVendor")]]
|
|
584
|
+
}) : null, (0, react_jsx_runtime.jsx)(SelectField, {
|
|
585
|
+
label: t("searchContextSize"),
|
|
586
|
+
hint: t("searchContextSizeHint"),
|
|
587
|
+
value: draft.searchContextSize,
|
|
588
|
+
disabled,
|
|
589
|
+
onChange: (value) => {
|
|
590
|
+
edit("searchContextSize", value);
|
|
591
|
+
},
|
|
592
|
+
options: [
|
|
593
|
+
["", t("contextDefault")],
|
|
594
|
+
["low", t("contextLow")],
|
|
595
|
+
["medium", t("contextMedium")],
|
|
596
|
+
["high", t("contextHigh")]
|
|
597
|
+
]
|
|
598
|
+
})] })
|
|
599
|
+
]
|
|
600
|
+
}),
|
|
601
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
602
|
+
className: "wse-footer",
|
|
603
|
+
children: [failed ? (0, react_jsx_runtime.jsx)("p", {
|
|
604
|
+
className: "wse-failed",
|
|
605
|
+
role: "alert",
|
|
606
|
+
children: t("failed")
|
|
607
|
+
}) : null, (0, react_jsx_runtime.jsxs)("div", {
|
|
608
|
+
className: "wse-actions",
|
|
609
|
+
children: [
|
|
610
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
611
|
+
type: "button",
|
|
612
|
+
className: "wse-button",
|
|
613
|
+
disabled: disabled || resetToProfile,
|
|
614
|
+
onClick: reset,
|
|
615
|
+
children: t("reset")
|
|
616
|
+
}),
|
|
617
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
618
|
+
type: "button",
|
|
619
|
+
className: "wse-button",
|
|
620
|
+
disabled: disabled || !dirty,
|
|
621
|
+
onClick: discard,
|
|
622
|
+
children: t("discard")
|
|
623
|
+
}),
|
|
624
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
625
|
+
type: "button",
|
|
626
|
+
className: "wse-button wse-save",
|
|
627
|
+
disabled: disabled || !dirty || invalid,
|
|
628
|
+
onClick: () => {
|
|
629
|
+
save();
|
|
630
|
+
},
|
|
631
|
+
children: saving ? t("saving") : t("save")
|
|
632
|
+
})
|
|
633
|
+
]
|
|
634
|
+
})]
|
|
635
|
+
})
|
|
636
|
+
]
|
|
637
|
+
}) : null
|
|
638
|
+
]
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function TextField(props) {
|
|
642
|
+
const id = (0, react.useId)();
|
|
643
|
+
const describedBy = (0, react.useId)();
|
|
644
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
645
|
+
className: "wse-field",
|
|
646
|
+
children: [
|
|
647
|
+
(0, react_jsx_runtime.jsx)("label", {
|
|
648
|
+
className: "wse-label",
|
|
649
|
+
htmlFor: id,
|
|
650
|
+
children: props.label
|
|
651
|
+
}),
|
|
652
|
+
(0, react_jsx_runtime.jsx)("input", {
|
|
653
|
+
id,
|
|
654
|
+
className: "wse-input",
|
|
655
|
+
type: props.type ?? "text",
|
|
656
|
+
value: props.value,
|
|
657
|
+
disabled: props.disabled,
|
|
658
|
+
inputMode: props.inputMode,
|
|
659
|
+
"aria-invalid": props.error === void 0 ? void 0 : true,
|
|
660
|
+
"aria-describedby": describedBy,
|
|
661
|
+
spellCheck: false,
|
|
662
|
+
onChange: (event) => {
|
|
663
|
+
props.onChange(event.target.value);
|
|
664
|
+
}
|
|
665
|
+
}),
|
|
666
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
667
|
+
id: describedBy,
|
|
668
|
+
className: props.error === void 0 ? "wse-hint" : "wse-error",
|
|
669
|
+
children: props.error ?? props.hint
|
|
670
|
+
})
|
|
671
|
+
]
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
function SelectField(props) {
|
|
675
|
+
const id = (0, react.useId)();
|
|
676
|
+
const describedBy = (0, react.useId)();
|
|
677
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
678
|
+
className: "wse-field",
|
|
679
|
+
children: [
|
|
680
|
+
(0, react_jsx_runtime.jsx)("label", {
|
|
681
|
+
className: "wse-label",
|
|
682
|
+
htmlFor: id,
|
|
683
|
+
children: props.label
|
|
684
|
+
}),
|
|
685
|
+
(0, react_jsx_runtime.jsx)("select", {
|
|
686
|
+
id,
|
|
687
|
+
className: "wse-select",
|
|
688
|
+
value: props.value,
|
|
689
|
+
disabled: props.disabled,
|
|
690
|
+
"aria-describedby": describedBy,
|
|
691
|
+
onChange: (event) => {
|
|
692
|
+
props.onChange(event.target.value);
|
|
693
|
+
},
|
|
694
|
+
children: props.options.map(([value, label]) => (0, react_jsx_runtime.jsx)("option", {
|
|
695
|
+
value,
|
|
696
|
+
children: label
|
|
697
|
+
}, value))
|
|
698
|
+
}),
|
|
699
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
700
|
+
id: describedBy,
|
|
701
|
+
className: "wse-hint",
|
|
702
|
+
children: props.hint
|
|
703
|
+
})
|
|
704
|
+
]
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
function asSearchSettings(value) {
|
|
708
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
709
|
+
}
|
|
710
|
+
function positiveInteger(value) {
|
|
711
|
+
const parsed = Number(value);
|
|
712
|
+
return Number.isInteger(parsed) && parsed > 0;
|
|
713
|
+
}
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region lib/types/client/locales.js
|
|
716
|
+
const en = {
|
|
717
|
+
title: "Web Search Enhanced",
|
|
718
|
+
description: "Choose the model route and built-in search settings used by web_search.",
|
|
719
|
+
expand: "Expand",
|
|
720
|
+
collapse: "Collapse",
|
|
721
|
+
unsaved: "Unsaved",
|
|
722
|
+
modelMode: "Model route",
|
|
723
|
+
modelModeHint: "Use the fixed search route or follow the model and calling protocol of the current session.",
|
|
724
|
+
configuredMode: "Fixed configuration",
|
|
725
|
+
currentSessionMode: "Current session model",
|
|
726
|
+
protocol: "API protocol",
|
|
727
|
+
protocolHint: "The fixed or fallback route protocol. Follow mode uses the current model protocol when available.",
|
|
728
|
+
anthropic: "Anthropic Messages v1",
|
|
729
|
+
responses: "OpenAI Responses API",
|
|
730
|
+
chat: "OpenAI Chat Completions API",
|
|
731
|
+
baseURL: "Endpoint base URL",
|
|
732
|
+
baseURLHint: "The protocol endpoint suffix is appended only when it is not already present.",
|
|
733
|
+
model: "Model ID",
|
|
734
|
+
modelHint: "The model used by the fixed route and when no session model is available.",
|
|
735
|
+
fallbackModel: "Fallback search model",
|
|
736
|
+
fallbackModelHint: "Optional model used when the current session route cannot be resolved; blank uses Model ID.",
|
|
737
|
+
apiKeyEnv: "API key environment variable",
|
|
738
|
+
apiKeyEnvHint: "The fixed and fallback route reads the API key from this credential reference.",
|
|
739
|
+
apiKey: "API key",
|
|
740
|
+
apiKeyHint: "Enter a new key to store it securely. The field is cleared after saving.",
|
|
741
|
+
credentialConfigured: "A credential is configured for this reference.",
|
|
742
|
+
toolIdentifier: "Internal search identifier",
|
|
743
|
+
toolHintAnthropic: "Anthropic tool type. Leave blank for web_search_20250305.",
|
|
744
|
+
toolHintResponses: "Responses built-in tool type. Leave blank for web_search.",
|
|
745
|
+
toolHintChatOfficial: "Official Chat search models use the fixed web_search_options field.",
|
|
746
|
+
toolHintChatVendor: "Vendor-specific Chat search options field. Leave blank for web_search_options.",
|
|
747
|
+
maxTokens: "Max output tokens",
|
|
748
|
+
maxTokensHint: "Positive integer sent as max_tokens or max_output_tokens for one search request.",
|
|
749
|
+
maxUses: "Max search uses",
|
|
750
|
+
maxUsesHint: "Anthropic-only maximum number of server-tool uses in one request.",
|
|
751
|
+
apiVersion: "Anthropic API version",
|
|
752
|
+
apiVersionHint: "Value sent in the anthropic-version request header.",
|
|
753
|
+
chatSearchMode: "Chat search capability",
|
|
754
|
+
chatSearchModeHint: "Use the official specialized-search-model contract unless the gateway documents a custom options field.",
|
|
755
|
+
chatOfficial: "Official search model",
|
|
756
|
+
chatVendor: "Vendor custom options field",
|
|
757
|
+
searchContextSize: "Search context size",
|
|
758
|
+
searchContextSizeHint: "Optional OpenAI-compatible context budget.",
|
|
759
|
+
contextDefault: "Provider default",
|
|
760
|
+
contextLow: "Low",
|
|
761
|
+
contextMedium: "Medium",
|
|
762
|
+
contextHigh: "High",
|
|
763
|
+
save: "Save",
|
|
764
|
+
saving: "Saving…",
|
|
765
|
+
reset: "Reset to Profile",
|
|
766
|
+
discard: "Discard",
|
|
767
|
+
readOnly: "This connection cannot persist Host Profile settings.",
|
|
768
|
+
failed: "The Host rejected the change. Review the fields and try again.",
|
|
769
|
+
invalidURL: "Enter an absolute HTTP(S) endpoint URL.",
|
|
770
|
+
invalidRequired: "This field must not be blank.",
|
|
771
|
+
invalidCredentialRef: "Use a valid environment-variable name such as WEB_SEARCH_ENHANCED_API.",
|
|
772
|
+
invalidIdentifier: "Use 1–128 identifier characters and start with a letter.",
|
|
773
|
+
invalidInteger: "Enter a positive integer."
|
|
774
|
+
};
|
|
775
|
+
const zh = {
|
|
776
|
+
title: "Web Search Enhanced",
|
|
777
|
+
description: "配置 web_search 使用的模型路由与内置搜索参数。",
|
|
778
|
+
expand: "展开",
|
|
779
|
+
collapse: "折叠",
|
|
780
|
+
unsaved: "未保存",
|
|
781
|
+
modelMode: "模型路由",
|
|
782
|
+
modelModeHint: "选择固定搜索路由,或跟随当前会话模型及其调用协议。",
|
|
783
|
+
configuredMode: "固定配置",
|
|
784
|
+
currentSessionMode: "当前会话模型",
|
|
785
|
+
protocol: "API 协议",
|
|
786
|
+
protocolHint: "固定或兜底路由使用的协议;跟随模式会优先使用当前模型协议。",
|
|
787
|
+
anthropic: "Anthropic Messages v1",
|
|
788
|
+
responses: "OpenAI Responses API",
|
|
789
|
+
chat: "OpenAI Chat Completions API",
|
|
790
|
+
baseURL: "接口基础地址",
|
|
791
|
+
baseURLHint: "仅当地址尚未包含协议端点时,插件才会自动追加相应路径。",
|
|
792
|
+
model: "模型标识",
|
|
793
|
+
modelHint: "固定路由使用的模型;当前会话没有可用模型时也会使用它。",
|
|
794
|
+
fallbackModel: "兜底搜索模型",
|
|
795
|
+
fallbackModelHint: "当前会话路由无法解析时使用的可选模型;留空使用模型标识。",
|
|
796
|
+
apiKeyEnv: "API Key 环境变量",
|
|
797
|
+
apiKeyEnvHint: "固定和兜底路由从此凭据引用读取 API Key。",
|
|
798
|
+
apiKey: "API Key",
|
|
799
|
+
apiKeyHint: "输入新 Key 后安全保存;保存成功后输入框会清空。",
|
|
800
|
+
credentialConfigured: "此凭据引用已配置。",
|
|
801
|
+
toolIdentifier: "内部搜索标识符",
|
|
802
|
+
toolHintAnthropic: "Anthropic 工具类型;留空使用 web_search_20250305。",
|
|
803
|
+
toolHintResponses: "Responses 内置工具类型;留空使用 web_search。",
|
|
804
|
+
toolHintChatOfficial: "官方 Chat 搜索模型固定使用 web_search_options 字段。",
|
|
805
|
+
toolHintChatVendor: "提供方自定义的 Chat 搜索选项字段;留空使用 web_search_options。",
|
|
806
|
+
maxTokens: "最大输出 Token",
|
|
807
|
+
maxTokensHint: "单次搜索请求使用的正整数 max_tokens 或 max_output_tokens。",
|
|
808
|
+
maxUses: "最大搜索次数",
|
|
809
|
+
maxUsesHint: "仅 Anthropic:单次请求最多调用服务端搜索工具的次数。",
|
|
810
|
+
apiVersion: "Anthropic API 版本",
|
|
811
|
+
apiVersionHint: "写入 anthropic-version 请求头的版本值。",
|
|
812
|
+
chatSearchMode: "Chat 搜索能力",
|
|
813
|
+
chatSearchModeHint: "除非网关明确说明自定义选项字段,否则请选择官方专用搜索模型协议。",
|
|
814
|
+
chatOfficial: "官方专用搜索模型",
|
|
815
|
+
chatVendor: "提供方自定义选项字段",
|
|
816
|
+
searchContextSize: "搜索上下文大小",
|
|
817
|
+
searchContextSizeHint: "可选的 OpenAI 兼容搜索上下文预算。",
|
|
818
|
+
contextDefault: "提供方默认值",
|
|
819
|
+
contextLow: "低",
|
|
820
|
+
contextMedium: "中",
|
|
821
|
+
contextHigh: "高",
|
|
822
|
+
save: "保存",
|
|
823
|
+
saving: "正在保存…",
|
|
824
|
+
reset: "重置为 Profile 配置",
|
|
825
|
+
discard: "放弃修改",
|
|
826
|
+
readOnly: "当前连接不能持久化 Host Profile 设置。",
|
|
827
|
+
failed: "Host 拒绝了修改,请检查字段后重试。",
|
|
828
|
+
invalidURL: "请输入绝对 HTTP(S) 接口地址。",
|
|
829
|
+
invalidRequired: "此字段不能为空。",
|
|
830
|
+
invalidCredentialRef: "请输入有效的环境变量名,例如 WEB_SEARCH_ENHANCED_API。",
|
|
831
|
+
invalidIdentifier: "请输入 1–128 位标识符字符,并以字母开头。",
|
|
832
|
+
invalidInteger: "请输入正整数。"
|
|
833
|
+
};
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region lib/types/client/index.js
|
|
836
|
+
const SETTINGS_NAMESPACE = "web-search-enhanced";
|
|
837
|
+
const LOCALE_NAMESPACE = "settings.webSearchEnhanced";
|
|
838
|
+
/** Browser plugin dependencies. */
|
|
839
|
+
const inject = [
|
|
840
|
+
"slots",
|
|
841
|
+
"locale",
|
|
842
|
+
"settingsScope",
|
|
843
|
+
"remote",
|
|
844
|
+
"remote.credentials"
|
|
845
|
+
];
|
|
846
|
+
/** Register the localized card under Settings -> Plugins -> Plugin configuration. */
|
|
847
|
+
function apply(ctx) {
|
|
848
|
+
const t = ctx.locale.bind(LOCALE_NAMESPACE);
|
|
849
|
+
ctx.effect(() => ctx.locale.register(LOCALE_NAMESPACE, {
|
|
850
|
+
en,
|
|
851
|
+
zh
|
|
852
|
+
}), "web-search-enhanced: settings dictionaries");
|
|
853
|
+
const scope = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
|
|
854
|
+
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
855
|
+
name: "settings.plugin.item",
|
|
856
|
+
key: SETTINGS_NAMESPACE,
|
|
857
|
+
locale: LOCALE_NAMESPACE,
|
|
858
|
+
inject: () => ({
|
|
859
|
+
scope,
|
|
860
|
+
credentials: ctx.remote.credentials,
|
|
861
|
+
t
|
|
862
|
+
})
|
|
863
|
+
}, SearchSettingsCard));
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
866
|
+
exports.apply = apply;
|
|
867
|
+
exports.inject = inject;
|
|
868
|
+
return module.exports;
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
//# sourceMappingURL=client.js.map
|