pi-auto-web-search 0.1.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.
@@ -0,0 +1,148 @@
1
+ import type { ResolvedInstance } from "../config.ts";
2
+ import type { ProviderResponse, RequestSpec } from "../http.ts";
3
+ import type {
4
+ ExtractOutput,
5
+ ExtractParams,
6
+ MapOutput,
7
+ MapParams,
8
+ SearchAdapter,
9
+ SearchHit,
10
+ SearchOutput,
11
+ SearchParams,
12
+ SearchQuality,
13
+ } from "./types.ts";
14
+ import { asArray, asNumber, asRecord, asString, businessFailure, qualityDowngradeNote, sourceModeGapNote } from "./util.ts";
15
+
16
+ const MAX_RESULTS = 20;
17
+
18
+ /** Tavily 只有 basic 与 advanced 两档,deep 按 advanced 请求并在 notes 说明。 */
19
+ function depthOf(quality: SearchQuality): "basic" | "advanced" {
20
+ return quality === "basic" ? "basic" : "advanced";
21
+ }
22
+
23
+ function hitOf(value: unknown, params: SearchParams): SearchHit | undefined {
24
+ const item = asRecord(value);
25
+ if (!item) return undefined;
26
+ const url = asString(item.url);
27
+ if (!url) return undefined;
28
+
29
+ const snippet = asString(item.content);
30
+ const hit: SearchHit = { title: asString(item.title) ?? url, url };
31
+ if (snippet) hit.snippet = snippet;
32
+
33
+ if (params.contents === "markdown") {
34
+ const raw = asString(item.raw_content);
35
+ if (raw) hit.content = raw;
36
+ } else if (params.contents !== "none" && snippet) {
37
+ hit.content = snippet;
38
+ }
39
+
40
+ const date = asString(item.published_date);
41
+ if (date) hit.date = date;
42
+ const score = asNumber(item.score);
43
+ if (score !== undefined) hit.score = score;
44
+ return hit;
45
+ }
46
+
47
+ /** Tavily:Bearer 鉴权,search 与 extract 都是 POST;结果字段见官方 API 参考。 */
48
+ export const tavilyAdapter: SearchAdapter = {
49
+ preset: "tavily",
50
+ capabilities: { search: true, fetch: true, map: true },
51
+
52
+ unsupported(): string[] {
53
+ return [];
54
+ },
55
+
56
+ buildSearch(instance: ResolvedInstance, params: SearchParams): RequestSpec {
57
+ const body: Record<string, unknown> = {
58
+ query: params.query,
59
+ max_results: Math.min(params.limit, MAX_RESULTS),
60
+ include_answer: params.answer === true,
61
+ include_raw_content: params.contents === "markdown",
62
+ search_depth: depthOf(params.quality),
63
+ // 0 表示始终实时抓取;缓存年龄由插件固定,不开放给 agent。
64
+ max_age_hours: 0,
65
+ };
66
+ if (params.domains?.length) body.include_domains = params.domains;
67
+ // 官方 topic 默认 general,只有 news 需要显式发送。
68
+ if (params.topic === "news") body.topic = "news";
69
+ if (params.excludeDomains?.length) body.exclude_domains = params.excludeDomains;
70
+ if (params.freshness) body.time_range = params.freshness;
71
+ return { instance, path: "search", method: "POST", body };
72
+ },
73
+
74
+ checkSearch(response: ProviderResponse): void {
75
+ const data = asRecord(response.data);
76
+ if (!data || !Array.isArray(data.results)) {
77
+ throw businessFailure(response, "tavily 响应缺少 results");
78
+ }
79
+ },
80
+
81
+ mapSearch(response: ProviderResponse, params: SearchParams): SearchOutput {
82
+ const data = asRecord(response.data) ?? {};
83
+ const hits = asArray(data.results)
84
+ .map((item) => hitOf(item, params))
85
+ .filter((hit): hit is SearchHit => hit !== undefined);
86
+ const answer = asString(data.answer);
87
+ const notes = params.quality === "deep" ? [qualityDowngradeNote("tavily", "deep", "advanced")] : [];
88
+ if (params.sourceMode) notes.push(sourceModeGapNote("tavily", params.sourceMode));
89
+ // 官方 country 只接受国家全名枚举,alpha-2 无法直接映射,不发字段只说明降级。
90
+ if (params.country) {
91
+ notes.push(`tavily 的 country 只接受国家全名,country=${params.country} 已按供应商默认地区请求`);
92
+ }
93
+ return { hits, answer, notes, rateLimit: response.rateLimit };
94
+ },
95
+
96
+ buildExtract(instance: ResolvedInstance, params: ExtractParams): RequestSpec {
97
+ const body: Record<string, unknown> = { urls: [params.url] };
98
+ if (params.format === "text") body.format = "text";
99
+ return { instance, path: "extract", method: "POST", body };
100
+ },
101
+
102
+ checkExtract(response: ProviderResponse): void {
103
+ const data = asRecord(response.data);
104
+ if (!data) throw businessFailure(response, "tavily 响应格式无法解析");
105
+
106
+ const failed = asArray(data.failed_results);
107
+ if (failed.length > 0) {
108
+ const first = asRecord(failed[0]);
109
+ const url = asString(first?.url) ?? "目标地址";
110
+ const reason = asString(first?.error) ?? "未知原因";
111
+ throw businessFailure(response, `tavily 提取失败:${url}(${reason})`, "network");
112
+ }
113
+ const raw = asString(asRecord(asArray(data.results)[0])?.raw_content);
114
+ if (!raw) throw businessFailure(response, "tavily 提取未返回正文", "network");
115
+ },
116
+
117
+ mapExtract(response: ProviderResponse): ExtractOutput {
118
+ const data = asRecord(response.data) ?? {};
119
+ const content = asString(asRecord(asArray(data.results)[0])?.raw_content) ?? "";
120
+ return { content };
121
+ },
122
+
123
+ unsupportedExtract(params) {
124
+ return params.format === "markdown" || params.format === "text" ? [] : [params.format];
125
+ },
126
+
127
+ buildMap(instance: ResolvedInstance, params: MapParams): RequestSpec {
128
+ const body: Record<string, unknown> = { url: params.url, limit: params.limit };
129
+ if (params.instructions) body.instructions = params.instructions;
130
+ return { instance, path: "map", method: "POST", body, kind: "crawl" };
131
+ },
132
+
133
+ checkMap(response: ProviderResponse): void {
134
+ const data = asRecord(response.data);
135
+ if (!data || !Array.isArray(data.results)) {
136
+ throw businessFailure(response, "tavily 响应缺少 results");
137
+ }
138
+ },
139
+
140
+ mapSite(response: ProviderResponse): MapOutput {
141
+ const data = asRecord(response.data) ?? {};
142
+ const links = asArray(data.results)
143
+ .map((item) => asString(item))
144
+ .filter((url): url is string => url !== undefined)
145
+ .map((url) => ({ url }));
146
+ return { links };
147
+ },
148
+ };
@@ -0,0 +1,172 @@
1
+ import type { ErrorClass, ResolvedInstance } from "../config.ts";
2
+ import { ProviderError, type ProviderResponse, type RequestSpec } from "../http.ts";
3
+ import type {
4
+ ExtractOutput,
5
+ SearchAdapter,
6
+ SearchHit,
7
+ SearchOutput,
8
+ SearchParams,
9
+ SourceMode,
10
+ } from "./types.ts";
11
+ import { asArray, asNumber, asRecord, asString, businessFailure, countryGapNote, qualityGapNote, rejectNoMap, rejectUnsupported } from "./util.ts";
12
+
13
+ /** SearchPro 只按 10/20 条档位返回,超出 10 条的一律请求 20 条。 */
14
+ const CNT_TIERS = [10, 20] as const;
15
+
16
+ const MAX_EXCLUDE_DOMAINS = 5;
17
+
18
+ /** 信源范围映射官方 Mode:0 公开网页,1 优质权威垂直结果,2 混合结果。 */
19
+ const SOURCE_MODE_VALUES: Record<SourceMode, number> = { public: 0, authoritative: 1, mixed: 2 };
20
+
21
+ /** 不传 sourceMode 时保持官方的公开网页结果。 */
22
+ const DEFAULT_MODE = SOURCE_MODE_VALUES.public;
23
+
24
+ const FRESHNESS_CODES = { day: "d1", week: "d7", month: "m1", year: "y1" } as const;
25
+
26
+ const NO_FETCH = "tencent 只有 SearchPro 搜索接口";
27
+
28
+ /** 搜索词之外的入参都有硬限制,越界的参数直接让实例被跳过。 */
29
+ function unsupportedParams(params: SearchParams): string[] {
30
+ const names: string[] = [];
31
+ const domains = params.domains ?? [];
32
+ const excluded = params.excludeDomains ?? [];
33
+ if (domains.length > 1) names.push("多个 domains");
34
+ if (domains.length > 0 && excluded.length > 0) names.push("domains 与 excludeDomains 同时使用");
35
+ if (excluded.length > MAX_EXCLUDE_DOMAINS) names.push(`超过 ${MAX_EXCLUDE_DOMAINS} 个 excludeDomains`);
36
+ if (params.answer) names.push("answer");
37
+ if (params.contents === "markdown") names.push("contents=markdown");
38
+ return names;
39
+ }
40
+
41
+ function cntOf(limit: number): number {
42
+ return limit > CNT_TIERS[0] ? CNT_TIERS[1] : CNT_TIERS[0];
43
+ }
44
+
45
+ function siteOf(params: SearchParams): string | undefined {
46
+ if (params.domains?.length) return params.domains[0];
47
+ if (params.excludeDomains?.length) return `exclude:${params.excludeDomains.join("|")}`;
48
+ return undefined;
49
+ }
50
+
51
+ /** 腾讯云业务错误码到重试分类的映射。 */
52
+ function errorClassOf(code: string): ErrorClass {
53
+ if (code === "RequestLimitExceeded") return "rateLimit";
54
+ if (code === "UnauthorizedOperation" || code === "ResourceNotFound" || code.startsWith("AuthFailure")) return "auth";
55
+ if (code === "ResourceUnavailable") return "quota";
56
+ if (code.startsWith("InternalError")) return "server";
57
+ return "invalidRequest";
58
+ }
59
+
60
+ /** 响应信封:Response.Error 与只有 Msg 的异常状态都在这里抛 ProviderError。 */
61
+ function envelope(response: ProviderResponse): Record<string, unknown> {
62
+ const body = asRecord(response.data);
63
+ const data = body ? asRecord(body.Response) : undefined;
64
+ if (!data) throw businessFailure(response, "tencent 响应缺少 Response");
65
+
66
+ const error = asRecord(data.Error);
67
+ if (error) {
68
+ const code = asString(error.Code) ?? "未知错误码";
69
+ const message = asString(error.Message) ?? "未知错误";
70
+ throw businessFailure(response, `tencent 返回 ${code}:${message}`, errorClassOf(code));
71
+ }
72
+
73
+ if (!Array.isArray(data.Pages)) {
74
+ const message = asString(data.Msg);
75
+ throw businessFailure(response, message ? `tencent 返回:${message}` : "tencent 响应缺少 Pages");
76
+ }
77
+ return data;
78
+ }
79
+
80
+ /** Pages 的每一项是一段 JSON 字符串;解析不了的条目跳过,不算整体失败。 */
81
+ function hitOf(value: unknown, params: SearchParams): SearchHit | undefined {
82
+ const text = asString(value);
83
+ if (!text) return undefined;
84
+ let parsed: unknown;
85
+ try {
86
+ parsed = JSON.parse(text);
87
+ } catch {
88
+ return undefined;
89
+ }
90
+
91
+ const item = asRecord(parsed);
92
+ if (!item) return undefined;
93
+ const url = asString(item.url);
94
+ if (!url) return undefined;
95
+
96
+ const hit: SearchHit = { title: asString(item.title) ?? url, url };
97
+ const passage = asString(item.passage);
98
+ if (passage) hit.snippet = passage;
99
+ const content = params.contents === "none" ? undefined : asString(item.content);
100
+ if (content) hit.content = content;
101
+ const date = asString(item.date);
102
+ if (date) hit.date = date;
103
+ const score = asNumber(item.score);
104
+ if (score !== undefined) hit.score = score;
105
+ return hit;
106
+ }
107
+
108
+ /** 腾讯云元宝搜索:使用服务 API KEY(Bearer)调用 SearchPro,只提供搜索。 */
109
+ export const tencentAdapter: SearchAdapter = {
110
+ preset: "tencent",
111
+ capabilities: { search: true, fetch: false, map: false },
112
+
113
+ unsupported: unsupportedParams,
114
+
115
+ buildSearch(instance: ResolvedInstance, params: SearchParams): RequestSpec {
116
+ rejectUnsupported(instance, "tencent", unsupportedParams(params));
117
+
118
+ const body: Record<string, unknown> = {
119
+ Query: params.query,
120
+ Cnt: cntOf(params.limit),
121
+ Mode: params.sourceMode === undefined ? DEFAULT_MODE : SOURCE_MODE_VALUES[params.sourceMode],
122
+ };
123
+ // 官方 Industry 支持 gov/news/acad/finance,这里只映射 news。
124
+ if (params.topic === "news") body.Industry = "news";
125
+ const site = siteOf(params);
126
+ if (site) body.Site = site;
127
+ if (params.freshness) body.Freshness = FRESHNESS_CODES[params.freshness];
128
+ if (params.contents === "summary") body.Switch = "open_summary";
129
+ return {
130
+ instance,
131
+ path: "search",
132
+ method: "POST",
133
+ body,
134
+ };
135
+ },
136
+
137
+ checkSearch(response: ProviderResponse): void {
138
+ envelope(response);
139
+ },
140
+
141
+ mapSearch(response: ProviderResponse, params: SearchParams): SearchOutput {
142
+ const data = envelope(response);
143
+ const hits = asArray(data.Pages)
144
+ .map((item) => hitOf(item, params))
145
+ .filter((hit): hit is SearchHit => hit !== undefined);
146
+
147
+ const cnt = cntOf(params.limit);
148
+ const notes: string[] = [];
149
+ if (params.limit < cnt) notes.push(`tencent 每次按 ${cnt} 条档位返回,已按 ${params.limit} 条裁剪`);
150
+ const gap = qualityGapNote("tencent", params.quality);
151
+ if (gap) notes.push(gap);
152
+ const countryGap = countryGapNote("tencent", params.country);
153
+ if (countryGap) notes.push(countryGap);
154
+ return { hits, notes, rateLimit: response.rateLimit };
155
+ },
156
+
157
+ buildExtract(instance: ResolvedInstance): RequestSpec {
158
+ throw new ProviderError({ instance: instance.id, code: "invalidRequest", message: NO_FETCH });
159
+ },
160
+
161
+ mapExtract(): ExtractOutput {
162
+ throw new ProviderError({ instance: "tencent", code: "invalidRequest", message: NO_FETCH });
163
+ },
164
+
165
+ buildMap(instance) {
166
+ rejectNoMap(instance.id, "tencent");
167
+ },
168
+
169
+ mapSite() {
170
+ rejectNoMap("tencent", "tencent");
171
+ },
172
+ };
@@ -0,0 +1,122 @@
1
+ import type { ResolvedInstance } from "../config.ts";
2
+ import type { ProviderResponse, RateLimitInfo, RequestSpec } from "../http.ts";
3
+ import type { PresetId } from "../presets.ts";
4
+
5
+ export type Freshness = "day" | "week" | "month" | "year";
6
+
7
+ export type ContentsMode = "none" | "summary" | "markdown";
8
+
9
+ /** 统一质量档位;各适配器映射到供应商自己的深度字段。 */
10
+ export type SearchQuality = "basic" | "advanced" | "deep";
11
+
12
+ export const SEARCH_QUALITIES: readonly SearchQuality[] = ["basic", "advanced", "deep"];
13
+
14
+ /** 统一信源范围;腾讯对应官方 Mode 0/1/2,与搜索深度无关。 */
15
+ export type SourceMode = "public" | "authoritative" | "mixed";
16
+
17
+ export const SOURCE_MODES: readonly SourceMode[] = ["public", "authoritative", "mixed"];
18
+
19
+ /** 统一主题;general 与不传等价,news 映射到各供应商的新闻入口。 */
20
+ export type Topic = "general" | "news";
21
+
22
+ export const TOPICS: readonly Topic[] = ["general", "news"];
23
+
24
+ /** 与供应商无关的搜索参数;limit、quality、sourceMode、topic 与 country 已由 search-service 规范化。 */
25
+ export interface SearchParams {
26
+ query: string;
27
+ limit: number;
28
+ quality: SearchQuality;
29
+ sourceMode?: SourceMode;
30
+ topic?: Topic;
31
+ /** 结果地区偏好,ISO 3166-1 alpha-2 两字母大写;只影响排序偏置,不做硬地域过滤。 */
32
+ country?: string;
33
+ domains?: string[];
34
+ excludeDomains?: string[];
35
+ freshness?: Freshness;
36
+ contents?: ContentsMode;
37
+ answer?: boolean;
38
+ }
39
+
40
+ /** 供应商返回的单条结果。 */
41
+ export interface SearchHit {
42
+ title: string;
43
+ url: string;
44
+ snippet?: string;
45
+ content?: string;
46
+ date?: string;
47
+ score?: number;
48
+ }
49
+
50
+ /** 统一结果;instance、providerUsed 与 degraded 由 search-service 补齐。 */
51
+ export interface SearchResult extends SearchHit {
52
+ instance: string;
53
+ providerUsed: PresetId;
54
+ degraded?: boolean;
55
+ }
56
+
57
+ export interface SearchOutput {
58
+ hits: SearchHit[];
59
+ answer?: string;
60
+ notes?: string[];
61
+ rateLimit?: RateLimitInfo;
62
+ }
63
+
64
+ /** 供应商抓取正文格式;text 由 Tavily 原生兑现,其余供应商抓 markdown 再由工具层转纯文本。 */
65
+ export type FetchOutputFormat = "markdown" | "text" | "html" | "json" | "links";
66
+
67
+ /** 与供应商无关的抓取参数;url、format 与 schema 已由 search-service 规范化。 */
68
+ export interface ExtractParams {
69
+ url: string;
70
+ format: FetchOutputFormat;
71
+ schema?: Record<string, unknown>;
72
+ }
73
+
74
+ export interface ExtractOutput {
75
+ title?: string;
76
+ content: string;
77
+ }
78
+
79
+ /** 与供应商无关的站点地图参数;url 与 limit 已由 search-service 规范化。 */
80
+ export interface MapParams {
81
+ url: string;
82
+ limit: number;
83
+ instructions?: string;
84
+ }
85
+
86
+ export interface MapLink {
87
+ url: string;
88
+ title?: string;
89
+ description?: string;
90
+ }
91
+
92
+ export interface MapOutput {
93
+ links: MapLink[];
94
+ notes?: string[];
95
+ }
96
+
97
+ /** 供应商支持的能力;没有抓取或站点地图接口的供应商会在对应链上被跳过。 */
98
+ export interface AdapterCapabilities {
99
+ search: boolean;
100
+ fetch: boolean;
101
+ map: boolean;
102
+ }
103
+
104
+ /** 一家供应商的请求构造、业务校验与响应映射。 */
105
+ export interface SearchAdapter {
106
+ readonly preset: PresetId;
107
+ readonly capabilities: AdapterCapabilities;
108
+ /** 该供应商无法兑现的搜索参数;search-service 据此跳过实例。 */
109
+ unsupported(params: SearchParams): string[];
110
+ buildSearch(instance: ResolvedInstance, params: SearchParams): RequestSpec;
111
+ /** HTTP 200 里的业务失败在这里抛 ProviderError。 */
112
+ checkSearch?(response: ProviderResponse, params: SearchParams): void;
113
+ mapSearch(response: ProviderResponse, params: SearchParams): SearchOutput;
114
+ buildExtract(instance: ResolvedInstance, params: ExtractParams): RequestSpec;
115
+ checkExtract?(response: ProviderResponse, params: ExtractParams): void;
116
+ mapExtract(response: ProviderResponse, params: ExtractParams): ExtractOutput;
117
+ /** 该供应商无法兑现的抓取格式;search-service 据此跳过实例。 */
118
+ unsupportedExtract?(params: ExtractParams): string[];
119
+ buildMap(instance: ResolvedInstance, params: MapParams): RequestSpec;
120
+ checkMap?(response: ProviderResponse, params: MapParams): void;
121
+ mapSite(response: ProviderResponse, params: MapParams): MapOutput;
122
+ }
@@ -0,0 +1,93 @@
1
+ import type { ErrorClass, ResolvedInstance } from "../config.ts";
2
+ import { ProviderError, type ProviderResponse } from "../http.ts";
3
+ import type { PresetId } from "../presets.ts";
4
+ import type { ExtractParams, SearchQuality, SourceMode, Topic } from "./types.ts";
5
+
6
+ export function asRecord(value: unknown): Record<string, unknown> | undefined {
7
+ return typeof value === "object" && value !== null && !Array.isArray(value)
8
+ ? (value as Record<string, unknown>)
9
+ : undefined;
10
+ }
11
+
12
+ export function asString(value: unknown): string | undefined {
13
+ return typeof value === "string" && value.trim() ? value : undefined;
14
+ }
15
+
16
+ export function asNumber(value: unknown): number | undefined {
17
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
18
+ }
19
+
20
+ export function asArray(value: unknown): unknown[] {
21
+ return Array.isArray(value) ? value : [];
22
+ }
23
+
24
+ /** 业务失败:保留状态码与上游 request_id,消息只写供应商结论。 */
25
+ export function businessFailure(
26
+ response: ProviderResponse,
27
+ message: string,
28
+ code: ErrorClass = "invalidRequest",
29
+ ): ProviderError {
30
+ return new ProviderError({
31
+ instance: response.instance,
32
+ code,
33
+ status: response.status,
34
+ requestId: response.requestId,
35
+ message,
36
+ });
37
+ }
38
+
39
+ /** 显式指定实例时不经链过滤,在请求构造处拦住该供应商兑现不了的参数。 */
40
+ export function rejectUnsupported(
41
+ instance: ResolvedInstance,
42
+ preset: PresetId,
43
+ unsupported: string[],
44
+ ): void {
45
+ if (unsupported.length === 0) return;
46
+ throw new ProviderError({
47
+ instance: instance.id,
48
+ code: "invalidRequest",
49
+ message: `${preset} 不支持 ${unsupported.join("、")}`,
50
+ });
51
+ }
52
+
53
+ /** 没有站点地图接口的供应商在 buildMap / mapSite 里抛出。 */
54
+ export function rejectNoMap(instanceId: string, preset: string): never {
55
+ throw new ProviderError({
56
+ instance: instanceId,
57
+ code: "invalidRequest",
58
+ message: `${preset} 没有站点地图接口`,
59
+ });
60
+ }
61
+
62
+ /** markdown 与 text 都视为可兑现;text 由工具层从 markdown 转出。其余 format 原样交给 search-service 裁链。 */
63
+ export function markdownOnlyExtract(params: ExtractParams): string[] {
64
+ return params.format === "markdown" || params.format === "text" ? [] : [params.format];
65
+ }
66
+
67
+ /** 供应商接口没有质量字段时的降级说明;basic 已是默认深度,不必说明。 */
68
+ export function qualityGapNote(preset: PresetId, quality: SearchQuality): string | undefined {
69
+ if (quality === "basic") return undefined;
70
+ return `${preset} 没有质量参数,quality=${quality} 已按默认深度请求`;
71
+ }
72
+
73
+ /** 供应商有质量字段但兑现不了该档位时的降级说明。 */
74
+ export function qualityDowngradeNote(preset: PresetId, quality: SearchQuality, actual: string): string {
75
+ return `${preset} 没有 ${quality} 档位,已按 ${actual} 请求`;
76
+ }
77
+
78
+ /** 供应商没有信源范围字段时的降级说明;不阻断请求,也不伪造上游字段。 */
79
+ export function sourceModeGapNote(preset: PresetId, sourceMode: SourceMode): string {
80
+ return `${preset} 没有信源范围参数,sourceMode=${sourceMode} 已按供应商默认信源请求`;
81
+ }
82
+
83
+ /** 供应商没有主题字段时的降级说明;general 与不传等价,不必说明。 */
84
+ export function topicGapNote(preset: PresetId, topic: Topic | undefined): string | undefined {
85
+ if (topic === undefined || topic === "general") return undefined;
86
+ return `${preset} 没有主题参数,topic=${topic} 已按通用主题请求`;
87
+ }
88
+
89
+ /** 供应商没有地区偏好字段时的降级说明;不阻断请求,也不伪造上游字段。 */
90
+ export function countryGapNote(preset: PresetId, country: string | undefined): string | undefined {
91
+ if (country === undefined) return undefined;
92
+ return `${preset} 没有地区参数,country=${country} 已按供应商默认地区请求`;
93
+ }