dsh-web-search-plugin 0.5.0 → 0.5.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/lib/client.js CHANGED
@@ -29,6 +29,34 @@ window.__ModuleLoader__.load({
29
29
 
30
30
  /** Settings namespace of this plugin. */
31
31
  const NS = "dsh-web-search-plugin";
32
+ // Mirrors lib/config.js; this client bundle has no host-module imports.
33
+ const SUPPLIER_CONFIG_ALIASES = {
34
+ tavilyApiKey: "apiKey",
35
+ tavilyApiKeyEnv: "apiKeyEnv",
36
+ tavilyBaseURL: "baseURL",
37
+ tavilyMode: "mode",
38
+ tavilySearchDepth: "searchDepth",
39
+ tavilyIncludeAnswer: "includeAnswer",
40
+ tavilyTopic: "topic",
41
+ deepseekModel: "model",
42
+ deepseekApiVersion: "apiVersion",
43
+ deepseekMaxTokens: "maxTokens",
44
+ deepseekMaxUses: "maxUses",
45
+ braveCountry: "country",
46
+ braveSearchLang: "searchLang",
47
+ braveFreshness: "freshness",
48
+ braveProxy: "proxy",
49
+ scavioCountry: "country",
50
+ scavioSearchLang: "searchLang"
51
+ };
52
+ const SUPPLIER_DEFAULTS = {
53
+ deepseekModel: "deepseek-flash", deepseekApiVersion: "2023-06-01", deepseekMaxTokens: 4096, deepseekMaxUses: 5,
54
+ tavilyMode: "keyless", tavilyApiKey: "", tavilyApiKeyEnv: "TAVILY_API_KEY", tavilyBaseURL: "",
55
+ tavilySearchDepth: "basic", tavilyIncludeAnswer: true, tavilyTopic: "general",
56
+ braveCountry: "", braveSearchLang: "", braveFreshness: "", braveProxy: "",
57
+ scavioCountry: "", scavioSearchLang: ""
58
+ };
59
+ const supplierValue = (values, field) => values?.[field] ?? values?.[SUPPLIER_CONFIG_ALIASES[field]] ?? SUPPLIER_DEFAULTS[field];
32
60
  /** Built-in REST providers (mirrors `lib/providers.js`; browser bundle is self-contained). */
33
61
  const BUILTIN_REST_PROVIDERS = [
34
62
  { id: "serper", name: "Serper", officialUrl: "https://serper.dev/", defaultBaseURL: "https://google.serper.dev", keyRequired: true, keyField: "serperApiKey", keyEnvField: "serperApiKeyEnv", baseURLField: "serperBaseURL" },
@@ -91,7 +119,7 @@ window.__ModuleLoader__.load({
91
119
  /** Credential reference DeepSeek resolves when the section names none. */
92
120
  const DEFAULT_DEEPSEEK_KEY_REF = "DEEPSEEK_API_KEY";
93
121
  /** Form field the Tavily write-only credential control stages under. */
94
- const TAVILY_API_KEY_FIELD = "apiKey";
122
+ const TAVILY_API_KEY_FIELD = "tavilyApiKey";
95
123
  /** Form field the Brave write-only credential control stages under. */
96
124
  const BRAVE_API_KEY_FIELD = "braveApiKey";
97
125
  /** Form field the DeepSeek write-only credential control stages under. */
@@ -163,6 +191,8 @@ window.__ModuleLoader__.load({
163
191
  topicNews: "News",
164
192
  country: "Country",
165
193
  countryHint: "ISO 2-letter code (e.g. cn).",
194
+ scavioCountryHint: "Country/region code accepted by Scavio (e.g. cn).",
195
+ scavioSearchLangHint: "Language code accepted by Scavio (e.g. zh-CN).",
166
196
  searchLang: "Search language",
167
197
  searchLangHint: "e.g. zh-hans or en.",
168
198
  freshness: "Freshness",
@@ -179,8 +209,6 @@ window.__ModuleLoader__.load({
179
209
  deepseekBaseURLHint: "Leave blank to use the DeepSeek Anthropic-compatible API default.",
180
210
  model: "Model",
181
211
  modelHint: "Anthropic-format model name for the search request.",
182
- apiVersion: "API version",
183
- apiVersionHint: "anthropic-version header value.",
184
212
  maxTokens: "Max tokens",
185
213
  maxTokensHint: "Upper bound on generated tokens for the search request.",
186
214
  maxUses: "Max uses",
@@ -260,6 +288,8 @@ window.__ModuleLoader__.load({
260
288
  topicNews: "新闻",
261
289
  country: "国家/地区",
262
290
  countryHint: "ISO 两位码(如 cn)。",
291
+ scavioCountryHint: "Scavio 支持的国家/地区码(如 cn)。",
292
+ scavioSearchLangHint: "Scavio 支持的语言码(如 zh-CN)。",
263
293
  searchLang: "搜索语言",
264
294
  searchLangHint: "如 zh-hans、en。",
265
295
  freshness: "时效",
@@ -276,8 +306,6 @@ window.__ModuleLoader__.load({
276
306
  deepseekBaseURLHint: "留空则使用 DeepSeek Anthropic 兼容 API 默认地址。",
277
307
  model: "模型",
278
308
  modelHint: "搜索请求使用的 Anthropic 格式模型名。",
279
- apiVersion: "API 版本",
280
- apiVersionHint: "anthropic-version 请求头值。",
281
309
  maxTokens: "最大 token",
282
310
  maxTokensHint: "搜索请求生成 token 的上限。",
283
311
  maxUses: "最大调用次数",
@@ -392,25 +420,24 @@ window.__ModuleLoader__.load({
392
420
  this.remote = remote;
393
421
  this.specs = new Map([
394
422
  choiceField("provider"),
395
- choiceField("mode"),
423
+ choiceField("tavilyMode"),
396
424
  numberField("maxResults", { min: 1, max: MAX_RESULTS_CAP }),
397
- credentialField("apiKeyEnv"),
398
- textField("baseURL"),
399
- choiceField("searchDepth"),
400
- choiceField("topic"),
401
- booleanField("includeAnswer"),
425
+ credentialField("tavilyApiKeyEnv"),
426
+ textField("tavilyBaseURL"),
427
+ choiceField("tavilySearchDepth"),
428
+ choiceField("tavilyTopic"),
429
+ booleanField("tavilyIncludeAnswer"),
402
430
  credentialField("braveApiKeyEnv"),
403
431
  textField("braveBaseURL"),
404
- textField("country"),
405
- textField("searchLang"),
406
- choiceField("freshness"),
407
- textField("proxy"),
432
+ textField("braveCountry"),
433
+ textField("braveSearchLang"),
434
+ choiceField("braveFreshness"),
435
+ textField("braveProxy"),
408
436
  credentialField("deepseekApiKeyEnv"),
409
437
  textField("deepseekBaseURL"),
410
- textField("model"),
411
- textField("apiVersion"),
412
- numberField("maxTokens", { min: 1 }),
413
- numberField("maxUses", { min: 1 }),
438
+ textField("deepseekModel"),
439
+ numberField("deepseekMaxTokens", { min: 1 }),
440
+ numberField("deepseekMaxUses", { min: 1 }),
414
441
  credentialField("serperApiKeyEnv"),
415
442
  textField("serperBaseURL"),
416
443
  credentialField("serpapiApiKeyEnv"),
@@ -420,6 +447,8 @@ window.__ModuleLoader__.load({
420
447
  textField("searxngBaseURL"),
421
448
  credentialField("scavioApiKeyEnv"),
422
449
  textField("scavioBaseURL"),
450
+ textField("scavioCountry"),
451
+ textField("scavioSearchLang"),
423
452
  credentialField("firecrawlApiKeyEnv"),
424
453
  textField("firecrawlBaseURL")
425
454
  ].map((spec) => [spec.field, spec]));
@@ -432,7 +461,9 @@ window.__ModuleLoader__.load({
432
461
  this.listeners = new Set();
433
462
  const draft = readDraft();
434
463
  if (draft?.staged) {
435
- for (const [field, edit] of Object.entries(draft.staged)) {
464
+ for (const [oldField, edit] of Object.entries(draft.staged)) {
465
+ const field = Object.entries(SUPPLIER_CONFIG_ALIASES).find(([name, legacy]) => !name.startsWith("scavio") && legacy === oldField)?.[0] ?? oldField;
466
+ if (field !== oldField && Object.hasOwn(draft.staged, field)) continue;
436
467
  if (!this.specs.has(field) || edit === null || typeof edit !== "object") continue;
437
468
  this.staged.set(field, { text: String(edit.text ?? ""), clear: edit.clear === true });
438
469
  }
@@ -528,6 +559,15 @@ window.__ModuleLoader__.load({
528
559
  const revision = this.snapshotOf().revision;
529
560
  const credentials = plan.filter((item) => item.credential !== void 0);
530
561
  const ops = plan.flatMap((item) => item.op === void 0 ? [] : [item.op]);
562
+ for (const item of plan) {
563
+ const legacy = SUPPLIER_CONFIG_ALIASES[item.field];
564
+ if (item.op?.op !== "unset" || legacy === void 0 || !Object.hasOwn(this.userLayer() ?? {}, legacy)) continue;
565
+ for (const [other, alias] of Object.entries(SUPPLIER_CONFIG_ALIASES)) {
566
+ if (other === item.field || alias !== legacy || plan.some((entry) => entry.field === other) || this.snapshotOf().value?.[other] != null) continue;
567
+ ops.push({ op: "set", path: [other], value: this.sectionValue(other) });
568
+ }
569
+ if (!ops.some((op) => op.op === "unset" && op.path[0] === legacy)) ops.push({ op: "unset", path: [legacy] });
570
+ }
531
571
  for (const item of credentials) {
532
572
  // Override even an inherited literal key; unsetting could expose it again.
533
573
  if (!ops.some((op) => op.path[0] === item.field)) ops.push({ op: "set", path: [item.field], value: "" });
@@ -576,23 +616,23 @@ window.__ModuleLoader__.load({
576
616
  this.staged.set(field, edit);
577
617
  this.failed = false;
578
618
  this.publish();
579
- if (field === "provider" || field === "apiKeyEnv" || field === "braveApiKeyEnv" || field === "deepseekApiKeyEnv" || BUILTIN_REST_PROVIDERS.some((entry) => entry.keyEnvField === field)) this.readCredential();
619
+ if (field === "provider" || field === "tavilyApiKeyEnv" || field === "braveApiKeyEnv" || field === "deepseekApiKeyEnv" || BUILTIN_REST_PROVIDERS.some((entry) => entry.keyEnvField === field)) this.readCredential();
580
620
  }
581
621
  snapshotOf() {
582
622
  return this.scope.getSnapshot();
583
623
  }
584
624
  sectionValue(field) {
585
- return this.snapshotOf().value?.[field];
625
+ return supplierValue(this.snapshotOf().value, field);
586
626
  }
587
627
  baseText(field) {
588
- return this.specs.get(field).format(this.snapshotOf().base?.[field]);
628
+ return this.specs.get(field).format(supplierValue(this.snapshotOf().base, field));
589
629
  }
590
630
  userLayer() {
591
631
  return this.snapshotOf().user;
592
632
  }
593
633
  stored(field) {
594
634
  const user = this.userLayer();
595
- return user !== void 0 && Object.hasOwn(user, field);
635
+ return user !== void 0 && (Object.hasOwn(user, field) || Object.hasOwn(user, SUPPLIER_CONFIG_ALIASES[field]));
596
636
  }
597
637
  publish() {
598
638
  writeDraft(this);
@@ -610,11 +650,11 @@ window.__ModuleLoader__.load({
610
650
  const staged = this.staged.get(field);
611
651
  const declared = staged === void 0
612
652
  ? this.sectionValue(field)
613
- : staged.clear ? this.snapshotOf().base?.[field] : staged.text.trim();
653
+ : staged.clear ? supplierValue(this.snapshotOf().base, field) : staged.text.trim();
614
654
  return typeof declared === "string" && declared.length > 0 ? declared : fallback;
615
655
  }
616
656
  tavilyRef() {
617
- return this.credentialRef("apiKeyEnv", DEFAULT_TAVILY_KEY_REF);
657
+ return this.credentialRef("tavilyApiKeyEnv", DEFAULT_TAVILY_KEY_REF);
618
658
  }
619
659
  braveRef() {
620
660
  return this.credentialRef("braveApiKeyEnv", DEFAULT_BRAVE_KEY_REF);
@@ -697,28 +737,27 @@ window.__ModuleLoader__.load({
697
737
  return {
698
738
  ...this.form.shell(),
699
739
  provider: this.form.field("provider"),
700
- mode: this.form.field("mode"),
701
- apiKey: this.form.field(TAVILY_API_KEY_FIELD),
702
- apiKeyEnv: this.form.field("apiKeyEnv"),
703
- baseURL: this.form.field("baseURL"),
740
+ tavilyMode: this.form.field("tavilyMode"),
741
+ tavilyApiKey: this.form.field(TAVILY_API_KEY_FIELD),
742
+ tavilyApiKeyEnv: this.form.field("tavilyApiKeyEnv"),
743
+ tavilyBaseURL: this.form.field("tavilyBaseURL"),
704
744
  maxResults: this.form.field("maxResults"),
705
- searchDepth: this.form.field("searchDepth"),
706
- includeAnswer: this.form.field("includeAnswer"),
707
- topic: this.form.field("topic"),
745
+ tavilySearchDepth: this.form.field("tavilySearchDepth"),
746
+ tavilyIncludeAnswer: this.form.field("tavilyIncludeAnswer"),
747
+ tavilyTopic: this.form.field("tavilyTopic"),
708
748
  braveApiKey: this.form.field(BRAVE_API_KEY_FIELD),
709
749
  braveApiKeyEnv: this.form.field("braveApiKeyEnv"),
710
750
  braveBaseURL: this.form.field("braveBaseURL"),
711
- country: this.form.field("country"),
712
- searchLang: this.form.field("searchLang"),
713
- freshness: this.form.field("freshness"),
714
- proxy: this.form.field("proxy"),
751
+ braveCountry: this.form.field("braveCountry"),
752
+ braveSearchLang: this.form.field("braveSearchLang"),
753
+ braveFreshness: this.form.field("braveFreshness"),
754
+ braveProxy: this.form.field("braveProxy"),
715
755
  deepseekApiKey: this.form.field(DEEPSEEK_API_KEY_FIELD),
716
756
  deepseekApiKeyEnv: this.form.field("deepseekApiKeyEnv"),
717
757
  deepseekBaseURL: this.form.field("deepseekBaseURL"),
718
- model: this.form.field("model"),
719
- apiVersion: this.form.field("apiVersion"),
720
- maxTokens: this.form.field("maxTokens"),
721
- maxUses: this.form.field("maxUses"),
758
+ deepseekModel: this.form.field("deepseekModel"),
759
+ deepseekMaxTokens: this.form.field("deepseekMaxTokens"),
760
+ deepseekMaxUses: this.form.field("deepseekMaxUses"),
722
761
  serperApiKey: this.form.field("serperApiKey"),
723
762
  serperApiKeyEnv: this.form.field("serperApiKeyEnv"),
724
763
  serperBaseURL: this.form.field("serperBaseURL"),
@@ -732,6 +771,8 @@ window.__ModuleLoader__.load({
732
771
  scavioApiKey: this.form.field("scavioApiKey"),
733
772
  scavioApiKeyEnv: this.form.field("scavioApiKeyEnv"),
734
773
  scavioBaseURL: this.form.field("scavioBaseURL"),
774
+ scavioCountry: this.form.field("scavioCountry"),
775
+ scavioSearchLang: this.form.field("scavioSearchLang"),
735
776
  firecrawlApiKey: this.form.field("firecrawlApiKey"),
736
777
  firecrawlApiKeyEnv: this.form.field("firecrawlApiKeyEnv"),
737
778
  firecrawlBaseURL: this.form.field("firecrawlBaseURL"),
@@ -1032,7 +1073,7 @@ window.__ModuleLoader__.load({
1032
1073
  const deepseek = provider === "deepseek-official";
1033
1074
  const tavily = provider === "tavily";
1034
1075
  const restMeta = builtinRest(provider);
1035
- const keyed = state.mode.text === "keyed";
1076
+ const keyed = state.tavilyMode.text === "keyed";
1036
1077
  const keyHint = state.apiKeyConfigured ? t("apiKeyHint") : t("apiKeyHint") + " " + t("apiKeyUnavailableHint");
1037
1078
  const toastText = toastCopy(t, state.toastKey);
1038
1079
  const toastTone = state.toastKey === "failed" || state.toastKey === "invalid" ? "error" : state.toastKey === "nothing" ? "info" : "success";
@@ -1072,7 +1113,7 @@ window.__ModuleLoader__.load({
1072
1113
  react.createElement("option", { value: "__ddg__", key: "ddg", disabled: true }, t("ddgDisabled"))
1073
1114
  ] }),
1074
1115
  react.createElement("p", { className: "dshws_field_hint", style: { padding: "4px 0 0" } }, t("ddgHint"))),
1075
- tavily ? row("mode", t("mode"), null, selectInput({ id: "ws-mode", value: state.mode.text, disabled, onChange: (e) => actions.edit("mode", e.target.value), children: [
1116
+ tavily ? row("tavilyMode", t("mode"), null, selectInput({ id: "ws-mode", value: state.tavilyMode.text, disabled, onChange: (e) => actions.edit("tavilyMode", e.target.value), children: [
1076
1117
  react.createElement("option", { value: "keyless", key: "keyless" }, t("modeKeyless")),
1077
1118
  react.createElement("option", { value: "keyed", key: "keyed" }, t("modeKeyed"))
1078
1119
  ] })) : null
@@ -1088,40 +1129,37 @@ window.__ModuleLoader__.load({
1088
1129
  row("braveApiKeyEnv", t("braveApiKeyEnv"), t("braveApiKeyEnvHint"), textInput({ id: "ws-brave-keyref", value: state.braveApiKeyEnv.text, disabled, onChange: (e) => actions.edit("braveApiKeyEnv", e.target.value) }))
1089
1130
  ) : null,
1090
1131
  (tavily && keyed) ? pair(
1091
- fieldRow(t("apiKey"), keyHint, secretInput({ id: "ws-tavily-key", value: state.apiKey.text, disabled: disabled || !state.apiKeyWritable, placeholder: state.apiKeyConfigured ? t("apiKeySet") : t("apiKeyUnset"), onChange: (e) => actions.edit(TAVILY_API_KEY_FIELD, e.target.value) })),
1092
- row("apiKeyEnv", t("apiKeyEnv"), t("apiKeyEnvHint"), textInput({ id: "ws-tavily-keyref", value: state.apiKeyEnv.text, disabled, onChange: (e) => actions.edit("apiKeyEnv", e.target.value) }))
1132
+ fieldRow(t("apiKey"), keyHint, secretInput({ id: "ws-tavily-key", value: state.tavilyApiKey.text, disabled: disabled || !state.apiKeyWritable, placeholder: state.apiKeyConfigured ? t("apiKeySet") : t("apiKeyUnset"), onChange: (e) => actions.edit(TAVILY_API_KEY_FIELD, e.target.value) })),
1133
+ row("tavilyApiKeyEnv", t("apiKeyEnv"), t("apiKeyEnvHint"), textInput({ id: "ws-tavily-keyref", value: state.tavilyApiKeyEnv.text, disabled, onChange: (e) => actions.edit("tavilyApiKeyEnv", e.target.value) }))
1093
1134
  ) : null,
1094
1135
  deepseek ? row("deepseekBaseURL", t("deepseekBaseURL"), t("deepseekBaseURLHint"), textInput({ id: "ws-deepseek-base", value: state.deepseekBaseURL.text, disabled, onChange: (e) => actions.edit("deepseekBaseURL", e.target.value) })) : null,
1095
1136
  brave ? row("braveBaseURL", t("braveBaseURL"), t("braveBaseURLHint"), textInput({ id: "ws-brave-base", value: state.braveBaseURL.text, disabled, onChange: (e) => actions.edit("braveBaseURL", e.target.value) })) : null,
1096
- tavily ? row("baseURL", t("baseURL"), t("baseURLHint"), textInput({ id: "ws-tavily-base", value: state.baseURL.text, disabled, onChange: (e) => actions.edit("baseURL", e.target.value) })) : null,
1137
+ tavily ? row("tavilyBaseURL", t("baseURL"), t("baseURLHint"), textInput({ id: "ws-tavily-base", value: state.tavilyBaseURL.text, disabled, onChange: (e) => actions.edit("tavilyBaseURL", e.target.value) })) : null,
1138
+ deepseek ? row("deepseekModel", t("model"), t("modelHint"), textInput({ id: "ws-model", value: state.deepseekModel.text, disabled, onChange: (e) => actions.edit("deepseekModel", e.target.value) })) : null,
1097
1139
  deepseek ? pair(
1098
- row("model", t("model"), t("modelHint"), textInput({ id: "ws-model", value: state.model.text, disabled, onChange: (e) => actions.edit("model", e.target.value) })),
1099
- row("apiVersion", t("apiVersion"), t("apiVersionHint"), textInput({ id: "ws-apiversion", value: state.apiVersion.text, disabled, onChange: (e) => actions.edit("apiVersion", e.target.value) }))
1100
- ) : null,
1101
- deepseek ? pair(
1102
- row("maxTokens", t("maxTokens"), t("maxTokensHint"), numberInput({ id: "ws-maxtokens", value: state.maxTokens.text, disabled, onChange: (e) => actions.edit("maxTokens", e.target.value), className: state.maxTokens.invalid ? "dshws_input_invalid" : void 0 })),
1103
- row("maxUses", t("maxUses"), t("maxUsesHint"), numberInput({ id: "ws-maxuses", value: state.maxUses.text, disabled, onChange: (e) => actions.edit("maxUses", e.target.value), className: state.maxUses.invalid ? "dshws_input_invalid" : void 0 }))
1140
+ row("deepseekMaxTokens", t("maxTokens"), t("maxTokensHint"), numberInput({ id: "ws-maxtokens", value: state.deepseekMaxTokens.text, disabled, onChange: (e) => actions.edit("deepseekMaxTokens", e.target.value), className: state.deepseekMaxTokens.invalid ? "dshws_input_invalid" : void 0 })),
1141
+ row("deepseekMaxUses", t("maxUses"), t("maxUsesHint"), numberInput({ id: "ws-maxuses", value: state.deepseekMaxUses.text, disabled, onChange: (e) => actions.edit("deepseekMaxUses", e.target.value), className: state.deepseekMaxUses.invalid ? "dshws_input_invalid" : void 0 }))
1104
1142
  ) : null,
1105
1143
  tavily ? pair(
1106
- row("searchDepth", t("searchDepth"), null, selectInput({ id: "ws-depth", value: state.searchDepth.text, disabled, onChange: (e) => actions.edit("searchDepth", e.target.value), children: [
1144
+ row("tavilySearchDepth", t("searchDepth"), null, selectInput({ id: "ws-depth", value: state.tavilySearchDepth.text, disabled, onChange: (e) => actions.edit("tavilySearchDepth", e.target.value), children: [
1107
1145
  react.createElement("option", { value: "basic", key: "basic" }, t("searchDepthBasic")),
1108
1146
  react.createElement("option", { value: "advanced", key: "advanced" }, t("searchDepthAdvanced"))
1109
1147
  ] })),
1110
- row("topic", t("topic"), null, selectInput({ id: "ws-topic", value: state.topic.text, disabled, onChange: (e) => actions.edit("topic", e.target.value), children: [
1148
+ row("tavilyTopic", t("topic"), null, selectInput({ id: "ws-topic", value: state.tavilyTopic.text, disabled, onChange: (e) => actions.edit("tavilyTopic", e.target.value), children: [
1111
1149
  react.createElement("option", { value: "general", key: "general" }, t("topicGeneral")),
1112
1150
  react.createElement("option", { value: "news", key: "news" }, t("topicNews"))
1113
1151
  ] }))
1114
1152
  ) : null,
1115
1153
  tavily ? pair(
1116
- row("includeAnswer", t("includeAnswer"), t("includeAnswerHint"), checkboxInput({ id: "ws-answer", checked: state.includeAnswer.text === "true", disabled, onChange: (e) => actions.edit("includeAnswer", e.target.checked ? "true" : "") })),
1154
+ row("tavilyIncludeAnswer", t("includeAnswer"), t("includeAnswerHint"), checkboxInput({ id: "ws-answer", checked: state.tavilyIncludeAnswer.text === "true", disabled, onChange: (e) => actions.edit("tavilyIncludeAnswer", e.target.checked ? "true" : "") })),
1117
1155
  maxResultsRow
1118
1156
  ) : null,
1119
1157
  brave ? pair(
1120
- row("country", t("country"), t("countryHint"), textInput({ id: "ws-country", value: state.country.text, disabled, placeholder: t("braveDefaultPlaceholder"), onChange: (e) => actions.edit("country", e.target.value) })),
1121
- row("searchLang", t("searchLang"), t("searchLangHint"), textInput({ id: "ws-lang", value: state.searchLang.text, disabled, placeholder: t("braveDefaultPlaceholder"), onChange: (e) => actions.edit("searchLang", e.target.value) }))
1158
+ row("braveCountry", t("country"), t("countryHint"), textInput({ id: "ws-country", value: state.braveCountry.text, disabled, placeholder: t("braveDefaultPlaceholder"), onChange: (e) => actions.edit("braveCountry", e.target.value) })),
1159
+ row("braveSearchLang", t("searchLang"), t("searchLangHint"), textInput({ id: "ws-lang", value: state.braveSearchLang.text, disabled, placeholder: t("braveDefaultPlaceholder"), onChange: (e) => actions.edit("braveSearchLang", e.target.value) }))
1122
1160
  ) : null,
1123
1161
  brave ? pair(
1124
- row("freshness", t("freshness"), null, selectInput({ id: "ws-freshness", value: state.freshness.text, disabled, onChange: (e) => actions.edit("freshness", e.target.value), children: [
1162
+ row("braveFreshness", t("freshness"), null, selectInput({ id: "ws-freshness", value: state.braveFreshness.text, disabled, onChange: (e) => actions.edit("braveFreshness", e.target.value), children: [
1125
1163
  react.createElement("option", { value: "", key: "any" }, t("freshnessAny")),
1126
1164
  react.createElement("option", { value: "pd", key: "pd" }, t("freshnessDay")),
1127
1165
  react.createElement("option", { value: "pw", key: "pw" }, t("freshnessWeek")),
@@ -1130,13 +1168,17 @@ window.__ModuleLoader__.load({
1130
1168
  ] })),
1131
1169
  maxResultsRow
1132
1170
  ) : null,
1133
- brave ? row("proxy", t("proxy"), null, textInput({ id: "ws-proxy", value: state.proxy.text, disabled, placeholder: t("proxyPlaceholder"), onChange: (e) => actions.edit("proxy", e.target.value) })) : null,
1171
+ brave ? row("braveProxy", t("proxy"), null, textInput({ id: "ws-proxy", value: state.braveProxy.text, disabled, placeholder: t("proxyPlaceholder"), onChange: (e) => actions.edit("braveProxy", e.target.value) })) : null,
1134
1172
  deepseek ? maxResultsRow : null,
1135
1173
  restMeta ? react.createElement("div", { className: "dshws_form" },
1136
1174
  restMeta.keyRequired ? pair(
1137
1175
  fieldRow(t("apiKey"), keyHint, secretInput({ id: "ws-" + restMeta.id + "-key", value: state[restMeta.keyField]?.text ?? "", disabled: disabled || !state.apiKeyWritable, placeholder: state.apiKeyConfigured ? t("apiKeySet") : t("apiKeyUnset"), onChange: (e) => actions.edit(restMeta.keyField, e.target.value) })),
1138
1176
  row(restMeta.keyEnvField, t("apiKeyEnv"), t("apiKeyEnvHint"), textInput({ id: "ws-" + restMeta.id + "-keyref", value: state[restMeta.keyEnvField]?.text ?? "", disabled, onChange: (e) => actions.edit(restMeta.keyEnvField, e.target.value) }))
1139
1177
  ) : null,
1178
+ provider === "scavio" ? pair(
1179
+ row("scavioCountry", t("country"), t("scavioCountryHint"), textInput({ id: "ws-scavio-country", value: state.scavioCountry.text, disabled, onChange: (e) => actions.edit("scavioCountry", e.target.value) })),
1180
+ row("scavioSearchLang", t("searchLang"), t("scavioSearchLangHint"), textInput({ id: "ws-scavio-lang", value: state.scavioSearchLang.text, disabled, onChange: (e) => actions.edit("scavioSearchLang", e.target.value) }))
1181
+ ) : null,
1140
1182
  row(restMeta.baseURLField, t("baseURL"), t("baseURLHint"), textInput({ id: "ws-" + restMeta.id + "-base", value: state[restMeta.baseURLField]?.text || restMeta.defaultBaseURL || "", disabled, onChange: (e) => actions.edit(restMeta.baseURLField, e.target.value) })),
1141
1183
  maxResultsRow
1142
1184
  ) : null,
package/lib/config.js ADDED
@@ -0,0 +1,29 @@
1
+ /** Supplier-specific configuration names and their pre-prefix aliases. */
2
+ export const SUPPLIER_CONFIG_ALIASES = {
3
+ tavilyApiKey: "apiKey",
4
+ tavilyApiKeyEnv: "apiKeyEnv",
5
+ tavilyBaseURL: "baseURL",
6
+ tavilyMode: "mode",
7
+ tavilySearchDepth: "searchDepth",
8
+ tavilyIncludeAnswer: "includeAnswer",
9
+ tavilyTopic: "topic",
10
+ deepseekModel: "model",
11
+ deepseekApiVersion: "apiVersion",
12
+ deepseekMaxTokens: "maxTokens",
13
+ deepseekMaxUses: "maxUses",
14
+ braveCountry: "country",
15
+ braveSearchLang: "searchLang",
16
+ braveFreshness: "freshness",
17
+ braveProxy: "proxy",
18
+ scavioCountry: "country",
19
+ scavioSearchLang: "searchLang"
20
+ };
21
+
22
+ /** Explicit new values, including false and empty strings, override old names. */
23
+ export function resolveSupplierConfig(config) {
24
+ const resolved = { ...config };
25
+ for (const [field, legacy] of Object.entries(SUPPLIER_CONFIG_ALIASES)) {
26
+ resolved[field] = config[field] ?? config[legacy];
27
+ }
28
+ return resolved;
29
+ }
package/lib/deepseek.js CHANGED
@@ -19,6 +19,7 @@
19
19
  *
20
20
  * @module dsh-web-search-plugin/deepseek
21
21
  */
22
+ import { resolveSupplierConfig } from "./config.js";
22
23
  import { WebError } from "@deepseek-ai/dsh-web";
23
24
  import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
24
25
  import { MAX_RESULTS_CAP, USER_AGENT, abortable, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
@@ -35,7 +36,7 @@ const DEEPSEEK_SEARCH_BASE_URL_ENV = "DEEPSEEK_SEARCH_BASE_URL";
35
36
  * account quota on auxiliary search.
36
37
  */
37
38
  const ACCOUNT_PROVIDER = "deepseek-account";
38
- const DEFAULT_MODEL = "deepseek-v4-flash";
39
+ const DEFAULT_MODEL = "deepseek-flash";
39
40
  const DEFAULT_API_VERSION = "2023-06-01";
40
41
  const DEFAULT_MAX_TOKENS = 4096;
41
42
  const DEFAULT_MAX_USES = 5;
@@ -180,6 +181,7 @@ export class DeepSeekSearchProvider {
180
181
  * @returns options for one search.
181
182
  */
182
183
  export function resolveDeepseekOptions(ctx, config) {
184
+ config = resolveSupplierConfig(config);
183
185
  return {
184
186
  ...resolveSecret(ctx, {
185
187
  literal: config.deepseekApiKey,
@@ -195,10 +197,10 @@ export function resolveDeepseekOptions(ctx, config) {
195
197
  ctx.get("agents")?.currentInitiator()?.session.append("web/deepseek-search-llm-request", request);
196
198
  },
197
199
  baseURL: config.deepseekBaseURL || launchEnvironmentOf(ctx).get(DEEPSEEK_SEARCH_BASE_URL_ENV)?.value || DEEPSEEK_DEFAULT_BASE_URL,
198
- model: config.model ?? DEFAULT_MODEL,
199
- apiVersion: config.apiVersion ?? DEFAULT_API_VERSION,
200
- maxTokens: config.maxTokens ?? DEFAULT_MAX_TOKENS,
201
- maxUses: config.maxUses ?? DEFAULT_MAX_USES,
200
+ model: config.deepseekModel ?? DEFAULT_MODEL,
201
+ apiVersion: config.deepseekApiVersion ?? DEFAULT_API_VERSION,
202
+ maxTokens: config.deepseekMaxTokens ?? DEFAULT_MAX_TOKENS,
203
+ maxUses: config.deepseekMaxUses ?? DEFAULT_MAX_USES,
202
204
  maxResults: config.maxResults ?? 8
203
205
  };
204
206
  }
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@
21
21
  * @module dsh-web-search-plugin
22
22
  */
23
23
  import z from "@deepseek-ai/schemastery";
24
+ import { SUPPLIER_CONFIG_ALIASES, resolveSupplierConfig } from "./config.js";
24
25
  import { MAX_RESULTS_CAP } from "./shared.js";
25
26
  import { TAVILY_DEFAULT_API_KEY_ENV, TAVILY_DEFAULT_BASE_URL, TavilySearchProvider, resolveTavilyOptions } from "./tavily.js";
26
27
  import { BRAVE_DEFAULT_API_KEY_ENV, BRAVE_DEFAULT_BASE_URL, BraveSearchProvider, resolveBraveOptions } from "./brave.js";
@@ -48,6 +49,25 @@ const WEB_SEARCH_SETTINGS_NAMESPACE = "dsh-web-search-plugin";
48
49
  * which makes these accessors the only way to read live configuration.
49
50
  */
50
51
  const Config = z.object({
52
+ // No defaults here: absent prefixed fields must still inherit legacy values.
53
+ deepseekModel: z.string().volatile(),
54
+ deepseekApiVersion: z.string().volatile(),
55
+ deepseekMaxTokens: z.number().step(1).min(1).volatile(),
56
+ deepseekMaxUses: z.number().step(1).min(1).volatile(),
57
+ tavilyApiKey: z.string().role("secret").volatile(),
58
+ tavilyApiKeyEnv: z.string().role("credential-ref").volatile(),
59
+ tavilyBaseURL: z.string().volatile(),
60
+ tavilyMode: z.string().volatile(),
61
+ tavilySearchDepth: z.string().volatile(),
62
+ tavilyIncludeAnswer: z.boolean().volatile(),
63
+ tavilyTopic: z.string().volatile(),
64
+ braveCountry: z.string().volatile(),
65
+ braveSearchLang: z.string().volatile(),
66
+ braveFreshness: z.string().volatile(),
67
+ braveProxy: z.string().volatile(),
68
+ scavioCountry: z.string().volatile(),
69
+ scavioSearchLang: z.string().volatile(),
70
+ // Legacy fields remain accepted for existing profiles.
51
71
  /** Active backend: `deepseek-official` (default), `tavily`, `brave`, `serper`, `serpapi`, `exa`, `searxng`, `scavio`, or `firecrawl`. */
52
72
  provider: z.string().default("deepseek-official").volatile(),
53
73
  /** Tavily auth mode: `keyless` (default) or `keyed`. */
@@ -119,7 +139,7 @@ const Config = z.object({
119
139
  /** DeepSeek Anthropic-compatible Messages base URL. `/messages` is appended. */
120
140
  deepseekBaseURL: z.string().default("").volatile(),
121
141
  /** Anthropic-format model name for the Messages request. */
122
- model: z.string().default("deepseek-v4-flash").volatile(),
142
+ model: z.string().default("deepseek-flash").volatile(),
123
143
  /** `anthropic-version` header value. */
124
144
  apiVersion: z.string().default("2023-06-01").volatile(),
125
145
  /** Upper bound on generated tokens for the Messages request. */
@@ -169,6 +189,7 @@ class PluginSearchProvider {
169
189
 
170
190
  /** Project one resolved section into options for each backend. */
171
191
  function resolveOptions(ctx, config) {
192
+ config = resolveSupplierConfig(config);
172
193
  const isBuiltIn = config.provider === "tavily" || config.provider === "brave" || config.provider === "deepseek-official" || BUILTIN_REST_IDS.includes(config.provider);
173
194
  const provider = isBuiltIn ? config.provider : "deepseek-official";
174
195
  const tavily = provider === "tavily" ? resolveTavilyOptions(ctx, config) : void 0;
@@ -176,8 +197,8 @@ function resolveOptions(ctx, config) {
176
197
  // metadata row's default is not enough (self-hosted SearXNG, proxied
177
198
  // providers, custom key refs).
178
199
  const keySourceByProvider = {
179
- brave: { literal: config.braveApiKey, envName: config.braveApiKeyEnv ?? BRAVE_DEFAULT_API_KEY_ENV, baseURL: config.braveBaseURL ?? "", proxy: config.proxy ?? "" },
180
- tavily: { literal: config.apiKey, envName: config.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV, baseURL: tavily?.baseURL ?? "" },
200
+ brave: { literal: config.braveApiKey, envName: config.braveApiKeyEnv ?? BRAVE_DEFAULT_API_KEY_ENV, baseURL: config.braveBaseURL ?? "", proxy: config.braveProxy ?? "" },
201
+ tavily: { literal: config.tavilyApiKey, envName: config.tavilyApiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV, baseURL: tavily?.baseURL ?? "" },
181
202
  serper: { literal: config.serperApiKey, envName: config.serperApiKeyEnv ?? "SERPER_API_KEY", baseURL: config.serperBaseURL ?? "" },
182
203
  serpapi: { literal: config.serpapiApiKey, envName: config.serpapiApiKeyEnv ?? "SERPAPI_API_KEY", baseURL: config.serpapiBaseURL ?? "" },
183
204
  exa: { literal: config.exaApiKey, envName: config.exaApiKeyEnv ?? "EXA_API_KEY", baseURL: config.exaBaseURL ?? "" },
@@ -186,12 +207,12 @@ function resolveOptions(ctx, config) {
186
207
  firecrawl: { literal: config.firecrawlApiKey, envName: config.firecrawlApiKeyEnv ?? "FIRECRAWL_API_KEY", baseURL: config.firecrawlBaseURL ?? "" }
187
208
  };
188
209
  const settings = {
189
- country: config.country,
190
- searchLang: config.searchLang,
191
- freshness: config.freshness,
192
- searchDepth: config.searchDepth,
193
- topic: config.topic,
194
- includeAnswer: config.includeAnswer
210
+ country: provider === "scavio" ? config.scavioCountry : config.braveCountry,
211
+ searchLang: provider === "scavio" ? config.scavioSearchLang : config.braveSearchLang,
212
+ freshness: config.braveFreshness,
213
+ searchDepth: config.tavilySearchDepth,
214
+ topic: config.tavilyTopic,
215
+ includeAnswer: config.tavilyIncludeAnswer
195
216
  };
196
217
  const rest = {};
197
218
  for (const providerId of provider === "deepseek-official" ? [] : [provider]) {
@@ -201,7 +222,7 @@ function resolveOptions(ctx, config) {
201
222
  const resolved = resolveRestProvider(ctx, row, {
202
223
  config,
203
224
  settings,
204
- keyed: providerId === "tavily" ? config.mode === "keyed" : false,
225
+ keyed: providerId === "tavily" ? config.tavilyMode === "keyed" : false,
205
226
  keySource: source
206
227
  });
207
228
  // Endpoint override: an explicit config baseURL wins over the row default.
@@ -262,6 +283,7 @@ function sendJson(res, statusCode, data) {
262
283
  */
263
284
  function readSection(config) {
264
285
  return {
286
+ ...Object.fromEntries(Object.keys(SUPPLIER_CONFIG_ALIASES).map((field) => [field, config[field].get()])),
265
287
  provider: config.provider.get(),
266
288
  mode: config.mode.get(),
267
289
  apiKey: config.apiKey.get(),
package/lib/shared.js CHANGED
@@ -7,7 +7,7 @@ import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
7
7
  import { WebError } from "@deepseek-ai/dsh-web";
8
8
 
9
9
  /** Attribution header sent on every request. */
10
- export const USER_AGENT = "dsh-web-search-plugin/0.5.0";
10
+ export const USER_AGENT = "dsh-web-search-plugin/0.5.1";
11
11
  /** Shared cap: Tavily `max_results` and Brave `count` both accept 1..20. */
12
12
  export const MAX_RESULTS_CAP = 20;
13
13
 
package/lib/tavily.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Tavily REST search backend (`POST {baseURL}/search`).
3
3
  * @module dsh-web-search-plugin/tavily
4
4
  */
5
+ import { resolveSupplierConfig } from "./config.js";
5
6
  import { WebError } from "@deepseek-ai/dsh-web";
6
7
  import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
7
8
  import { MAX_RESULTS_CAP, USER_AGENT, isAbortError, resolveApiKey, resolveSecret, searchAborted, throwIfSearchAborted } from "./shared.js";
@@ -64,7 +65,7 @@ export class TavilySearchProvider {
64
65
  throwIfSearchAborted(signal);
65
66
  let apiKey;
66
67
  if (options.mode === "keyed") {
67
- apiKey = await resolveApiKey(options, signal, `Tavily search has no API key for "${options.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV}"; store it through the credentials service, export it in the launching environment, or set a literal "apiKey" in the dsh-web-search-plugin config`);
68
+ apiKey = await resolveApiKey(options, signal, `Tavily search has no API key for "${options.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV}"; store it through the credentials service, export it in the launching environment, or set a literal "tavilyApiKey" in the dsh-web-search-plugin config`);
68
69
  throwIfSearchAborted(signal);
69
70
  }
70
71
  const endpoint = `${options.baseURL.replace(/\/+$/u, "")}/search`;
@@ -125,16 +126,17 @@ export class TavilySearchProvider {
125
126
 
126
127
  /** Project the plugin section into Tavily backend options. */
127
128
  export function resolveTavilyOptions(ctx, config) {
129
+ config = resolveSupplierConfig(config);
128
130
  return {
129
- mode: config.mode ?? "keyless",
131
+ mode: config.tavilyMode ?? "keyless",
130
132
  ...resolveSecret(ctx, {
131
- literal: config.apiKey,
132
- envName: config.apiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV
133
+ literal: config.tavilyApiKey,
134
+ envName: config.tavilyApiKeyEnv ?? TAVILY_DEFAULT_API_KEY_ENV
133
135
  }),
134
- baseURL: config.baseURL || launchEnvironmentOf(ctx).get(TAVILY_BASE_URL_ENV)?.value || TAVILY_DEFAULT_BASE_URL,
136
+ baseURL: config.tavilyBaseURL || launchEnvironmentOf(ctx).get(TAVILY_BASE_URL_ENV)?.value || TAVILY_DEFAULT_BASE_URL,
135
137
  maxResults: config.maxResults ?? 8,
136
- searchDepth: config.searchDepth ?? "basic",
137
- includeAnswer: config.includeAnswer ?? true,
138
- topic: config.topic ?? "general"
138
+ searchDepth: config.tavilySearchDepth ?? "basic",
139
+ includeAnswer: config.tavilyIncludeAnswer ?? true,
140
+ topic: config.tavilyTopic ?? "general"
139
141
  };
140
142
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "dsh-web-search-plugin",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Unified web search for the DeepSeek Harness seam (ctx.web): DeepSeek (official), Tavily, Brave, Serper, SerpApi, Exa, SearXNG, Scavio, and Firecrawl backends",
5
+ "icon": "./assets/icon.svg",
5
6
  "keywords": [
6
7
  "dsh-plugin",
7
8
  "deepseek-harness",
@@ -17,11 +18,13 @@
17
18
  "type": "module",
18
19
  "main": "lib/index.js",
19
20
  "files": [
21
+ "assets",
20
22
  "lib",
21
23
  "locale",
22
24
  "cordis.patch.yml",
23
25
  "CHANGELOG.md",
24
26
  "README.md",
27
+ "README.zh.md",
25
28
  "LICENSE"
26
29
  ],
27
30
  "engines": {
@@ -53,7 +56,7 @@
53
56
  }
54
57
  },
55
58
  "scripts": {
56
- "check": "node --check lib/index.js && node --check lib/client.js && node --check lib/shared.js && node --check lib/providers.js && node --check lib/rest.js && node --check lib/tavily.js && node --check lib/brave.js && node --check lib/deepseek.js && node --check lib/usage.js",
59
+ "check": "node --check lib/config.js && node --check lib/index.js && node --check lib/client.js && node --check lib/shared.js && node --check lib/providers.js && node --check lib/rest.js && node --check lib/tavily.js && node --check lib/brave.js && node --check lib/deepseek.js && node --check lib/usage.js",
57
60
  "test": "node --experimental-vm-modules --test test/*.test.mjs"
58
61
  },
59
62
  "dependencies": {