@240xu/dsh-websearch 2.8.9 → 2.9.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
@@ -7,6 +7,11 @@ window.__ModuleLoader__.load({
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
  let react = require("react");
9
9
 
10
+ /** Localized display label for a backend id (falls back to the id). */
11
+ function backendLabel(t, id) {
12
+ return t("backend" + id.charAt(0).toUpperCase() + id.slice(1));
13
+ }
14
+
10
15
  const NS = "websearch.settings";
11
16
  const PLUGIN_NS = "unified-search";
12
17
 
@@ -39,7 +44,7 @@ window.__ModuleLoader__.load({
39
44
  dedupStrategy: ["url", "url+title"],
40
45
  };
41
46
  /** Boolean settings staged as "true"/"false" strings by the selects. */
42
- const BOOLEAN_FIELDS = ["rerank", "safeSearch", "resultTelemetry"];
47
+ const BOOLEAN_FIELDS = ["rerank", "safeSearch", "resultTelemetry", "resultHeader"];
43
48
  // split metered, opt-in backends out of the
44
49
  // "keyless / ready to use" group. They work without a key but are rate
45
50
  // limited and default OFF, so a separate section with an explicit hint
@@ -61,6 +66,19 @@ window.__ModuleLoader__.load({
61
66
  };
62
67
 
63
68
  const zh = {
69
+ backendExa: "Exa (MCP, 免费)",
70
+ backendParallel: "Parallel (MCP, 免费)",
71
+ backendDdg: "DuckDuckGo (HTML)",
72
+ backendSearxng: "SearXNG (元搜索)",
73
+ backendBrave: "Brave Search",
74
+ backendTavily: "Tavily (AI)",
75
+ backendSerper: "Serper.dev",
76
+ backendMojeek: "Mojeek",
77
+ backendDeepseek: "DeepSeek",
78
+ backendAnthropic: "Anthropic",
79
+ backendOpenai: "OpenAI",
80
+ backendFirecrawl: "Firecrawl (免 Key · 有额度 · 默认关)",
81
+ backendTinyfish: "TinyFish (免 Key · 30/分·50/日 · 默认关)",
64
82
  nav: "搜索",
65
83
  groupFree: "免密钥(开箱即用)",
66
84
  groupKeyed: "需要 API Key",
@@ -90,13 +108,14 @@ window.__ModuleLoader__.load({
90
108
  keySaveModeHint: "开关即时生效;密钥填写后需点「保存」写入凭证库",
91
109
  keySet: "已配置",
92
110
  keyUnset: "未配置",
111
+ keyChecking: "检查中…",
93
112
  togglesTitle: "启用后端",
94
113
  globalsTitle: "全局参数",
95
114
  numResultsLabel: "结果条数",
96
115
  concurrencyLabel: "并发数",
97
116
  timeoutLabel: "后端超时 (ms)",
98
117
  saveFailed: "保存失败",
99
- conflictHint: "其他端已修改,请先刷新",
118
+ conflictHint: "其他端已修改,已重新载入;请再次保存",
100
119
  shapingTitle: "结果策略",
101
120
  recencyLabel: "时间范围",
102
121
  langLabel: "搜索语言",
@@ -116,6 +135,7 @@ window.__ModuleLoader__.load({
116
135
  envProvided: "环境变量提供", readOnly: "只读,无需填写", conflict: "设置已在其他端被修改,请重试", keyFailed: "该 Key 保存失败",
117
136
  keyReadFailed: "密钥状态读取失败,请稍后重试",
118
137
  telemetryLabel: "结果健康遥测",
138
+ resultHeaderLabel: "结果引用提示头",
119
139
  fallbackHint: "全部后端已关闭:搜索将回退到默认免 Key 后端(计量型仍保持关闭)",
120
140
  invalidFields: "以下字段未通过校验:",
121
141
  readOnlyScope: "当前配置只读(可能由宿主锁定)",
@@ -126,10 +146,24 @@ window.__ModuleLoader__.load({
126
146
  interventionHint: "official 把查询与结果呈现完全交给官方工具;balanced 只剥明确的口语前缀;thorough 会重排并扩大后端请求,延迟与额度消耗更高。内部多查询仍是独立开关。",
127
147
  unavailable: "设置暂不可用:宿主没有返回配置快照(服务未就绪或路由未挂载)。",
128
148
  retry: "重试",
149
+ loading: "载入中…",
129
150
  toggleFailed: "开关未生效",
130
151
  optionalTitle: "可选 Key(私有实例 / 提升计量型额度)",
131
152
  };
132
153
  const en = {
154
+ backendExa: "Exa (MCP, free)",
155
+ backendParallel: "Parallel (MCP, free)",
156
+ backendDdg: "DuckDuckGo (HTML)",
157
+ backendSearxng: "SearXNG (meta-search)",
158
+ backendBrave: "Brave Search",
159
+ backendTavily: "Tavily (AI)",
160
+ backendSerper: "Serper.dev",
161
+ backendMojeek: "Mojeek",
162
+ backendDeepseek: "DeepSeek",
163
+ backendAnthropic: "Anthropic",
164
+ backendOpenai: "OpenAI",
165
+ backendFirecrawl: "Firecrawl (keyless, metered, off by default)",
166
+ backendTinyfish: "TinyFish (keyless, 30/min · 50/day, off by default)",
133
167
  nav: "Web Search",
134
168
  groupFree: "Keyless (ready to use)",
135
169
  groupKeyed: "Requires API key",
@@ -159,13 +193,14 @@ window.__ModuleLoader__.load({
159
193
  keySaveModeHint: "The switch applies immediately; the key is written to the credential store when you press Save",
160
194
  keySet: "configured",
161
195
  keyUnset: "not set",
196
+ keyChecking: "Checking…",
162
197
  togglesTitle: "Enabled backends",
163
198
  globalsTitle: "Global parameters",
164
199
  numResultsLabel: "Results",
165
200
  concurrencyLabel: "Concurrency",
166
201
  timeoutLabel: "Backend timeout (ms)",
167
202
  saveFailed: "Save failed",
168
- conflictHint: "Changed elsewhere — refresh first",
203
+ conflictHint: "Changed elsewhere — reloaded; press Save again",
169
204
  shapingTitle: "Result shaping",
170
205
  recencyLabel: "Recency",
171
206
  langLabel: "Language",
@@ -188,6 +223,7 @@ window.__ModuleLoader__.load({
188
223
  keyFailed: "failed to save this key",
189
224
  keyReadFailed: "could not read key status, please retry later",
190
225
  telemetryLabel: "Result health telemetry",
226
+ resultHeaderLabel: "Citation header",
191
227
  fallbackHint: "All backends off: search falls back to the default keyless four (metered backends stay off).",
192
228
  invalidFields: "Fields failed validation:",
193
229
  readOnlyScope: "Configuration is read-only (locked by host?)",
@@ -198,12 +234,13 @@ window.__ModuleLoader__.load({
198
234
  interventionHint: "official leaves query construction and presentation to the host tool; balanced strips only explicit conversational prefixes; thorough reranks and widens backend requests, costing more latency and quota. Internal multi-query stays a separate opt-in.",
199
235
  unavailable: "Settings are unavailable: the host returned no configuration snapshot (service not ready or route not mounted).",
200
236
  retry: "Retry",
237
+ loading: "Loading…",
201
238
  toggleFailed: "Toggle failed",
202
239
  optionalTitle: "Optional keys (private instance / higher metered limits)",
203
240
  };
204
241
 
205
242
  //#region styles
206
- const css = ".wsc-card{display:flex;flex-direction:column;gap:14px}.wsc-sectionTitle{font-size:13px;font-weight:600;opacity:.75;margin:4px 0 0}.wsc-toggles{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:6px}.wsc-toggle{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);cursor:pointer;font-size:13px;color:var(--dsw-alias-label-primary);background:0 0}.wsc-toggle input{accent-color:var(--dsw-alias-brand-primary)}.wsc-input,.wsc-keyInput{box-sizing:border-box;width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-size:13px;font-family:inherit}.wsc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px}.wsc-fieldHead{display:flex;justify-content:space-between;align-items:center;margin-bottom:3px}.wsc-label{font-size:12px;opacity:.8}.wsc-badge{font-size:11px;padding:1px 8px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2)}.wsc-badgeOn{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary)}.wsc-hint{font-size:11px;opacity:.55;margin:3px 0 0}.wsc-actions{display:flex;gap:8px;align-items:center}.wsc-btn{cursor:pointer;border:none;border-radius:10px;padding:8px 16px;font-size:13px;font-family:inherit;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.wsc-btn:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}.wsc-btnGhost{background:0 0;color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2)}.wsc-btn:disabled{opacity:.5;cursor:default}.wsc-status{font-size:12px;opacity:.7}";
243
+ const css = ".wsc-card{display:flex;flex-direction:column;gap:8px}.wsc-sectionTitle{margin:24px 0 0;font-size:14px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}.wsc-toggles{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:6px}.wsc-toggle{display:flex;align-items:center;gap:8px;padding:7px 10px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:13px;color:var(--dsw-alias-label-primary);background:0 0;transition:background-color .16s,border-color .16s}@media (hover:hover){.wsc-toggle:hover{background:var(--dsw-alias-interactive-bg-hover)}}.wsc-toggle input{accent-color:var(--dsw-alias-brand-primary)}.wsc-toggle:has(input:focus-visible){outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-toggle input:focus-visible{outline:none}.wsc-input,.wsc-keyInput{box-sizing:border-box;height:32px;width:100%;padding:0 10px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;font-family:inherit}select.wsc-input{cursor:pointer;max-width:240px}.wsc-input:focus,.wsc-keyInput:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}.wsc-input:disabled,.wsc-keyInput:disabled{opacity:.6;cursor:default}.wsc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px}.wsc-fieldHead{display:flex;justify-content:space-between;align-items:center;margin-bottom:3px}.wsc-label{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary)}.wsc-badge{font-size:11px;padding:1px 8px;border-radius:var(--dsw-radius-xs);border:.5px solid var(--dsw-alias-border-l3);color:var(--dsw-alias-label-secondary)}.wsc-badgeOn{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-state-success-primary)}.wsc-hint{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-secondary);margin:3px 0 0}.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary));font-size:12px}.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary));font-size:12px}.wsc-strip{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform)}.wsc-keyCard{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-xl);background:var(--dsw-alias-settings-card-fill)}.wsc-live{display:flex;gap:8px;align-items:center;flex-wrap:wrap;min-height:16px}.wsc-actionsStatic{position:static;border-top:0;padding:0;background:transparent}.wsc-actions{position:sticky;bottom:0;display:flex;gap:8px;align-items:center;padding:8px 0;background:var(--dsw-alias-bg-layer-2);border-top:.5px solid var(--dsw-alias-border-l2)}.wsc-btn{box-sizing:border-box;cursor:pointer;border:none;border-radius:var(--dsw-radius-md);height:36px;padding:0 14px;font-size:14px;line-height:22px;font-family:inherit;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}.wsc-btn:hover:not(.wsc-btnGhost):not(:disabled){background:var(--dsw-alias-button-primary-hover)}.wsc-btn:focus-visible{outline:none;box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}.wsc-btnGhost{background:0 0;color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l3)}.wsc-btnGhost:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}.wsc-btn:disabled{opacity:.4;cursor:default}.wsc-status{font-size:12px;color:var(--dsw-alias-label-secondary)}.wsc-status.wsc-error{color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 85%,var(--dsw-alias-label-primary))}.wsc-status.wsc-warn{color:color-mix(in srgb,var(--dsw-alias-state-warn-label) 65%,var(--dsw-alias-label-primary))}.wsc-dot{width:8px;height:8px;border-radius:50%;display:inline-block}.wsc-dotOn{background:var(--dsw-alias-state-success-primary)}.wsc-dotWarn{background:var(--dsw-alias-state-warn-primary)}.wsc-dotOff{background:var(--dsw-alias-label-tertiary)}.wsc-link{color:color-mix(in srgb,var(--dsw-alias-link) 90%,var(--dsw-alias-label-primary));text-decoration:none;border-radius:var(--dsw-radius-xs)}.wsc-link:hover{text-decoration:underline}.wsc-card fieldset[disabled] .wsc-toggle{opacity:.6;cursor:default}.wsc-card fieldset[disabled] .wsc-toggle:hover{background:transparent}";
207
244
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"dsh-websearch/card\"]") === null) {
208
245
  const tag = document.createElement("style");
209
246
  tag.dataset.plugin = "@240xu/dsh-websearch";
@@ -343,6 +380,8 @@ window.__ModuleLoader__.load({
343
380
 
344
381
  set(field, value) { return this.write([{ op: "set", path: [field], value }]); }
345
382
  unset(field) { return this.write([{ op: "unset", path: [field] }]); }
383
+ /** One POST for all staged field ops; the route accepts up to 64. */
384
+ setMany(ops) { return this.write(ops); }
346
385
  }
347
386
 
348
387
  /**
@@ -371,6 +410,7 @@ window.__ModuleLoader__.load({
371
410
  // cleared only by a later Save, nor persist after a retry succeeds.
372
411
  this.toggleFailed = false;
373
412
  this.toggleConflict = false;
413
+ this.toggleErrorId = null;
374
414
  this.failedKeys = new Map(); // envRef -> failure reason
375
415
  // Credential READ failures, distinct from SAVE failures above.
376
416
  // Only a fixed code is stored; raw host errors are never kept.
@@ -426,6 +466,7 @@ window.__ModuleLoader__.load({
426
466
  failed: this.failed,
427
467
  toggleFailed: this.toggleFailed,
428
468
  toggleConflict: this.toggleConflict,
469
+ toggleErrorId: this.toggleErrorId,
429
470
  version: (this.staged.size + ":" + [...this.staged.keys()].join(",")),
430
471
  };
431
472
  }
@@ -448,7 +489,17 @@ window.__ModuleLoader__.load({
448
489
  }
449
490
 
450
491
  /** Stage a field edit (clears the saved marker so the card shows "unsaved"). */
451
- edit(field, text) { this.savedAt = 0; this.staged.set(field, { text }); this.republish(); }
492
+ edit(field, text) {
493
+ const committed = String(this.sectionValue(field) ?? "");
494
+ if (String(text) === committed) {
495
+ // Reverting to the stored value is not a pending write.
496
+ if (this.staged.delete(field)) this.republish();
497
+ return;
498
+ }
499
+ this.savedAt = 0;
500
+ this.staged.set(field, { text });
501
+ this.republish();
502
+ }
452
503
  /** Drop a staged field edit; the stored value is untouched. */
453
504
  reset(field) { this.staged.delete(field); this.republish(); }
454
505
  /** Stage a credential draft; a blank draft is never staged so Save can drain. */
@@ -467,13 +518,15 @@ window.__ModuleLoader__.load({
467
518
  // while the new write is in flight so the card does not flicker.
468
519
  this.toggleFailed = false;
469
520
  this.toggleConflict = false;
521
+ this.toggleErrorId = null;
470
522
  try {
471
523
  await this.scope.set("enable" + id.charAt(0).toUpperCase() + id.slice(1), checked);
472
524
  } catch (err) {
473
525
  this.toggleFailed = true;
526
+ this.toggleErrorId = id;
474
527
  this.toggleConflict = String(err).includes("SETTINGS_CONFLICT");
475
- this.failed = false;
476
- this.conflict = false;
528
+ // Do not erase a Save failure: two independent writes must
529
+ // keep their own error state.
477
530
  // The host may have committed the write even when the
478
531
  // response failed. Resync instead of leaving the stale
479
532
  // pre-write value on screen. Report only the conflict
@@ -493,6 +546,8 @@ window.__ModuleLoader__.load({
493
546
  this.credSeq.set(ref, seq);
494
547
  let readFailed = false;
495
548
  let reason;
549
+ // A badge must not claim "not set" before the first read lands.
550
+ this.keyState.set(ref, { ...(this.keyState.get(ref) ?? {}), pending: true });
496
551
  try {
497
552
  let view;
498
553
  // Guard the namespace access: an undeclared remote service throws on
@@ -521,8 +576,13 @@ window.__ModuleLoader__.load({
521
576
  if (res?.result?.ok) view = res.result.value.credentials[ref];
522
577
  }
523
578
  if (!readFailed && view !== undefined && seq === this.credSeq.get(ref)) {
524
- this.keyState.set(ref, { configured: view.configured === true, writable: view.writable !== false });
579
+ this.keyState.set(ref, { configured: view.configured === true, writable: view.writable !== false, pending: false });
525
580
  this.readErrors.delete(ref);
581
+ } else if (!readFailed && view === undefined && api === undefined
582
+ && !(this.connection !== undefined && this.connection.api !== undefined && this.connection.api.credentials !== undefined)) {
583
+ // No credentials face at all: report unavailable instead of
584
+ // silently painting every badge "not set".
585
+ reason = "credential/service-unavailable";
526
586
  }
527
587
  } catch {
528
588
  reason = "credential/read-failed";
@@ -532,6 +592,14 @@ window.__ModuleLoader__.load({
532
592
  if (reason !== undefined && seq === this.credSeq.get(ref)) {
533
593
  this.readErrors.set(ref, safeFailureReason({ code: reason }));
534
594
  }
595
+ if (seq === this.credSeq.get(ref)) {
596
+ const prev = this.keyState.get(ref) ?? {};
597
+ this.keyState.set(ref, {
598
+ ...prev,
599
+ ...(prev.configured === undefined ? { configured: false } : {}),
600
+ pending: false,
601
+ });
602
+ }
535
603
  this.republish();
536
604
  }
537
605
  }
@@ -586,6 +654,11 @@ window.__ModuleLoader__.load({
586
654
  const savedFieldRefs = new Map();
587
655
  const savedKeyRefs = new Map();
588
656
  try {
657
+ // Validate every staged field first, then commit the whole set in
658
+ // one POST (the route applies up to 64 ops atomically). Falling
659
+ // back to the per-field API keeps older hosts working.
660
+ const fieldOps = [];
661
+ const fieldOpNames = [];
589
662
  for (const [field, staged] of this.staged) {
590
663
  // Snapshot the entry BEFORE any await. edit() replaces the staged
591
664
  // entry with a new object, so identity comparison later detects an edit
@@ -593,18 +666,14 @@ window.__ModuleLoader__.load({
593
666
  // await would capture the NEW edit and delete it as if saved.
594
667
  savedFieldRefs.set(field, staged);
595
668
  // Empty draft clears the override so the schema default applies again.
596
- if (staged.clear || staged.text === "") { await this.scope.unset(field); doneFields.push(field); continue; }
669
+ if (staged.clear || staged.text === "") { fieldOps.push({ op: "unset", path: [field] }); fieldOpNames.push(field); continue; }
597
670
  if (SELECT_FIELDS[field]) {
598
671
  if (!SELECT_FIELDS[field].includes(staged.text)) { this.failed = true; this.failedFields.add(field); continue; }
599
- await this.scope.set(field, staged.text);
600
- doneFields.push(field);
601
- continue;
672
+ fieldOps.push({ op: "set", path: [field], value: staged.text }); fieldOpNames.push(field); continue;
602
673
  }
603
674
  if (BOOLEAN_FIELDS.includes(field)) {
604
675
  if (staged.text !== "true" && staged.text !== "false") { this.failed = true; this.failedFields.add(field); continue; }
605
- await this.scope.set(field, staged.text === "true");
606
- doneFields.push(field);
607
- continue;
676
+ fieldOps.push({ op: "set", path: [field], value: staged.text === "true" }); fieldOpNames.push(field); continue;
608
677
  }
609
678
  if (GLOBAL_FIELDS.includes(field)) {
610
679
  const num = Number(staged.text);
@@ -616,13 +685,22 @@ window.__ModuleLoader__.load({
616
685
  backendTimeoutMs: [1000, 120000],
617
686
  };
618
687
  const [lo, hi] = BOUNDS[field] ?? [-Infinity, Infinity];
619
- if (!Number.isFinite(num) || num < lo || num > hi) { this.failed = true; this.failedFields.add(field); continue; }
620
- await this.scope.set(field, num);
621
- doneFields.push(field);
688
+ if (!Number.isInteger(num) || num < lo || num > hi) { this.failed = true; this.failedFields.add(field); continue; }
689
+ fieldOps.push({ op: "set", path: [field], value: num }); fieldOpNames.push(field);
690
+ } else {
691
+ fieldOps.push({ op: "set", path: [field], value: staged.text }); fieldOpNames.push(field);
692
+ }
693
+ }
694
+ if (fieldOps.length > 0) {
695
+ if (typeof this.scope.setMany === "function") {
696
+ await this.scope.setMany(fieldOps);
622
697
  } else {
623
- await this.scope.set(field, staged.text);
624
- doneFields.push(field);
698
+ for (const op of fieldOps) {
699
+ if (op.op === "unset") await this.scope.unset(op.path[0]);
700
+ else await this.scope.set(op.path[0], op.value);
701
+ }
625
702
  }
703
+ doneFields.push(...fieldOpNames);
626
704
  }
627
705
  for (const [ref, staged] of this.stagedKeys) {
628
706
  // Snapshot before any await, same reason as the field loop.
@@ -697,16 +775,17 @@ window.__ModuleLoader__.load({
697
775
  const checked = props.value === true;
698
776
  // Status dot: green keyless-or-keyed, amber enabled-but-key-missing.
699
777
  const needsKey = !!b.keyEnv && !b.optionalKey && !props.keyConfigured;
700
- const dotColor = needsKey ? (checked ? "#e6a700" : "#888") : "#2ea043";
778
+ const dotClass = "wsc-dot " + (needsKey ? (checked ? "wsc-dotWarn" : "wsc-dotOff") : "wsc-dotOn");
701
779
  return react_jsx_runtime.jsxs("label", { className: "wsc-toggle", style: { display: "flex", alignItems: "center", gap: 8, cursor: "pointer" }, children: [
702
780
  react_jsx_runtime.jsx("input", {
703
781
  type: "checkbox",
704
782
  checked,
705
783
  onChange: (e) => props.onChange(e.target.checked),
706
784
  }),
707
- react_jsx_runtime.jsx("span", { style: { width: 8, height: 8, borderRadius: "50%", background: dotColor, display: "inline-block" } }),
708
- react_jsx_runtime.jsx("span", { children: b.label }),
785
+ react_jsx_runtime.jsx("span", { className: dotClass }),
786
+ react_jsx_runtime.jsx("span", { children: props.t("backend" + b.id.charAt(0).toUpperCase() + b.id.slice(1)) }),
709
787
  needsKey && checked && react_jsx_runtime.jsx("span", { style: { fontSize: 10, opacity: .65 }, children: props.t("keyMissing") }),
788
+ props.toggleError && react_jsx_runtime.jsx("span", { className: "wsc-hint wsc-error", children: props.t("toggleFailed") }),
710
789
  ] });
711
790
  }
712
791
 
@@ -725,37 +804,40 @@ window.__ModuleLoader__.load({
725
804
  const checked = props.value === true;
726
805
  const configured = !!state.keyState[b.keyEnv]?.configured;
727
806
  const readOnly = configured && state.keyState[b.keyEnv]?.writable === false;
807
+ const locked = readOnly || props.locked === true;
728
808
  // failedKeys is an array of { ref, reason }, NOT an array of strings.
729
809
  const failure = (state.failedKeys ?? []).find((f) => f && f.ref === b.keyEnv);
730
810
  const readFailure = (state.readErrors ?? []).find((f) => f && f.ref === b.keyEnv);
731
811
  const needsKey = !configured;
732
- const dotColor = needsKey ? (checked ? "#e6a700" : "#888") : "#2ea043";
733
- return react_jsx_runtime.jsxs("div", { className: "wsc-keyCard", style: { display: "flex", flexDirection: "column", gap: 6, padding: "9px 10px", borderRadius: 10, border: "1px solid var(--dsw-alias-border-l2)" }, children: [
734
- react_jsx_runtime.jsxs("label", { className: "wsc-toggle", style: { display: "flex", alignItems: "center", gap: 8, cursor: "pointer", padding: 0, border: "none", borderRadius: 0 }, children: [
812
+ const dotClass = "wsc-dot " + (needsKey ? (checked ? "wsc-dotWarn" : "wsc-dotOff") : "wsc-dotOn");
813
+ return react_jsx_runtime.jsxs("div", { className: "wsc-keyCard", style: { display: "flex", flexDirection: "column", gap: 6, padding: "9px 10px" }, children: [
814
+ react_jsx_runtime.jsxs("label", { className: "wsc-toggle", style: { display: "flex", alignItems: "center", gap: 8, cursor: "pointer", padding: 0, border: "none", borderRadius: "var(--dsw-radius-sm)" }, children: [
735
815
  react_jsx_runtime.jsx("input", { type: "checkbox", checked, onChange: (e) => props.onToggle(e.target.checked) }),
736
- react_jsx_runtime.jsx("span", { style: { width: 8, height: 8, borderRadius: "50%", background: dotColor, display: "inline-block" } }),
737
- react_jsx_runtime.jsx("span", { children: b.label }),
816
+ react_jsx_runtime.jsx("span", { className: dotClass }),
817
+ react_jsx_runtime.jsx("span", { children: props.t("backend" + b.id.charAt(0).toUpperCase() + b.id.slice(1)) }),
738
818
  needsKey && checked && react_jsx_runtime.jsx("span", { style: { fontSize: 10, opacity: .65 }, children: props.t("keyMissing") }),
739
819
  ] }),
820
+ props.toggleError && react_jsx_runtime.jsx("p", { className: "wsc-hint wsc-error", children: props.t("toggleFailed") }),
740
821
  react_jsx_runtime.jsxs("div", { style: { display: "flex", gap: 6, alignItems: "center", flexWrap: "wrap" }, children: [
741
- react_jsx_runtime.jsx("span", { className: "wsc-badge" + (configured ? " wsc-badgeOn" : ""), children: configured ? props.t("keySet") : props.t("keyUnset") }),
742
- readOnly && react_jsx_runtime.jsx("span", { className: "wsc-badge", style: { opacity: .75 }, children: props.t("envProvided") }),
822
+ react_jsx_runtime.jsx("span", { className: "wsc-badge" + (configured ? " wsc-badgeOn" : ""), children: state.keyState[b.keyEnv]?.configured === undefined ? props.t("keyChecking") : configured ? props.t("keySet") : props.t("keyUnset") }),
823
+ readOnly && react_jsx_runtime.jsx("span", { className: "wsc-badge", children: props.t("envProvided") }),
743
824
  KEY_URLS[b.id] && react_jsx_runtime.jsx("a", {
744
- href: KEY_URLS[b.id], target: "_blank", rel: "noreferrer",
745
- style: { fontSize: 11, color: "var(--dsw-alias-link)", textDecoration: "none" },
825
+ href: KEY_URLS[b.id], target: "_blank", rel: "noreferrer", className: "wsc-link",
826
+ style: { fontSize: 11 },
746
827
  children: props.t("getKey"),
747
828
  }),
748
829
  ] }),
749
830
  react_jsx_runtime.jsx("input", {
750
831
  className: "wsc-keyInput", type: "password", autoComplete: "off",
751
- disabled: readOnly,
752
- placeholder: readOnly ? props.t("readOnly") : b.keyEnv,
832
+ "aria-label": props.t("keyLabel", { id: props.t("backend" + b.id.charAt(0).toUpperCase() + b.id.slice(1)) }),
833
+ disabled: locked,
834
+ placeholder: locked ? props.t("readOnly") : b.keyEnv,
753
835
  value: state.stagedKeys[b.keyEnv] ?? "",
754
836
  onChange: (e) => props.onEditKey(b.keyEnv, e.target.value),
755
837
  }),
756
838
  react_jsx_runtime.jsx("p", { className: "wsc-hint", children: props.t("keySaveModeHint") }),
757
- failure && react_jsx_runtime.jsx("p", { className: "wsc-hint", style: { color: "#e5534b" }, children: props.t("keyFailed") + (failure.reason ? ": " + failure.reason : "") }),
758
- readFailure && react_jsx_runtime.jsx("p", { className: "wsc-hint", style: { color: "#e6a700" }, children: props.t("keyReadFailed") }),
839
+ failure && react_jsx_runtime.jsx("p", { className: "wsc-hint wsc-error", children: props.t("keyFailed") + (failure.reason ? ": " + failure.reason : "") }),
840
+ readFailure && react_jsx_runtime.jsx("p", { className: "wsc-hint wsc-warn", children: props.t("keyReadFailed") }),
759
841
  ] });
760
842
  }
761
843
 
@@ -765,6 +847,7 @@ window.__ModuleLoader__.load({
765
847
  react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: props.label }) }),
766
848
  react_jsx_runtime.jsx("select", {
767
849
  className: "wsc-input",
850
+ "aria-label": props.label,
768
851
  value: props.value,
769
852
  onChange: (e) => props.onChange(e.target.value),
770
853
  children: props.options.map((o) =>
@@ -781,9 +864,9 @@ window.__ModuleLoader__.load({
781
864
  * @param {object} props { state, enabledCount, keysReady, t }
782
865
  */
783
866
  function StatusSummary(props) {
784
- const { state, enabledCount, keysReady, t } = props;
867
+ const { state, enabledCount, keysReady, hasOverride, t } = props;
785
868
  return react_jsx_runtime.jsxs(react_jsx_runtime.Fragment, { children: [
786
- react_jsx_runtime.jsx("div", { style: { display: "flex", gap: 14, alignItems: "center", padding: "10px 12px", marginBottom: 10, borderRadius: 8, background: "var(--dsw-alias-bg-module-platform)" }, children: [
869
+ react_jsx_runtime.jsx("div", { className: "wsc-strip", style: { display: "flex", gap: 14, alignItems: "center", padding: "10px 12px" }, children: [
787
870
  react_jsx_runtime.jsxs("span", { children: [t("statusEnabled"), ": ", react_jsx_runtime.jsx("b", { children: enabledCount + "/" + BACKENDS.length })] }),
788
871
  react_jsx_runtime.jsxs("span", { children: [t("statusKeys"), ": ", react_jsx_runtime.jsx("b", { children: keysReady + "/" + KEYED.length })] }),
789
872
  METERED.length > 0 && react_jsx_runtime.jsxs("span", { style: { opacity: .65 }, children: [
@@ -791,8 +874,8 @@ window.__ModuleLoader__.load({
791
874
  ] }),
792
875
  ] }),
793
876
  react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, opacity: .65 }, children: t("description") }),
794
- (enabledCount === 0) && react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, color: "#e6a700" }, children: t("fallbackHint") }),
795
- (state.writable === false) && react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, color: "#e6a700" }, children: t("readOnlyScope") }),
877
+ (!hasOverride && enabledCount === 0) && react_jsx_runtime.jsx("p", { className: "wsc-warn", style: { margin: 0, fontSize: 12 }, children: t("fallbackHint") }),
878
+ (state.writable === false) && react_jsx_runtime.jsx("p", { className: "wsc-warn", style: { margin: 0, fontSize: 12 }, children: t("readOnlyScope") }),
796
879
  ] });
797
880
  }
798
881
 
@@ -811,6 +894,7 @@ window.__ModuleLoader__.load({
811
894
  backend: b,
812
895
  value: state.value[toggleField(b.id)],
813
896
  keyConfigured: true,
897
+ toggleError: state.toggleErrorId === b.id,
814
898
  t,
815
899
  onChange: (checked) => card.setToggle(b.id, checked),
816
900
  }, b.id)
@@ -821,6 +905,7 @@ window.__ModuleLoader__.load({
821
905
  react_jsx_runtime.jsx(KeyedBackendCard, {
822
906
  backend: b,
823
907
  state,
908
+ locked: state.writable === false,
824
909
  value: state.value[toggleField(b.id)],
825
910
  t,
826
911
  onToggle: (checked) => card.setToggle(b.id, checked),
@@ -835,6 +920,7 @@ window.__ModuleLoader__.load({
835
920
  backend: b,
836
921
  value: state.value[toggleField(b.id)],
837
922
  keyConfigured: true,
923
+ toggleError: state.toggleErrorId === b.id,
838
924
  t,
839
925
  onChange: (checked) => card.setToggle(b.id, checked),
840
926
  }, b.id)
@@ -883,15 +969,15 @@ window.__ModuleLoader__.load({
883
969
  react_jsx_runtime.jsxs("div", { className: "wsc-grid", children: [
884
970
  react_jsx_runtime.jsxs("div", { children: [
885
971
  react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("numResultsLabel") }) }),
886
- react_jsx_runtime.jsx("input", { className: "wsc-input", value: state.stagedText("numResults") ?? String(state.value.numResults ?? ""), onChange: (e) => card.edit("numResults", e.target.value), inputMode: "numeric" }),
972
+ react_jsx_runtime.jsx("input", { className: "wsc-input", "aria-label": t("numResultsLabel"), value: state.stagedText("numResults") ?? String(state.value.numResults ?? ""), onChange: (e) => card.edit("numResults", e.target.value), inputMode: "numeric" }),
887
973
  ] }),
888
974
  react_jsx_runtime.jsxs("div", { children: [
889
975
  react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("concurrencyLabel") }) }),
890
- react_jsx_runtime.jsx("input", { className: "wsc-input", value: state.stagedText("concurrency") ?? String(state.value.concurrency ?? ""), onChange: (e) => card.edit("concurrency", e.target.value), inputMode: "numeric" }),
976
+ react_jsx_runtime.jsx("input", { className: "wsc-input", "aria-label": t("concurrencyLabel"), value: state.stagedText("concurrency") ?? String(state.value.concurrency ?? ""), onChange: (e) => card.edit("concurrency", e.target.value), inputMode: "numeric" }),
891
977
  ] }),
892
978
  react_jsx_runtime.jsxs("div", { children: [
893
979
  react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("timeoutLabel") }) }),
894
- react_jsx_runtime.jsx("input", { className: "wsc-input", value: state.stagedText("backendTimeoutMs") ?? String(state.value.backendTimeoutMs ?? ""), onChange: (e) => card.edit("backendTimeoutMs", e.target.value), inputMode: "numeric" }),
980
+ react_jsx_runtime.jsx("input", { className: "wsc-input", "aria-label": t("timeoutLabel"), value: state.stagedText("backendTimeoutMs") ?? String(state.value.backendTimeoutMs ?? ""), onChange: (e) => card.edit("backendTimeoutMs", e.target.value), inputMode: "numeric" }),
895
981
  ] }),
896
982
  ] }),
897
983
  react_jsx_runtime.jsx("h4", { className: "wsc-sectionTitle", children: t("shapingTitle") }),
@@ -902,6 +988,7 @@ window.__ModuleLoader__.load({
902
988
  react_jsx_runtime.jsx("div", { className: "wsc-fieldHead", children: react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("langLabel") }) }),
903
989
  react_jsx_runtime.jsx("input", {
904
990
  className: "wsc-input",
991
+ "aria-label": t("langLabel"),
905
992
  placeholder: t("langPlaceholder"),
906
993
  value: state.stagedText("language") ?? String(state.value.language ?? ""),
907
994
  onChange: (e) => card.edit("language", e.target.value),
@@ -912,6 +999,7 @@ window.__ModuleLoader__.load({
912
999
  react_jsx_runtime.jsx(SelectField, { label: t("rerankLabel"), value: selVal("rerank", "false"), options: boolOptions, onChange: (v) => card.edit("rerank", v) }),
913
1000
  react_jsx_runtime.jsx(SelectField, { label: t("safeSearchLabel"), value: selVal("safeSearch", "true"), options: boolOptions, onChange: (v) => card.edit("safeSearch", v) }),
914
1001
  react_jsx_runtime.jsx(SelectField, { label: t("telemetryLabel"), value: selVal("resultTelemetry", "true"), options: boolOptions, onChange: (v) => card.edit("resultTelemetry", v) }),
1002
+ react_jsx_runtime.jsx(SelectField, { label: t("resultHeaderLabel"), value: selVal("resultHeader", "true"), options: boolOptions, onChange: (v) => card.edit("resultHeader", v) }),
915
1003
  ] }),
916
1004
  ] });
917
1005
  }
@@ -931,54 +1019,66 @@ window.__ModuleLoader__.load({
931
1019
  const readFailure = (state.readErrors ?? []).find((f) => f && f.ref === b.keyEnv);
932
1020
  return react_jsx_runtime.jsxs("div", { children: [
933
1021
  react_jsx_runtime.jsxs("div", { className: "wsc-fieldHead", children: [
934
- react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("keyLabel", { id: b.label }) }),
935
- react_jsx_runtime.jsx("span", { className: "wsc-badge" + (state.keyState[b.keyEnv]?.configured ? " wsc-badgeOn" : ""), children: state.keyState[b.keyEnv]?.configured ? t("keySet") : t("keyUnset") }),
1022
+ react_jsx_runtime.jsx("span", { className: "wsc-label", children: t("keyLabel", { id: t("backend" + b.id.charAt(0).toUpperCase() + b.id.slice(1)) }) }),
1023
+ react_jsx_runtime.jsx("span", { className: "wsc-badge" + (state.keyState[b.keyEnv]?.configured ? " wsc-badgeOn" : ""), children: state.keyState[b.keyEnv]?.configured === undefined ? t("keyChecking") : state.keyState[b.keyEnv]?.configured ? t("keySet") : t("keyUnset") }),
936
1024
  ] }),
937
1025
  react_jsx_runtime.jsx("input", {
938
1026
  className: "wsc-keyInput", type: "password", autoComplete: "off",
939
- disabled: state.keyState[b.keyEnv]?.configured && state.keyState[b.keyEnv]?.writable === false,
940
- placeholder: b.keyEnv,
1027
+ "aria-label": t("keyLabel", { id: t("backend" + b.id.charAt(0).toUpperCase() + b.id.slice(1)) }),
1028
+ disabled: state.writable === false || (state.keyState[b.keyEnv]?.configured && state.keyState[b.keyEnv]?.writable === false),
1029
+ placeholder: state.writable === false ? t("readOnly") : b.keyEnv,
941
1030
  value: state.stagedKeys[b.keyEnv] ?? "",
942
1031
  onChange: (e) => card.editKey(b.keyEnv, e.target.value),
943
1032
  }),
944
1033
  react_jsx_runtime.jsx("p", { className: "wsc-hint", children: t("keySaveModeHint") }),
945
- failure && react_jsx_runtime.jsx("p", { className: "wsc-hint", style: { color: "#e5534b" }, children: t("keyFailed") + (failure.reason ? ": " + failure.reason : "") }),
946
- readFailure && react_jsx_runtime.jsx("p", { className: "wsc-hint", style: { color: "#e6a700" }, children: t("keyReadFailed") }),
1034
+ failure && react_jsx_runtime.jsx("p", { className: "wsc-hint wsc-error", children: t("keyFailed") + (failure.reason ? ": " + failure.reason : "") }),
1035
+ readFailure && react_jsx_runtime.jsx("p", { className: "wsc-hint wsc-warn", children: t("keyReadFailed") }),
947
1036
  ] }, b.id);
948
1037
  }) }),
949
1038
  state.stagedCount > 0 && react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, opacity: .65 }, children: t("unsavedHint") }),
950
1039
  react_jsx_runtime.jsxs("div", { className: "wsc-actions", children: [
951
1040
  react_jsx_runtime.jsx("button", { className: "wsc-btn", disabled: state.saving || state.stagedCount === 0 || state.writable === false, onClick: () => card.save(), children: state.saving ? t("saving") : t("save") }),
952
1041
  (state.stagedCount > 0) && react_jsx_runtime.jsx("button", { className: "wsc-btn wsc-btnGhost", disabled: state.saving, onClick: () => card.discard(), children: t("discard") }),
953
- state.failed && react_jsx_runtime.jsx("span", { className: "wsc-status", style: { color: "#e5534b" }, children: state.conflict ? t("conflict") : t("saveFailed") }),
954
- state.toggleFailed && react_jsx_runtime.jsx("span", { className: "wsc-status", style: { color: "#e5534b" }, children: t("toggleFailed") + (state.toggleConflict ? " — " + t("conflict") : "") }),
955
- (state.failedFields.length > 0) && react_jsx_runtime.jsx("span", { className: "wsc-status", style: { color: "#e6a700" }, children: t("invalidFields") + " " + state.failedFields.join(", ") }),
956
- state.conflict && react_jsx_runtime.jsx("span", { className: "wsc-status", style: { color: "#e6a700" }, children: t("conflictHint") }),
957
- !state.failed && !state.saving && state.savedAt > 0 && react_jsx_runtime.jsx("span", { className: "wsc-status", style: { color: "#2ea043" }, children: t("savedOk") }),
1042
+ react_jsx_runtime.jsxs("span", { className: "wsc-live", role: "status", "aria-live": "polite", children: [
1043
+ state.failed && !state.conflict && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-error", children: t("saveFailed") }),
1044
+ state.toggleFailed && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-error", children: t("toggleFailed") + (state.toggleConflict ? " — " + t("conflict") : "") }),
1045
+ (state.failedFields.length > 0) && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-warn", children: t("invalidFields") + " " + state.failedFields.join(", ") }),
1046
+ state.conflict && react_jsx_runtime.jsx("span", { className: "wsc-status wsc-warn", children: t("conflictHint") }),
1047
+ state.conflict && react_jsx_runtime.jsx("button", { className: "wsc-btn wsc-btnGhost", disabled: state.saving, onClick: () => card.retry(), children: t("retry") }),
1048
+ !state.failed && !state.saving && state.savedAt > 0 && react_jsx_runtime.jsx("span", { className: "wsc-status", children: t("savedOk") }),
1049
+ ] }),
958
1050
  ] }),
959
1051
  ] });
960
1052
  }
961
1053
 
962
1054
  function UnifiedSearchSection(props) {
963
1055
  const state = props.useUnifiedSearchCard((snapshot) => snapshot);
964
- const card = { edit: props.edit, setToggle: props.setToggle, reset: props.reset, editKey: props.editKey, save: props.save, discard: props.discard };
1056
+ const card = { edit: props.edit, setToggle: props.setToggle, reset: props.reset, editKey: props.editKey, save: props.save, discard: props.discard, retry: props.retry };
965
1057
  // Occupants of settings.plugin.item render inside the tab's <ul>; use <li>.
966
1058
  if (!state.ready) {
967
- return react_jsx_runtime.jsx("div", { className: "wsc-card", style: { fontSize: 12, opacity: .6 }, children: "…" });
1059
+ return react_jsx_runtime.jsx("div", { className: "wsc-card", style: { fontSize: 12, opacity: .6 }, role: "status", "aria-live": "polite", children: props.t("loading") });
968
1060
  }
969
1061
  // No snapshot at all (404/503): showing "0/13 enabled" plus live
970
1062
  // controls would be a fabricated state. Explain it and offer a retry.
971
1063
  if (state.unavailable) {
972
1064
  return react_jsx_runtime.jsxs("div", { className: "wsc-card", children: [
973
1065
  react_jsx_runtime.jsx("p", { style: { margin: 0, fontSize: 12, opacity: .75 }, children: props.t("unavailable") }),
974
- react_jsx_runtime.jsx("div", { className: "wsc-actions", children: react_jsx_runtime.jsx("button", { className: "wsc-btn", onClick: () => props.retry(), children: props.t("retry") }) }),
1066
+ react_jsx_runtime.jsx("div", { className: "wsc-actions wsc-actionsStatic", children: react_jsx_runtime.jsx("button", { className: "wsc-btn", onClick: () => props.retry(), children: props.t("retry") }) }),
975
1067
  ] });
976
1068
  }
977
1069
 
978
1070
  const toggleField = (id) => "enable" + id.charAt(0).toUpperCase() + id.slice(1);
979
1071
 
980
1072
  // Status summary: enabled backends + configured keys at a glance.
981
- const enabledCount = BACKENDS.filter((b) => state.value[toggleField(b.id)] === true).length;
1073
+ const override = Array.isArray(state.value.enabledBackends)
1074
+ ? state.value.enabledBackends.filter((id) => BACKENDS.some((b) => b.id === id))
1075
+ : [];
1076
+ // An explicit enabledBackends list wins over the toggles in the engine,
1077
+ // so the status strip and the all-off hint must describe that list, not
1078
+ // the toggle positions the engine ignores.
1079
+ const enabledCount = override.length > 0
1080
+ ? override.length
1081
+ : BACKENDS.filter((b) => state.value[toggleField(b.id)] === true).length;
982
1082
  const keysReady = KEYED.filter((b) => state.keyState[b.keyEnv]?.configured).length;
983
1083
 
984
1084
  const recencyOptions = [
@@ -999,7 +1099,7 @@ window.__ModuleLoader__.load({
999
1099
  const selVal = (f, dflt) => state.stagedText(f) ?? String(state.value[f] ?? dflt);
1000
1100
 
1001
1101
  return react_jsx_runtime.jsxs("div", { className: "wsc-card", children: [
1002
- react_jsx_runtime.jsx(StatusSummary, { state, enabledCount, keysReady, t: props.t }),
1102
+ react_jsx_runtime.jsx(StatusSummary, { state, enabledCount, hasOverride: override.length > 0, keysReady, t: props.t }),
1003
1103
  // A read-only snapshot (scope locked by the host) must not render
1004
1104
  // live toggles: fieldset disabled disables every descendant input,
1005
1105
  // select and button without relying on each call site.
@@ -1056,7 +1156,7 @@ window.__ModuleLoader__.load({
1056
1156
  // event face this build exposes; a missing face must not abort apply().
1057
1157
  for (const event of ["credentials/reference-updated", "credentials/updated"]) {
1058
1158
  try {
1059
- ctx.effect(() => ctx.remote.$on(event, () => controller.refreshAllCredentials()), "websearch: credential invalidations");
1159
+ ctx.effect(() => ctx.remote.$on(event, (ref) => (typeof ref === "string" ? controller.readCredential(ref) : controller.refreshAllCredentials())), "websearch: credential invalidations");
1060
1160
  } catch (_noEventFace) { /* this build does not forward that event */ }
1061
1161
  }
1062
1162
  // Re-read when another client saves this namespace (settings document
package/lib/health.js CHANGED
@@ -36,6 +36,7 @@ export function buildHealthReport({ resolveOptions, backends, getBackendHealth }
36
36
  const opts = resolveOptions();
37
37
  const healthMap = typeof getBackendHealth === "function" ? getBackendHealth() : getBackendHealth;
38
38
  const tel = healthMap instanceof Map ? healthMap : new Map();
39
+ const nowMs = Date.now();
39
40
 
40
41
  const enabledSet = new Set(
41
42
  (opts.enabledBackends ?? []).filter((id) => backends[id] !== undefined),
@@ -57,7 +58,7 @@ export function buildHealthReport({ resolveOptions, backends, getBackendHealth }
57
58
  // parsing lastError. Additive fields; existing keys keep their meaning.
58
59
  rateLimited: t?.rateLimited === true,
59
60
  keylessRejected: t?.keylessRejected === true,
60
- cooledUntilMs: Number.isFinite(t?.cooledUntil) && t.cooledUntil > 0 ? t.cooledUntil : null,
61
+ cooledUntilMs: Number.isFinite(t?.cooledUntil) && t.cooledUntil > nowMs ? t.cooledUntil : null,
61
62
  // reachable: true/false from the latest search telemetry; null = never probed.
62
63
  reachable: t ? t.ok === true : null,
63
64
  lastOk: t && typeof t.lastOkAt === "number" ? t.lastOkAt : null,
package/lib/history.js CHANGED
@@ -54,10 +54,10 @@ export function createHistoryStore({ dir, maxEntries = HISTORY_MAX_ENTRIES }) {
54
54
  }
55
55
 
56
56
  function atomicWriteAll(list) {
57
- mkdirSync(dir, { recursive: true });
57
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
58
58
  const f = file();
59
59
  const tmp = `${f}.${process.pid}.tmp`;
60
- writeFileSync(tmp, JSON.stringify(list, null, 2), "utf8");
60
+ writeFileSync(tmp, JSON.stringify(list, null, 2), { encoding: "utf8", mode: 0o600 });
61
61
  renameSync(tmp, f);
62
62
  }
63
63
 
@@ -113,7 +113,7 @@ export function toBackendObservability(healthMap, nowMs = Date.now()) {
113
113
  at: Number.isFinite(e?.at) ? e.at : null,
114
114
  failCount: Number.isFinite(e?.failCount) ? e.failCount : 0,
115
115
  cooled: Number.isFinite(e?.cooledUntil) && e.cooledUntil > nowMs,
116
- cooledUntilMs: Number.isFinite(e?.cooledUntil) && e.cooledUntil > 0 ? e.cooledUntil : null,
116
+ cooledUntilMs: Number.isFinite(e?.cooledUntil) && e.cooledUntil > nowMs ? e.cooledUntil : null,
117
117
  rateLimited: e?.rateLimited === true,
118
118
  keylessRejected: e?.keylessRejected === true,
119
119
  });