@dsh-plus/web-search-services 0.1.19 → 0.2.0

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/index.d.ts CHANGED
@@ -1,102 +1,29 @@
1
1
  import { UnwrapVolatile } from "@dsh-plus/shared";
2
- import { WebSearchProvider, WebSearchRequest, WebSearchResult } from "@deepseek-ai/dsh-web";
3
- import { spawn } from "node:child_process";
2
+ import { SEARCH_ENTRY_PROVIDER_PREFIX as ENTRY_PROVIDER_PREFIX, SEARCH_PROVIDER_ID as PROVIDER_ID, SearchEntry, searchEntryAvailable } from "@dsh-plus/web-providers-core";
4
3
  import z from "@deepseek-ai/schemastery";
5
4
  import { Context } from "@deepseek-ai/cordis";
6
5
  //#region src/config.d.ts
7
6
  declare const SETTINGS_NS = "dsh-plus-web-search-services";
8
7
  declare const Config: z<Schemastery.ObjectS<NoInfer<{
9
- scriptPath: z<string, string, "volatile-defined">;
10
- envFile: z<string, string, "volatile-defined">;
11
- python: z<string, string, "volatile-defined">;
12
- priority: z<NoInfer<("exa" | "openai-chat" | "tavily")[]>, NoInfer<("exa" | "openai-chat" | "tavily")[]>, "volatile-defined">;
13
- timeoutMs: z<number, number, "volatile-defined">;
14
- keys: z<NoInfer<Schemastery.ObjectS<NoInfer<{
15
- tavily: z<string, string, "defined">;
16
- exa: z<string, string, "defined">;
17
- openaiApiKey: z<string, string, "defined">;
18
- openaiBaseUrl: z<string, string, "defined">;
19
- openaiModel: z<string, string, "defined">;
20
- }>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
21
- tavily: z<string, string, "defined">;
22
- exa: z<string, string, "defined">;
23
- openaiApiKey: z<string, string, "defined">;
24
- openaiBaseUrl: z<string, string, "defined">;
25
- openaiModel: z<string, string, "defined">;
26
- }>>>, "volatile-defined">;
8
+ enabled: z<boolean, boolean, "volatile-defined">;
9
+ exposeEntries: z<boolean, boolean, "volatile-defined">;
10
+ proxy: z<string, string, "volatile-defined">;
11
+ entries: z<NoInfer<import("@dsh-plus/web-providers-core").SearchEntry[]>, NoInfer<import("@dsh-plus/web-providers-core").SearchEntry[]>, "volatile-defined">;
27
12
  }>>, Schemastery.ObjectT<NoInfer<{
28
- scriptPath: z<string, string, "volatile-defined">;
29
- envFile: z<string, string, "volatile-defined">;
30
- python: z<string, string, "volatile-defined">;
31
- priority: z<NoInfer<("exa" | "openai-chat" | "tavily")[]>, NoInfer<("exa" | "openai-chat" | "tavily")[]>, "volatile-defined">;
32
- timeoutMs: z<number, number, "volatile-defined">;
33
- keys: z<NoInfer<Schemastery.ObjectS<NoInfer<{
34
- tavily: z<string, string, "defined">;
35
- exa: z<string, string, "defined">;
36
- openaiApiKey: z<string, string, "defined">;
37
- openaiBaseUrl: z<string, string, "defined">;
38
- openaiModel: z<string, string, "defined">;
39
- }>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
40
- tavily: z<string, string, "defined">;
41
- exa: z<string, string, "defined">;
42
- openaiApiKey: z<string, string, "defined">;
43
- openaiBaseUrl: z<string, string, "defined">;
44
- openaiModel: z<string, string, "defined">;
45
- }>>>, "volatile-defined">;
13
+ enabled: z<boolean, boolean, "volatile-defined">;
14
+ exposeEntries: z<boolean, boolean, "volatile-defined">;
15
+ proxy: z<string, string, "volatile-defined">;
16
+ entries: z<NoInfer<import("@dsh-plus/web-providers-core").SearchEntry[]>, NoInfer<import("@dsh-plus/web-providers-core").SearchEntry[]>, "volatile-defined">;
46
17
  }>>, "plain">;
47
18
  /** 活动字段形态(loader 解析产物:volatile 字段为活动引用)。 */
48
19
  type WebSearchServicesConfigFields = Schemastery.TypeT<typeof Config>;
49
20
  /** 平面配置形态(消费面的读取形态,由活动引用解包得到)。 */
50
21
  type WebSearchServicesConfig = UnwrapVolatile<WebSearchServicesConfigFields>;
51
22
  //#endregion
52
- //#region src/python.d.ts
53
- /** 注入的文件系统视图(测试在 Linux 上覆盖 win32 形态)。 */
54
- interface PythonFs {
55
- exists: (path: string) => boolean;
56
- /** 列目录一层;目录不存在/不可读返回空表。 */
57
- list: (path: string) => readonly {
58
- name: string;
59
- dir: boolean;
60
- }[];
61
- }
62
- interface PythonDiscoveryEnv {
63
- platform: NodeJS.Platform;
64
- pathValue: string | undefined;
65
- /** 桌面端捆绑运行时根;undefined = 无(跳过 BFS)。 */
66
- bundledRoot: string | undefined;
67
- fs: PythonFs;
68
- }
69
- //#endregion
70
- //#region src/runner.d.ts
71
- type SpawnFn = typeof spawn;
72
- //#endregion
73
- //#region src/provider.d.ts
74
- declare const PROVIDER_ID = "search-services";
75
- declare class SearchServicesProvider implements WebSearchProvider {
76
- readonly id = "search-services";
77
- private readonly current;
78
- private readonly spawnFn;
79
- private readonly discovery;
80
- /** 候选链按 `${python}|${bundledRoot}` 记忆:PATH 与捆绑布局在进程内静态。 */
81
- private readonly candidateCache;
82
- constructor(current: () => WebSearchServicesConfig, spawnFn?: SpawnFn | undefined, discovery?: (() => PythonDiscoveryEnv) | undefined);
83
- /** 解释器候选链(有序、记忆化)。 */
84
- private candidates;
85
- /**
86
- * 廉价本地检查:脚本存在 + 至少一个【已验证】解释器候选(配置/捆绑/PATH,
87
- * 未验证兜底名不算)+ 优先级内至少一个后端有 key;不做网络调用、不 spawn。
88
- */
89
- available(): boolean;
90
- search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
91
- private childEnv;
92
- private run;
93
- private normalize;
94
- }
95
- //#endregion
96
23
  //#region src/index.d.ts
97
24
  declare const name = "dsh-plus-web-search-services";
98
25
  /** 行级 inject:dsh-web 服务激活后才应用本行(provider 注册即需 ctx.web)。 */
99
26
  declare const inject: readonly ['web'];
100
27
  declare function apply(ctx: Context, config: WebSearchServicesConfig | WebSearchServicesConfigFields): void;
101
28
  //#endregion
102
- export { Config, PROVIDER_ID, SETTINGS_NS, SearchServicesProvider, apply, inject, name };
29
+ export { Config, ENTRY_PROVIDER_PREFIX, PROVIDER_ID, SETTINGS_NS, type SearchEntry, apply, inject, name, searchEntryAvailable };