dsh-web-search-pro 0.2.1 → 0.2.3
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/CHANGELOG.md +164 -0
- package/README.md +154 -58
- package/assets/skills/dsh-web-search-pro/SKILL.md +13 -12
- package/assets/skills/dsh-web-search-pro/references/config.md +36 -0
- package/assets/skills/dsh-web-search-pro/references/sources.md +13 -7
- package/assets/skills/dsh-web-search-pro/references/troubleshooting.md +3 -1
- package/catalog/sources.v1.json +16 -14
- package/lib/actions/approval.js +50 -1
- package/lib/actions/approval.js.map +1 -1
- package/lib/actions/config.js +274 -0
- package/lib/actions/config.js.map +1 -0
- package/lib/actions/errors.js +8 -1
- package/lib/actions/errors.js.map +1 -1
- package/lib/actions/format.js +10 -0
- package/lib/actions/format.js.map +1 -1
- package/lib/actions/index-view.js +2 -2
- package/lib/actions/index-view.js.map +1 -1
- package/lib/actions/read.js +7 -3
- package/lib/actions/read.js.map +1 -1
- package/lib/actions/registry.js +3 -1
- package/lib/actions/registry.js.map +1 -1
- package/lib/actions/run.js +2 -2
- package/lib/actions/run.js.map +1 -1
- package/lib/actions/schema.js +18 -0
- package/lib/actions/schema.js.map +1 -1
- package/lib/actions/search.js +7 -2
- package/lib/actions/search.js.map +1 -1
- package/lib/actions/sources.js +76 -18
- package/lib/actions/sources.js.map +1 -1
- package/lib/actions/types.js +19 -1
- package/lib/actions/types.js.map +1 -1
- package/lib/browser-access.js +25 -0
- package/lib/browser-access.js.map +1 -1
- package/lib/catalog/recommend.js +11 -3
- package/lib/catalog/recommend.js.map +1 -1
- package/lib/catalog/schema.js +3 -1
- package/lib/catalog/schema.js.map +1 -1
- package/lib/cli/builtin-specs.js +57 -22
- package/lib/cli/builtin-specs.js.map +1 -1
- package/lib/cli/chain.js +13 -12
- package/lib/cli/chain.js.map +1 -1
- package/lib/cli/chains-spec.js +31 -11
- package/lib/cli/chains-spec.js.map +1 -1
- package/lib/cli/engine.js +19 -3
- package/lib/cli/engine.js.map +1 -1
- package/lib/cli/opencli-sites.js +83 -0
- package/lib/cli/opencli-sites.js.map +1 -0
- package/lib/cli/opencli.js +65 -17
- package/lib/cli/opencli.js.map +1 -1
- package/lib/cli/probe.js +1 -1
- package/lib/cli/probe.js.map +1 -1
- package/lib/cli/runner.js +217 -27
- package/lib/cli/runner.js.map +1 -1
- package/lib/cli/spec.js +100 -20
- package/lib/cli/spec.js.map +1 -1
- package/lib/cli/time-text.js +79 -0
- package/lib/cli/time-text.js.map +1 -0
- package/lib/cli/trial.js +57 -0
- package/lib/cli/trial.js.map +1 -0
- package/lib/client/SettingsCard.js +14 -32
- package/lib/client/SettingsCard.js.map +1 -1
- package/lib/client/agent-mark.js +27 -0
- package/lib/client/agent-mark.js.map +1 -0
- package/lib/client/card-frame.js +118 -0
- package/lib/client/card-frame.js.map +1 -0
- package/lib/client/cli-form.js +257 -0
- package/lib/client/cli-form.js.map +1 -0
- package/lib/client/field-docs.js +130 -0
- package/lib/client/field-docs.js.map +1 -0
- package/lib/client/field-keys.js +81 -0
- package/lib/client/field-keys.js.map +1 -0
- package/lib/client/field-rows.js +71 -0
- package/lib/client/field-rows.js.map +1 -0
- package/lib/client/fill.js +3 -0
- package/lib/client/fill.js.map +1 -0
- package/lib/client/form-specs.js +13 -1
- package/lib/client/form-specs.js.map +1 -1
- package/lib/client/form.js +282 -24
- package/lib/client/form.js.map +1 -1
- package/lib/client/group-advanced.js +23 -0
- package/lib/client/group-advanced.js.map +1 -0
- package/lib/client/group-agent.js +28 -0
- package/lib/client/group-agent.js.map +1 -0
- package/lib/client/group-cli.js +136 -0
- package/lib/client/group-cli.js.map +1 -0
- package/lib/client/group-common.js +29 -0
- package/lib/client/group-common.js.map +1 -0
- package/lib/client/group-judge.js +67 -0
- package/lib/client/group-judge.js.map +1 -0
- package/lib/client/group-order.js +201 -0
- package/lib/client/group-order.js.map +1 -0
- package/lib/client/group-runtime.js +33 -0
- package/lib/client/group-runtime.js.map +1 -0
- package/lib/client/group-sources.js +83 -0
- package/lib/client/group-sources.js.map +1 -0
- package/lib/client/groups-basic.js +36 -0
- package/lib/client/groups-basic.js.map +1 -0
- package/lib/client/index.js.map +1 -1
- package/lib/client/json-list.js +50 -0
- package/lib/client/json-list.js.map +1 -0
- package/lib/client/locales.js +666 -219
- package/lib/client/locales.js.map +1 -1
- package/lib/client/order.js +192 -0
- package/lib/client/order.js.map +1 -0
- package/lib/client/overlay-ops.js +46 -0
- package/lib/client/overlay-ops.js.map +1 -0
- package/lib/client/sources-table.js +1 -0
- package/lib/client/sources-table.js.map +1 -1
- package/lib/client/styles.js +74 -47
- package/lib/client/styles.js.map +1 -1
- package/lib/client/text-view.js +98 -0
- package/lib/client/text-view.js.map +1 -0
- package/lib/client/ui-kit.js +120 -0
- package/lib/client/ui-kit.js.map +1 -0
- package/lib/client/validators.js +8 -1
- package/lib/client/validators.js.map +1 -1
- package/lib/client.js +7313 -1571
- package/lib/client.js.map +1 -1
- package/lib/config-fillers.js +53 -0
- package/lib/config-fillers.js.map +1 -0
- package/lib/config-groups.js +49 -0
- package/lib/config-groups.js.map +1 -0
- package/lib/config.js +84 -108
- package/lib/config.js.map +1 -1
- package/lib/default-chain.js +66 -0
- package/lib/default-chain.js.map +1 -0
- package/lib/deps.js +1 -1
- package/lib/deps.js.map +1 -1
- package/lib/engines.js +3 -3
- package/lib/engines.js.map +1 -1
- package/lib/fetch.js +23 -4
- package/lib/fetch.js.map +1 -1
- package/lib/index.js +30 -5
- package/lib/index.js.map +1 -1
- package/lib/overlay-types.js +88 -0
- package/lib/overlay-types.js.map +1 -0
- package/lib/overlay.js +683 -0
- package/lib/overlay.js.map +1 -0
- package/lib/pipeline/candidates.js +27 -1
- package/lib/pipeline/candidates.js.map +1 -1
- package/lib/pipeline/compile.js +63 -0
- package/lib/pipeline/compile.js.map +1 -1
- package/lib/pipeline/confidence.js +64 -0
- package/lib/pipeline/confidence.js.map +1 -0
- package/lib/pipeline/fusion.js +50 -3
- package/lib/pipeline/fusion.js.map +1 -1
- package/lib/pipeline/plan.js +2 -2
- package/lib/pipeline/plan.js.map +1 -1
- package/lib/pipeline/render.js +20 -2
- package/lib/pipeline/render.js.map +1 -1
- package/lib/pipeline/run.js +17 -5
- package/lib/pipeline/run.js.map +1 -1
- package/lib/pipeline/sources-spec.js +19 -3
- package/lib/pipeline/sources-spec.js.map +1 -1
- package/lib/providers/builtin.js +3 -0
- package/lib/providers/builtin.js.map +1 -1
- package/lib/providers/deepseek.js +348 -0
- package/lib/providers/deepseek.js.map +1 -0
- package/lib/providers/http.js.map +1 -1
- package/lib/providers/keyed-meta.js +7 -0
- package/lib/providers/keyed-meta.js.map +1 -1
- package/lib/providers/platforms.js +18 -17
- package/lib/providers/platforms.js.map +1 -1
- package/lib/providers/registry.js.map +1 -1
- package/lib/restart.js +47 -0
- package/lib/restart.js.map +1 -0
- package/lib/router.js +145 -26
- package/lib/router.js.map +1 -1
- package/lib/rpc-types.js +15 -0
- package/lib/rpc-types.js.map +1 -0
- package/lib/rpc.js +85 -0
- package/lib/rpc.js.map +1 -0
- package/lib/tools.js +10 -4
- package/lib/tools.js.map +1 -1
- package/lib/types/actions/approval.d.ts +11 -0
- package/lib/types/actions/config.d.ts +54 -0
- package/lib/types/actions/format.d.ts +9 -2
- package/lib/types/actions/run.d.ts +1 -0
- package/lib/types/actions/schema.d.ts +7 -1
- package/lib/types/actions/sources.d.ts +29 -3
- package/lib/types/actions/types.d.ts +28 -2
- package/lib/types/browser-access.d.ts +17 -0
- package/lib/types/catalog/recommend.d.ts +4 -0
- package/lib/types/catalog/schema.d.ts +2 -0
- package/lib/types/cli/builtin-specs.d.ts +11 -3
- package/lib/types/cli/chains-spec.d.ts +12 -3
- package/lib/types/cli/engine.d.ts +10 -3
- package/lib/types/cli/opencli-sites.d.ts +24 -0
- package/lib/types/cli/opencli.d.ts +42 -3
- package/lib/types/cli/runner.d.ts +47 -8
- package/lib/types/cli/spec.d.ts +101 -8
- package/lib/types/cli/time-text.d.ts +12 -0
- package/lib/types/cli/trial.d.ts +19 -0
- package/lib/types/client/SettingsCard.d.ts +17 -1
- package/lib/types/client/agent-mark.d.ts +22 -0
- package/lib/types/client/card-frame.d.ts +35 -0
- package/lib/types/client/cli-form.d.ts +97 -0
- package/lib/types/client/field-docs.d.ts +15 -0
- package/lib/types/client/field-keys.d.ts +41 -0
- package/lib/types/client/field-rows.d.ts +70 -0
- package/lib/types/client/fill.d.ts +2 -0
- package/lib/types/client/form-specs.d.ts +12 -3
- package/lib/types/client/form.d.ts +79 -1
- package/lib/types/client/group-advanced.d.ts +9 -0
- package/lib/types/client/group-agent.d.ts +20 -0
- package/lib/types/client/group-cli.d.ts +52 -0
- package/lib/types/client/group-common.d.ts +12 -0
- package/lib/types/client/group-judge.d.ts +17 -0
- package/lib/types/client/group-order.d.ts +26 -0
- package/lib/types/client/group-runtime.d.ts +15 -0
- package/lib/types/client/group-sources.d.ts +46 -0
- package/lib/types/client/groups-basic.d.ts +18 -0
- package/lib/types/client/index.d.ts +8 -0
- package/lib/types/client/json-list.d.ts +21 -0
- package/lib/types/client/locales.d.ts +1079 -200
- package/lib/types/client/order.d.ts +102 -0
- package/lib/types/client/overlay-ops.d.ts +37 -0
- package/lib/types/client/styles.d.ts +56 -41
- package/lib/types/client/text-view.d.ts +22 -0
- package/lib/types/client/ui-kit.d.ts +200 -0
- package/lib/types/config-fillers.d.ts +9 -0
- package/lib/types/config-groups.d.ts +23 -0
- package/lib/types/config.d.ts +263 -225
- package/lib/types/default-chain.d.ts +63 -0
- package/lib/types/engines.d.ts +29 -1
- package/lib/types/fetch.d.ts +12 -3
- package/lib/types/index.d.ts +164 -150
- package/lib/types/overlay-types.d.ts +98 -0
- package/lib/types/overlay.d.ts +141 -0
- package/lib/types/pipeline/candidates.d.ts +17 -0
- package/lib/types/pipeline/compile.d.ts +11 -0
- package/lib/types/pipeline/confidence.d.ts +35 -0
- package/lib/types/pipeline/fusion.d.ts +23 -1
- package/lib/types/pipeline/render.d.ts +16 -0
- package/lib/types/pipeline/run.d.ts +2 -1
- package/lib/types/pipeline/sources-spec.d.ts +5 -2
- package/lib/types/pipeline/types.d.ts +37 -0
- package/lib/types/providers/deepseek.d.ts +130 -0
- package/lib/types/providers/http.d.ts +2 -1
- package/lib/types/providers/keyed-meta.d.ts +5 -0
- package/lib/types/providers/registry.d.ts +7 -0
- package/lib/types/restart.d.ts +52 -0
- package/lib/types/router.d.ts +57 -10
- package/lib/types/rpc-types.d.ts +79 -0
- package/lib/types/rpc.d.ts +41 -0
- package/lib/types/tools.d.ts +6 -0
- package/lib/types/util.d.ts +10 -0
- package/lib/util.js +10 -1
- package/lib/util.js.map +1 -1
- package/package.json +50 -42
- package/scripts/check-client-bundle.mjs +1 -1
- package/scripts/cli-login-check.mjs +214 -0
- package/lib/client/RubricEditor.js +0 -47
- package/lib/client/RubricEditor.js.map +0 -1
- package/lib/client/fields.js +0 -31
- package/lib/client/fields.js.map +0 -1
- package/lib/types/client/RubricEditor.d.ts +0 -6
- package/lib/types/client/fields.d.ts +0 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/providers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA0BH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/providers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA0BH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAU,CAAA;AAsGtE,yHAAyH;AACzH,MAAM,UAAU,UAAU,CAAC,UAA8D;IACvF,OAAO,UAAU,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,C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AC,QAAQ,CAAC,CAAA,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,gFAAgF;IAChF,IAAI,QAAQ,KAAa,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;IAEtC,KAAK;QACX,IAAI,CAAC,OAAO,EAAE,CAAA;QACd,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAAC,IAAI,CAAC;gBAAC,QAAQ,EAAE,CAAA;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,4CAA4C,CAAC,CAAC;QAAC,CAAC;IACtH,CAAC;CACF"}
|
package/lib/restart.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settings that are read once, when the plugin starts. Almost every field of `Config` is live (the Host updates the entry's
|
|
3
|
+
* configuration in place and every call reads it through `dynamic()`), but these few are applied while the plugin is mounted:
|
|
4
|
+
* a database opened, a tool registered, a cache sized, a deadline fixed. The Host lets them be edited (they are volatile in
|
|
5
|
+
* the schema), so without a marker the edit looks like it was ignored until the next restart.
|
|
6
|
+
*
|
|
7
|
+
* One constant lists them; the settings card marks them, the save bar says so when a save touches one, and `sources.status` /
|
|
8
|
+
* `config.inspect` report "待重启" when the configured value differs from the one the running plugin started with. Pure and
|
|
9
|
+
* free of imports: the client bundle includes this file.
|
|
10
|
+
* @module web-search-pro/restart
|
|
11
|
+
*/
|
|
12
|
+
/** Why each field is read at start-up only (shown in the docs and the card's `?` text). */
|
|
13
|
+
export const RESTART_FIELDS = {
|
|
14
|
+
toolSurface: 'the tools (web_index + web_call, or one tool per action) are registered at start-up',
|
|
15
|
+
'playwright.snapshotDir': 'the snapshot folder of read.snapshot is resolved at start-up',
|
|
16
|
+
providerId: 'the id of the ctx.web provider is given to the Host at registration',
|
|
17
|
+
registerProvider: 'the ctx.web provider is registered at start-up',
|
|
18
|
+
timeoutMs: 'the per-action deadlines and the Host tool ceiling are fixed at start-up (the cooperative time budget of a search reads it live)',
|
|
19
|
+
memoryCacheEntries: 'the in-process LRU cache is sized at start-up',
|
|
20
|
+
dbPath: 'the SQLite store and the overlay file are opened at start-up',
|
|
21
|
+
verbose: 'the load marker is written at start-up',
|
|
22
|
+
};
|
|
23
|
+
/** The field names, in the order of the configuration groups (config-groups.ts). */
|
|
24
|
+
export const RESTART_FIELD_LIST = Object.keys(RESTART_FIELDS);
|
|
25
|
+
export const isRestartField = (field) => Object.hasOwn(RESTART_FIELDS, field);
|
|
26
|
+
/** The values of the restart fields as short text, from a resolved configuration. */
|
|
27
|
+
export function restartValues(config) {
|
|
28
|
+
return {
|
|
29
|
+
dbPath: config.dbPath,
|
|
30
|
+
toolSurface: config.toolSurface,
|
|
31
|
+
registerProvider: String(config.registerProvider),
|
|
32
|
+
providerId: config.providerId,
|
|
33
|
+
verbose: String(config.verbose),
|
|
34
|
+
memoryCacheEntries: String(config.memoryCacheEntries),
|
|
35
|
+
timeoutMs: String(config.timeoutMs),
|
|
36
|
+
'playwright.snapshotDir': config.playwright.snapshotDir ?? '',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** The restart fields whose configured value differs from the one the running plugin started with. */
|
|
40
|
+
export function pendingRestart(mounted, current) {
|
|
41
|
+
return RESTART_FIELD_LIST.filter(field => mounted[field] !== current[field]).map(field => ({ field, running: mounted[field], configured: current[field] }));
|
|
42
|
+
}
|
|
43
|
+
/** `待重启:toolSurface(当前生效 indexed,配置为 flat)`, one line per field. */
|
|
44
|
+
export function pendingRestartLine(entry) {
|
|
45
|
+
return '待重启:' + entry.field + '(当前生效 ' + (entry.running || '(空)') + ',配置为 ' + (entry.configured || '(空)') + ')';
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=restart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../src/restart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG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EAAE,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;AAC7J,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACtD,OAAO,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,GAAG,CAAA;AACjH,CAAC"}
|
package/lib/router.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* @module web-search-pro/router
|
|
5
5
|
*/
|
|
6
6
|
import { credentialRef } from '@deepseek-ai/dsh-credentials';
|
|
7
|
+
import { effectiveChain } from "./default-chain.js";
|
|
7
8
|
import { EngineError, } from "./engines.js";
|
|
8
9
|
import { customCliAdapter, customCliProviderId, customKeyProblem, customPlatformAdapter } from "./providers/platforms.js";
|
|
9
|
-
import { platformBackendIssues } from "./cli/chains-spec.js";
|
|
10
|
-
import { resolveCliAdapters } from "./cli/spec.js";
|
|
10
|
+
import { customCliPlatformIssues, isBackendId, platformBackendIssues } from "./cli/chains-spec.js";
|
|
11
|
+
import { DEFAULT_CUSTOM_CONFIDENCE, resolveCliAdapters } from "./cli/spec.js";
|
|
11
12
|
import { SourceUnavailableError } from "./providers/unavailable.js";
|
|
12
13
|
import { defaultProviderRegistry, costTierOf, routeIdOf } from "./providers/index.js";
|
|
13
14
|
import { BOCHA_FALLBACK_KEY_ENV, BOCHA_KEY_ENV } from "./providers/bocha.js";
|
|
@@ -24,8 +25,25 @@ import { createPlatformCacheKey, createSearchCacheKey } from "./cache-key.js";
|
|
|
24
25
|
import { allAttemptsBenign, allAttemptsEmpty, BackendRegistry, NoBackendError } from "./backend-registry.js";
|
|
25
26
|
import { ExaClient } from "./exa-client.js";
|
|
26
27
|
import { SingleFlight } from "./singleflight.js";
|
|
27
|
-
import { mergeCandidates } from "./pipeline/candidates.js";
|
|
28
|
+
import { mergeCandidates, provenanceOf } from "./pipeline/candidates.js";
|
|
29
|
+
import { guaranteeSeats } from "./pipeline/confidence.js";
|
|
28
30
|
import { fuseCandidates } from "./pipeline/fusion.js";
|
|
31
|
+
function originExtra(origin) {
|
|
32
|
+
return origin.via || origin.tag || origin.confidence !== undefined ? { origin } : {};
|
|
33
|
+
}
|
|
34
|
+
function originFromExtra(extra) {
|
|
35
|
+
if (!extra)
|
|
36
|
+
return {};
|
|
37
|
+
try {
|
|
38
|
+
const origin = JSON.parse(extra).origin;
|
|
39
|
+
return origin && typeof origin === 'object'
|
|
40
|
+
? { ...typeof origin.via === 'string' ? { via: origin.via } : {}, ...typeof origin.tag === 'string' ? { tag: origin.tag } : {}, ...typeof origin.confidence === 'number' ? { confidence: origin.confidence } : {} }
|
|
41
|
+
: {};
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
29
47
|
export class SearchRouter {
|
|
30
48
|
ctx;
|
|
31
49
|
config;
|
|
@@ -45,6 +63,8 @@ export class SearchRouter {
|
|
|
45
63
|
/** User-defined CLI adapters (settings `cliAdapters`) this router registered as `custom-cli:<id>` platforms, with the diagnostics of the entries it ignored. */
|
|
46
64
|
customCli = new Map();
|
|
47
65
|
cliAdapterDiagnostics = [];
|
|
66
|
+
/** Confidence of each registered custom CLI by route id (its spec's, default 0.5), rebuilt with the registrations. */
|
|
67
|
+
customConfidence = new Map();
|
|
48
68
|
/** Latest local probe per route id (read by providerStatuses for the credential dimension). */
|
|
49
69
|
readiness = new Map();
|
|
50
70
|
/** Last real call per route id: feeds the health dimension (never inferred from a local probe). */
|
|
@@ -112,6 +132,7 @@ export class SearchRouter {
|
|
|
112
132
|
syncCustomCliAdapters() {
|
|
113
133
|
const { specs, diagnostics } = resolveCliAdapters(this.dynamic().cliAdapters);
|
|
114
134
|
this.cliAdapterDiagnostics = diagnostics;
|
|
135
|
+
this.customConfidence = new Map([...specs].map(([id, spec]) => [customCliProviderId(id), spec.confidence ?? DEFAULT_CUSTOM_CONFIDENCE]));
|
|
115
136
|
const next = new Map([...specs].map(([id, spec]) => [id, JSON.stringify(spec)]));
|
|
116
137
|
for (const [id, entry] of [...this.customCli])
|
|
117
138
|
if (next.get(id) !== entry.sig) {
|
|
@@ -133,7 +154,7 @@ export class SearchRouter {
|
|
|
133
154
|
cliAdapterProblems() {
|
|
134
155
|
this.syncCustomPlatforms();
|
|
135
156
|
const cfg = this.dynamic();
|
|
136
|
-
return [...this.cliAdapterDiagnostics, ...[...this.customCli.values()].flatMap(entry => (entry.problem ? [entry.problem] : [])), ...platformBackendIssues(cfg.platformBackends, cfg.cliAdapters)];
|
|
157
|
+
return [...this.cliAdapterDiagnostics, ...[...this.customCli.values()].flatMap(entry => (entry.problem ? [entry.problem] : [])), ...customCliPlatformIssues(cfg.cliAdapters), ...platformBackendIssues(cfg.platformBackends, cfg.cliAdapters)];
|
|
137
158
|
}
|
|
138
159
|
/** Custom platforms the registry could not take (key clash, bad key), for `sources.status`. */
|
|
139
160
|
customPlatformProblems() {
|
|
@@ -192,7 +213,9 @@ export class SearchRouter {
|
|
|
192
213
|
const outcome = await engine.search(input.query, input.count, input.signal, this.withBindings(id, input.options));
|
|
193
214
|
ticket?.settle(1, 'request counted by the router (the adapter booked none)');
|
|
194
215
|
this.outcomes.set(id, { ok: true, at: new Date().toISOString() });
|
|
195
|
-
|
|
216
|
+
// The source's confidence rides with every row it returned (only when below 1: the built-in sources add nothing).
|
|
217
|
+
const confidence = this.confidenceOf(id, outcome.backend);
|
|
218
|
+
return { ...outcome, via: outcome.via ?? engine.id, ...confidence < 1 ? { sources: outcome.sources.map(source => ({ ...source, confidence })) } : {} };
|
|
196
219
|
}
|
|
197
220
|
catch (error) {
|
|
198
221
|
const code = error?.code;
|
|
@@ -255,17 +278,53 @@ export class SearchRouter {
|
|
|
255
278
|
return { deps: await this.deps(false), config: this.dynamic(), ...cli ? { cli } : {} };
|
|
256
279
|
}
|
|
257
280
|
/**
|
|
258
|
-
* The configured `engines` list with the user's `sources.*`
|
|
259
|
-
*
|
|
281
|
+
* The default engine order for a search that names no `engines`: the configured `engines` list with the user's `sources.*`
|
|
282
|
+
* preferences applied, then the default rule for "常用" (common) sources.
|
|
283
|
+
* 1. an explicit `engines` of a call never comes through here;
|
|
284
|
+
* 2. `sources.disabled` ids are removed, `sources.priority` ids that are in the list move to the front in their listed order;
|
|
285
|
+
* 3. a common source (DeepSeek Search) whose key resolves leads what is left, while `engines` is still the default list (a
|
|
286
|
+
* list the user wrote is theirs: it keeps its order, and a common source in it keeps the position given). `sources.disabled`
|
|
287
|
+
* and `evidence.sourcePolicy: anonymous-only` switch it off.
|
|
260
288
|
*/
|
|
261
|
-
preferred(ids) {
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
289
|
+
async preferred(ids) {
|
|
290
|
+
const cfg = this.dynamic();
|
|
291
|
+
const src = cfg.sources;
|
|
292
|
+
return effectiveChain({
|
|
293
|
+
engines: ids,
|
|
294
|
+
priority: this.canonicalIds(src?.priority ?? []),
|
|
295
|
+
disabled: this.canonicalIds(src?.disabled ?? []),
|
|
296
|
+
anonymousOnly: cfg.evidence?.sourcePolicy === 'anonymous-only',
|
|
297
|
+
commonReady: await this.commonReady(),
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/** Route ids of the common ("常用") sources that are ready to run now (key resolved), best `priority` first. */
|
|
301
|
+
async commonReady() {
|
|
302
|
+
const common = this.registry.list({ operation: 'search' }).filter(a => a.descriptor.common && a.descriptor.kind !== 'platform');
|
|
303
|
+
if (!common.length)
|
|
304
|
+
return [];
|
|
305
|
+
const env = await this.probeEnv();
|
|
306
|
+
const out = [];
|
|
307
|
+
for (const adapter of common) {
|
|
308
|
+
try {
|
|
309
|
+
const readiness = await adapter.probeLocal(env);
|
|
310
|
+
if (readiness.available && readiness.credential === 'configured')
|
|
311
|
+
out.push({ id: routeIdOf(adapter.descriptor), priority: adapter.descriptor.priority ?? 100 });
|
|
312
|
+
}
|
|
313
|
+
catch { /* a probe that throws is not ready */ }
|
|
314
|
+
}
|
|
315
|
+
return out.sort((a, b) => a.priority - b.priority).map(x => x.id);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Key and endpoint of the DeepSeek Fetch API for the fetch pipeline, or undefined when no key resolves (settings literal ->
|
|
319
|
+
* DSH credentials ref -> process environment, the same order as the search side). Resolved per call; the key is never cached.
|
|
320
|
+
*/
|
|
321
|
+
async deepseekAccess() {
|
|
322
|
+
const cfg = this.dynamic();
|
|
323
|
+
const { sourceKeys, sourceBaseUrls } = await this.keyedSources(cfg, (ref, literal) => this.resolveKey(ref, literal));
|
|
324
|
+
const apiKey = sourceKeys?.deepseek;
|
|
325
|
+
if (!apiKey)
|
|
326
|
+
return undefined;
|
|
327
|
+
return { apiKey, ...sourceBaseUrls?.deepseek ? { baseUrl: sourceBaseUrls.deepseek } : {}, allowProxyFakeIp: cfg.allowProxyFakeIp, usage: this.usageRecorder() };
|
|
269
328
|
}
|
|
270
329
|
/** Alias / full id -> route id; ids the registry does not know are kept as written (the backend then reports them unknown). */
|
|
271
330
|
canonicalIds(ids) {
|
|
@@ -345,7 +404,7 @@ export class SearchRouter {
|
|
|
345
404
|
try {
|
|
346
405
|
const selected = await this.backends.runSelected({ query: call.query, count: call.count, signal: call.signal, skipSeam: opts.skipSeam ?? false, ...call.options ? { options: call.options } : {} }, { preferred: this.canonicalIds([call.id]), signal: call.signal });
|
|
347
406
|
const sources = selected.value.sources;
|
|
348
|
-
return sources.length ? { state: 'ok', sources, ...selected.value.backend ? { backend: selected.value.backend } : {} } : { state: 'empty' };
|
|
407
|
+
return sources.length ? { state: 'ok', sources, ...selected.value.backend ? { backend: selected.value.backend } : {}, ...selected.value.notes?.length ? { notes: selected.value.notes } : {} } : { state: 'empty' };
|
|
349
408
|
}
|
|
350
409
|
catch (error) {
|
|
351
410
|
if (call.signal.aborted)
|
|
@@ -363,6 +422,33 @@ export class SearchRouter {
|
|
|
363
422
|
return { state: 'error', message: error instanceof Error ? error.message : String(error) };
|
|
364
423
|
}
|
|
365
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* The credential variables of the CLI adapters under the names the tools read, each resolved like the plugin's other secrets:
|
|
427
|
+
* settings literal -> DSH credentials ref (`twitterAuthTokenEnv`) -> process environment. Values only ever reach a command's environment.
|
|
428
|
+
*/
|
|
429
|
+
async cliEnv() {
|
|
430
|
+
const cfg = this.dynamic();
|
|
431
|
+
const out = {};
|
|
432
|
+
const authToken = await this.resolveKey(cfg.twitterAuthTokenEnv ?? 'TWITTER_AUTH_TOKEN', cfg.twitterAuthToken);
|
|
433
|
+
const ct0 = await this.resolveKey(cfg.twitterCt0Env ?? 'TWITTER_CT0', cfg.twitterCt0);
|
|
434
|
+
if (authToken)
|
|
435
|
+
out.TWITTER_AUTH_TOKEN = authToken;
|
|
436
|
+
if (ct0)
|
|
437
|
+
out.TWITTER_CT0 = ct0;
|
|
438
|
+
return out;
|
|
439
|
+
}
|
|
440
|
+
/** Sync twin of {@link cliEnv} for `available()` checks: settings literal and process environment only. */
|
|
441
|
+
cliEnvSync() {
|
|
442
|
+
const cfg = this.dynamic();
|
|
443
|
+
const out = {};
|
|
444
|
+
const authToken = cfg.twitterAuthToken || process.env[cfg.twitterAuthTokenEnv ?? 'TWITTER_AUTH_TOKEN'];
|
|
445
|
+
const ct0 = cfg.twitterCt0 || process.env[cfg.twitterCt0Env ?? 'TWITTER_CT0'];
|
|
446
|
+
if (authToken)
|
|
447
|
+
out.TWITTER_AUTH_TOKEN = authToken;
|
|
448
|
+
if (ct0)
|
|
449
|
+
out.TWITTER_CT0 = ct0;
|
|
450
|
+
return out;
|
|
451
|
+
}
|
|
366
452
|
/** Resolve a key through credentials first, then process env. */
|
|
367
453
|
async resolveKey(ref, literal) {
|
|
368
454
|
if (literal && literal.length > 0)
|
|
@@ -392,8 +478,10 @@ export class SearchRouter {
|
|
|
392
478
|
const semanticScholarApiKey = await this.resolveKey(SEMANTICSCHOLAR_KEY_ENV);
|
|
393
479
|
const anysearchApiKey = await this.resolveKey(ANYSEARCH_KEY_ENV);
|
|
394
480
|
const keyed = await this.keyedSources(cfg, (ref, literal) => this.resolveKey(ref, literal));
|
|
481
|
+
const cliEnv = await this.cliEnv();
|
|
395
482
|
return {
|
|
396
483
|
...keyed,
|
|
484
|
+
...Object.keys(cliEnv).length ? { cliEnv } : {},
|
|
397
485
|
...openalexApiKey ? { openalexApiKey } : {},
|
|
398
486
|
...semanticScholarApiKey ? { semanticScholarApiKey } : {},
|
|
399
487
|
...anysearchApiKey ? { anysearchApiKey } : {},
|
|
@@ -430,8 +518,10 @@ export class SearchRouter {
|
|
|
430
518
|
const semanticScholarApiKey = process.env[SEMANTICSCHOLAR_KEY_ENV];
|
|
431
519
|
const anysearchApiKey = process.env[ANYSEARCH_KEY_ENV];
|
|
432
520
|
const keyed = this.keyedSourcesSync(cfg);
|
|
521
|
+
const cliEnv = this.cliEnvSync();
|
|
433
522
|
return {
|
|
434
523
|
...keyed,
|
|
524
|
+
...Object.keys(cliEnv).length ? { cliEnv } : {},
|
|
435
525
|
...openalexApiKey ? { openalexApiKey } : {},
|
|
436
526
|
...semanticScholarApiKey ? { semanticScholarApiKey } : {},
|
|
437
527
|
...anysearchApiKey ? { anysearchApiKey } : {},
|
|
@@ -512,8 +602,31 @@ export class SearchRouter {
|
|
|
512
602
|
}
|
|
513
603
|
/** Problems of the `sources.*` settings (unknown ids, bad numbers), for `sources.status`. */
|
|
514
604
|
sourceDiagnostics() {
|
|
605
|
+
this.syncCustomPlatforms();
|
|
515
606
|
const src = this.dynamic().sources;
|
|
516
|
-
return resolveSources({ priority: src?.priority, disabled: src?.disabled, budget: src?.budget }, id => this.registry.routeId(id) !== undefined).diagnostics;
|
|
607
|
+
return resolveSources({ priority: src?.priority, disabled: src?.disabled, budget: src?.budget, confidence: src?.confidence }, id => this.registry.routeId(id) !== undefined, isBackendId).diagnostics;
|
|
608
|
+
}
|
|
609
|
+
/** The confidence of one platform backend as a leg of a chain (`xhs`, `custom-cli:echo`): its own, without the provider's. */
|
|
610
|
+
backendConfidenceOf(id) {
|
|
611
|
+
return this.confidenceOf(id);
|
|
612
|
+
}
|
|
613
|
+
/** `sources.confidence` by canonical id (a provider's route id; a platform backend id as written), valid entries only. */
|
|
614
|
+
confidenceOverrides() {
|
|
615
|
+
const resolved = resolveSources({ confidence: this.dynamic().sources?.confidence }, id => this.registry.routeId(id) !== undefined, isBackendId);
|
|
616
|
+
return new Map(Object.entries(resolved.confidence).map(([id, value]) => [this.registry.routeId(id) ?? id, value]));
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* The confidence (0..1) of what `route` returned, through `backend` when it is a platform chain: `sources.confidence` of the
|
|
620
|
+
* provider times that of the backend that answered, each defaulting to the custom CLI's own (spec `confidence`, 0.5) and to 1
|
|
621
|
+
* for every built-in source, so the built-in ones are 1 unless the user set something.
|
|
622
|
+
*/
|
|
623
|
+
confidenceOf(route, backend) {
|
|
624
|
+
this.syncCustomPlatforms();
|
|
625
|
+
const overrides = this.confidenceOverrides();
|
|
626
|
+
const own = (id) => overrides.get(id) ?? this.customConfidence.get(id) ?? 1;
|
|
627
|
+
const provider = this.registry.routeId(route) ?? route;
|
|
628
|
+
const via = backend === undefined || backend === provider ? undefined : this.registry.routeId(backend) ?? backend;
|
|
629
|
+
return Math.round(own(provider) * (via === undefined ? 1 : own(via)) * 10_000) / 10_000;
|
|
517
630
|
}
|
|
518
631
|
/** Counts a metered, non-model request (Bocha search) in the usage ledger; best effort, never throws into the search. */
|
|
519
632
|
usageRecorder() {
|
|
@@ -584,7 +697,7 @@ export class SearchRouter {
|
|
|
584
697
|
if (adapter.chain) {
|
|
585
698
|
try {
|
|
586
699
|
chainReport = await adapter.chain(env);
|
|
587
|
-
chain = chainReport.entries;
|
|
700
|
+
chain = chainReport.entries.map(entry => ({ ...entry, confidence: this.backendConfidenceOf(entry.id) }));
|
|
588
701
|
}
|
|
589
702
|
catch {
|
|
590
703
|
chain = undefined;
|
|
@@ -596,6 +709,8 @@ export class SearchRouter {
|
|
|
596
709
|
...d.sourceFamily ? { sourceFamily: d.sourceFamily } : {},
|
|
597
710
|
requirements: d.requirements.map(({ env, ...r }) => ({ ...r, ...env ? { env: [...env] } : {} })), supportedFilters: [...d.supportedFilters], costModel: { ...d.costModel }, costTier: local.costTier ?? costTierOf(d),
|
|
598
711
|
...d.verification?.live ? {} : { unverified: true },
|
|
712
|
+
...d.common ? { common: true } : {},
|
|
713
|
+
confidence: this.confidenceOf(route),
|
|
599
714
|
...chain ? { chain } : {},
|
|
600
715
|
...this.requestBudgetOf(route) ? { budget: this.requestBudgetOf(route) } : {},
|
|
601
716
|
readiness: {
|
|
@@ -623,7 +738,7 @@ export class SearchRouter {
|
|
|
623
738
|
const query = platform ? platform.query : opts.query.trim();
|
|
624
739
|
if (!platform && !query)
|
|
625
740
|
throw new Error('query must be a non-empty string');
|
|
626
|
-
const ids = platform ? [platform.id] : opts.engines && opts.engines.length ? this.canonicalIds(opts.engines) : this.preferred(this.canonicalIds(cfg.engines));
|
|
741
|
+
const ids = platform ? [platform.id] : opts.engines && opts.engines.length ? this.canonicalIds(opts.engines) : await this.preferred(this.canonicalIds(cfg.engines));
|
|
627
742
|
const nq = normQuery(platform ? query || platform.url || platform.id : query);
|
|
628
743
|
const count = Math.min(Math.max(opts.count, 1), 20);
|
|
629
744
|
const multi = !platform && opts.multi && ids.length > 1;
|
|
@@ -676,7 +791,7 @@ export class SearchRouter {
|
|
|
676
791
|
if (detail?.requestedCount === undefined || detail.requestedCount >= count) {
|
|
677
792
|
const result = {
|
|
678
793
|
...detail?.content ? { content: detail.content } : {},
|
|
679
|
-
sources: shapeSources(cached.rows.map(r => ({ url: r.url, title: r.title, snippet: r.snippet, publishedAt: r.published })), count),
|
|
794
|
+
sources: shapeSources(cached.rows.map(r => ({ url: r.url, title: r.title, snippet: r.snippet, publishedAt: r.published, ...originFromExtra(r.extra) })), count),
|
|
680
795
|
engine: detail?.engine ?? ids[0] ?? 'unknown',
|
|
681
796
|
enginesTried: detail?.enginesTried ?? ids,
|
|
682
797
|
fromCache: true,
|
|
@@ -724,18 +839,19 @@ export class SearchRouter {
|
|
|
724
839
|
throw new Error('all engines failed: ' + failures);
|
|
725
840
|
}
|
|
726
841
|
const merged = mergeCandidates(outputs);
|
|
727
|
-
|
|
842
|
+
// A source with a confidence below 1 weighs a little less in the fusion, and its best result keeps a place in the list (confidence.ts).
|
|
843
|
+
const ranked = guaranteeSeats(fuseCandidates(merged, {
|
|
728
844
|
k: cfg.rrfConstant,
|
|
729
845
|
freshnessBoost: cfg.freshnessBoost,
|
|
730
846
|
freshnessDays: cfg.freshnessDays,
|
|
731
847
|
authorityBoost: cfg.authorityBoost,
|
|
732
848
|
authorityDomains: cfg.authorityDomains,
|
|
733
849
|
nProviders: outputs.length,
|
|
734
|
-
}).slice(0, count);
|
|
850
|
+
}), count, ranked => ranked.candidate.contributions).slice(0, count);
|
|
735
851
|
availableCount = merged.length;
|
|
736
|
-
outcome = { sources: ranked.map(({ candidate }) => ({ url: candidate.url, ...candidate.title ? { title: candidate.title } : {}, ...candidate.snippet ? { snippet: candidate.snippet } : {}, ...candidate.publishedAt ? { publishedAt: candidate.publishedAt } : {} })) };
|
|
737
|
-
// Per-source provenance survives in results.extra (no schema change);
|
|
738
|
-
persistExtras = ranked.map(({ candidate, score }) => JSON.stringify({ contributions: candidate.contributions, score: Number(score.toFixed(6)) }));
|
|
852
|
+
outcome = { sources: ranked.map(({ candidate }) => ({ url: candidate.url, ...candidate.title ? { title: candidate.title } : {}, ...candidate.snippet ? { snippet: candidate.snippet } : {}, ...candidate.publishedAt ? { publishedAt: candidate.publishedAt } : {}, ...provenanceOf(candidate) })) };
|
|
853
|
+
// Per-source provenance survives in results.extra (no schema change); a cache hit reads back the origin (`via`, `tag`, `confidence`) from it.
|
|
854
|
+
persistExtras = ranked.map(({ candidate, score }) => JSON.stringify({ contributions: candidate.contributions, score: Number(score.toFixed(6)), ...originExtra(provenanceOf(candidate)) }));
|
|
739
855
|
usedId = 'multi(' + ids.join('+') + ')';
|
|
740
856
|
}
|
|
741
857
|
else {
|
|
@@ -800,7 +916,10 @@ export class SearchRouter {
|
|
|
800
916
|
status: 'ok',
|
|
801
917
|
cacheKey,
|
|
802
918
|
detail: JSON.stringify({ ...finalOutcome.content ? { content: finalOutcome.content } : {}, engine: finalId, ...backendId ? { backend: backendId } : {}, enginesTried, requestedCount: count, ...fallbackNote ? { fallbackNote } : {} }),
|
|
803
|
-
},
|
|
919
|
+
}, finalOutcome.sources.map((source, i) => {
|
|
920
|
+
const extra = persistExtras ? persistExtras[i] : JSON.stringify(originExtra({ ...source.via ? { via: source.via } : {}, ...source.tag ? { tag: source.tag } : {}, ...source.confidence !== undefined ? { confidence: source.confidence } : {} }));
|
|
921
|
+
return extra === '{}' ? source : { ...source, extra };
|
|
922
|
+
}), platform ? 'platform-' + platform.id : finalId));
|
|
804
923
|
const result = {
|
|
805
924
|
...outcome.content ? { content: outcome.content } : {},
|
|
806
925
|
sources: shapeSources(outcome.sources, count),
|