@fffangchenghao/dsh-web-search 0.19.3 → 0.20.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/CHANGELOG.md +173 -1
- package/README.md +214 -34
- package/README.zh-CN.md +187 -35
- package/SECURITY.md +42 -7
- package/client.js +248 -10
- package/docs/store-evidence.md +10 -5
- package/lib/advanced-search.d.ts +107 -0
- package/lib/advanced-search.js +255 -0
- package/lib/bridge.d.ts +34 -0
- package/lib/bridge.js +305 -0
- package/lib/cache.d.ts +11 -4
- package/lib/cache.js +9 -5
- package/lib/config.d.ts +19 -3
- package/lib/config.js +24 -0
- package/lib/domain-tool.d.ts +5 -0
- package/lib/domain-tool.js +45 -6
- package/lib/engine-test.d.ts +116 -0
- package/lib/engine-test.js +256 -0
- package/lib/engines.d.ts +11 -1
- package/lib/engines.js +118 -19
- package/lib/errors.d.ts +16 -2
- package/lib/errors.js +40 -1
- package/lib/index.d.ts +24 -2
- package/lib/index.js +309 -21
- package/lib/inject.d.ts +68 -0
- package/lib/inject.js +1 -0
- package/lib/markdown.js +18 -1
- package/lib/mirrors.d.ts +23 -0
- package/lib/mirrors.js +69 -0
- package/lib/official-feed.d.ts +114 -0
- package/lib/official-feed.js +288 -0
- package/lib/official-support.d.ts +74 -0
- package/lib/official-support.js +134 -0
- package/lib/platform-tool.d.ts +77 -0
- package/lib/platform-tool.js +173 -0
- package/lib/platforms.d.ts +178 -0
- package/lib/platforms.js +1035 -0
- package/lib/query-router.d.ts +29 -0
- package/lib/query-router.js +58 -0
- package/lib/read-page.js +2 -1
- package/lib/research-cache.d.ts +115 -0
- package/lib/research-cache.js +275 -0
- package/lib/research.d.ts +45 -4
- package/lib/research.js +505 -22
- package/lib/search-many.d.ts +7 -1
- package/lib/search-many.js +7 -2
- package/lib/system-prompt.d.ts +27 -0
- package/lib/system-prompt.js +50 -0
- package/lib/tool-suite.d.ts +97 -0
- package/lib/tool-suite.js +224 -0
- package/lib/transport.d.ts +33 -2
- package/lib/transport.js +42 -9
- package/lib/types.d.ts +20 -0
- package/lib/types.js +9 -1
- package/lib/untrusted.d.ts +33 -0
- package/lib/untrusted.js +42 -0
- package/lib/verticals.d.ts +3 -1
- package/lib/verticals.js +26 -7
- package/package.json +5 -3
- package/skills/dsh-web-search/SKILL.md +21 -6
package/client.js
CHANGED
|
@@ -39,6 +39,33 @@
|
|
|
39
39
|
var React = require('react');
|
|
40
40
|
var h = React.createElement;
|
|
41
41
|
|
|
42
|
+
/** Compare dotted versions without treating a local build as older. */
|
|
43
|
+
function isNewerVersion(candidate, current) {
|
|
44
|
+
try {
|
|
45
|
+
var a = String(candidate).split('-')[0].split('.').map(function (part) { return Number(part); });
|
|
46
|
+
var b = String(current).split('-')[0].split('.').map(function (part) { return Number(part); });
|
|
47
|
+
var length = Math.max(a.length, b.length);
|
|
48
|
+
for (var i = 0; i < length; i += 1) {
|
|
49
|
+
var left = a[i] === undefined || !isFinite(a[i]) ? 0 : a[i];
|
|
50
|
+
var right = b[i] === undefined || !isFinite(b[i]) ? 0 : b[i];
|
|
51
|
+
if (left !== right) return left > right;
|
|
52
|
+
}
|
|
53
|
+
return String(candidate).indexOf('-') === -1 && String(current).indexOf('-') !== -1;
|
|
54
|
+
} catch (ignored) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The one-click updater route only exists on the local desktop surface. */
|
|
60
|
+
function isLocalPage() {
|
|
61
|
+
try {
|
|
62
|
+
var host = window.location.hostname;
|
|
63
|
+
return host === '127.0.0.1' || host === 'localhost' || host === '::1' || host === '[::1]';
|
|
64
|
+
} catch (ignored) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
42
69
|
/** Dictionary namespace owned by this plugin. */
|
|
43
70
|
var NS = 'webSearchBing';
|
|
44
71
|
/** The Settings surface slot: one settings page per list entry. */
|
|
@@ -47,22 +74,28 @@
|
|
|
47
74
|
var ENTRY = 'web-search-bing';
|
|
48
75
|
var PACKAGE_NAME = 'dsh-web-search-bing';
|
|
49
76
|
/** Keep in step with package.json; compared with the npm registry. */
|
|
50
|
-
var VERSION = '0.
|
|
77
|
+
var VERSION = '0.20.1';
|
|
51
78
|
/** Snapshot used while no configuration service is reachable. */
|
|
52
79
|
var EMPTY_STATE = { status: 'unavailable', value: undefined, base: undefined, user: undefined, revision: undefined, writable: false };
|
|
53
80
|
|
|
54
81
|
// English copy. Every label the page renders lives here.
|
|
55
82
|
var en = {
|
|
56
83
|
title: 'Web search (Bing)',
|
|
57
|
-
description: 'Edit the key-free search provider: engine allow-list, wait policy, proxy, result budget, ranking, cache, cooldowns and dedicated sources. Model tools: web_search,
|
|
84
|
+
description: 'Edit the key-free search provider: engine allow-list, wait policy, proxy, result budget, ranking, cache, cooldowns and dedicated sources. Model tools: web_search, web_fetch and one unified web_tools action tool (legacy eight-name mode is opt-in).',
|
|
58
85
|
jumpTo: 'Jump to',
|
|
59
86
|
latest: 'Latest on npm',
|
|
60
87
|
upToDate: 'up to date',
|
|
61
88
|
updateAvailable: 'update available',
|
|
62
89
|
'group.engines': 'Engines and transport',
|
|
63
90
|
'group.ranking': 'Results and ranking',
|
|
91
|
+
'group.fetch': 'Fetching',
|
|
64
92
|
'group.cache': 'Cache and cooldowns',
|
|
65
93
|
'group.domain': 'Dedicated sources',
|
|
94
|
+
'group.tools': 'Model tools',
|
|
95
|
+
'field.toolSurface': 'Tool surface',
|
|
96
|
+
'hint.toolSurface': 'unified exposes one web_tools with eight actions and is the recommended context-efficient mode; legacy keeps the old eight names for existing prompts. Restart the plugin after changing this.',
|
|
97
|
+
'toolSurface.unified': 'Unified (one web_tools)',
|
|
98
|
+
'toolSurface.legacy': 'Legacy (eight names)',
|
|
66
99
|
'wait.auto': 'Auto (query language)',
|
|
67
100
|
'wait.all': 'All engines',
|
|
68
101
|
'wait.fast': 'Fastest answer',
|
|
@@ -113,6 +146,22 @@
|
|
|
113
146
|
'timeRange.week': 'Past 7 days',
|
|
114
147
|
'timeRange.month': 'Past 30 days',
|
|
115
148
|
'timeRange.year': 'Past year',
|
|
149
|
+
'field.blockedDomains': 'Blocked sites',
|
|
150
|
+
'hint.blockedDomains': 'Domains that must never appear (spam.example, ads.example); subdomains are blocked too. Empty blocks nothing.',
|
|
151
|
+
'field.safeSearch': 'Safe search',
|
|
152
|
+
'hint.safeSearch': 'Applies only to Bing and DuckDuckGo; off keeps each engine default',
|
|
153
|
+
'safeSearch.off': 'Off (engine default)',
|
|
154
|
+
'safeSearch.moderate': 'Moderate',
|
|
155
|
+
'safeSearch.strict': 'Strict',
|
|
156
|
+
'field.fallbackOn': 'Fallback on',
|
|
157
|
+
'hint.fallbackOn': 'Failure classes that may switch to a fallback engine. Empty means never fall back; all six means search never fails just because one engine did.',
|
|
158
|
+
'testTitle': 'Engine health',
|
|
159
|
+
'testHint': 'Run one tiny query through each engine. This does not use the cache or change cooldowns.',
|
|
160
|
+
'testButton': 'Test engines',
|
|
161
|
+
'testRunning': 'Testing…',
|
|
162
|
+
'testUnavailable': 'The test endpoint is not available in this deployment.',
|
|
163
|
+
'testFailed': 'The test could not run.',
|
|
164
|
+
'testSummary': 'OK / failed',
|
|
116
165
|
'field.cacheTtlMs': 'Cache lifetime',
|
|
117
166
|
'hint.cacheTtlMs': 'How long an identical question reuses its cached answer (ms)',
|
|
118
167
|
'field.cacheEntries': 'Cache size',
|
|
@@ -145,13 +194,28 @@
|
|
|
145
194
|
title: '网页搜索(Bing)',
|
|
146
195
|
jumpTo: '跳到',
|
|
147
196
|
latest: 'npm 最新版',
|
|
197
|
+
autoUpdateHint: '定时自动更新需要 profile 更新器(dsh-autoupdater);「安装更新」按钮不依赖它:它会请 Host 插件管理器安装 npm 包,装完需重启。link:/file: 安装会被拒绝。',
|
|
198
|
+
updateButton: '安装更新',
|
|
199
|
+
updateInstalling: '正在安装…请保持此页打开。',
|
|
200
|
+
updateDone: '更新已安装。',
|
|
201
|
+
updateRestart: '更新已安装;重启 DeepSeek Harness 后生效。',
|
|
202
|
+
updateFailed: '更新失败:',
|
|
203
|
+
updateLocal: '当前是 link:/file: 安装。请先改成 npm 安装,再使用这个按钮。',
|
|
204
|
+
updateRemote: '更新按钮只在本地桌面 App 中可用。',
|
|
205
|
+
updateUnavailable: '当前部署没有内置插件管理器;请用 profile 的包管理器更新。',
|
|
148
206
|
upToDate: '已是最新',
|
|
149
207
|
updateAvailable: '有新版本',
|
|
150
|
-
description: '编辑免密钥搜索提供方:引擎白名单、等待策略、代理、结果上限、排序、缓存、冷却与专用检索源。模型工具:web_search、
|
|
208
|
+
description: '编辑免密钥搜索提供方:引擎白名单、等待策略、代理、结果上限、排序、缓存、冷却与专用检索源。模型工具:web_search、web_fetch,以及一个统一的 web_tools action 工具(旧版八个工具名可选)。',
|
|
151
209
|
'group.engines': '引擎与传输',
|
|
152
210
|
'group.ranking': '结果与排序',
|
|
211
|
+
'group.fetch': '抓取',
|
|
153
212
|
'group.cache': '缓存与冷却',
|
|
154
213
|
'group.domain': '专用检索',
|
|
214
|
+
'group.tools': '模型工具',
|
|
215
|
+
'field.toolSurface': '工具面',
|
|
216
|
+
'hint.toolSurface': 'unified 只暴露一个 web_tools、用 action 调用八种能力,推荐且更省上下文;legacy 保留原来的八个工具名,兼容旧提示词。修改后需要重启插件。',
|
|
217
|
+
'toolSurface.unified': '统一(一个 web_tools)',
|
|
218
|
+
'toolSurface.legacy': '旧版(八个工具名)',
|
|
155
219
|
'wait.auto': '自动(按提问语言)',
|
|
156
220
|
'wait.all': '等待全部引擎',
|
|
157
221
|
'wait.fast': '最快回答',
|
|
@@ -202,6 +266,22 @@
|
|
|
202
266
|
'timeRange.week': '最近 7 天',
|
|
203
267
|
'timeRange.month': '最近 30 天',
|
|
204
268
|
'timeRange.year': '最近 1 年',
|
|
269
|
+
'field.blockedDomains': '屏蔽网站',
|
|
270
|
+
'hint.blockedDomains': '永远不要出现在结果里的网站(如 spam.example、ads.example),子域名也会被屏蔽;留空表示不屏蔽。',
|
|
271
|
+
'field.safeSearch': '安全搜索',
|
|
272
|
+
'hint.safeSearch': '只影响 Bing 和 DuckDuckGo;off 保持引擎默认',
|
|
273
|
+
'safeSearch.off': '关闭(引擎默认)',
|
|
274
|
+
'safeSearch.moderate': '适中',
|
|
275
|
+
'safeSearch.strict': '严格',
|
|
276
|
+
'field.fallbackOn': '哪些失败可回退',
|
|
277
|
+
'hint.fallbackOn': '允许切换到备用引擎的失败类别;留空表示任何失败都不回退,六类全选表示一个引擎失败不会让搜索失败。',
|
|
278
|
+
'testTitle': '引擎健康',
|
|
279
|
+
'testHint': '用一条短查询逐个测试引擎;不会使用缓存,也不会改变冷却状态。',
|
|
280
|
+
'testButton': '测试引擎',
|
|
281
|
+
'testRunning': '测试中…',
|
|
282
|
+
'testUnavailable': '当前部署没有提供测试接口。',
|
|
283
|
+
'testFailed': '测试没能执行。',
|
|
284
|
+
'testSummary': '成功 / 失败',
|
|
205
285
|
'field.cacheTtlMs': '缓存保留多久',
|
|
206
286
|
'hint.cacheTtlMs': '同一问题复用旧结果多久(毫秒);想更快见新内容就调小',
|
|
207
287
|
'field.cacheEntries': '缓存条数上限',
|
|
@@ -235,10 +315,10 @@
|
|
|
235
315
|
{ key: 'wait', group: 'engines', kind: 'select', options: ['auto', 'all', 'fast'] },
|
|
236
316
|
{ key: 'timeoutMs', group: 'engines', kind: 'number', integer: true, min: 500 },
|
|
237
317
|
{ key: 'proxy', group: 'engines', kind: 'text' },
|
|
238
|
-
{ key: 'fetchFormat', group: '
|
|
239
|
-
{ key: 'fetchMaxLength', group: '
|
|
240
|
-
{ key: 'renderJs', group: '
|
|
241
|
-
{ key: 'renderTimeoutMs', group: '
|
|
318
|
+
{ key: 'fetchFormat', group: 'fetch', kind: 'select', options: ['markdown', 'text'] },
|
|
319
|
+
{ key: 'fetchMaxLength', group: 'fetch', kind: 'number', integer: true, min: 1000, max: 200000 },
|
|
320
|
+
{ key: 'renderJs', group: 'fetch', kind: 'select', options: ['auto', 'always', 'off'] },
|
|
321
|
+
{ key: 'renderTimeoutMs', group: 'fetch', kind: 'number', integer: true, min: 1000, max: 120000 },
|
|
242
322
|
{ key: 'anysearchApiKey', group: 'engines', kind: 'text' },
|
|
243
323
|
{ key: 'anysearchDomain', group: 'engines', kind: 'text' },
|
|
244
324
|
{ key: 'limit', group: 'ranking', kind: 'number', integer: true, min: 1, max: 20 },
|
|
@@ -248,6 +328,9 @@
|
|
|
248
328
|
{ key: 'freshnessBoost', group: 'ranking', kind: 'number', min: 0, max: 10 },
|
|
249
329
|
{ key: 'freshnessDays', group: 'ranking', kind: 'number', integer: true, min: 1 },
|
|
250
330
|
{ key: 'timeRange', group: 'ranking', kind: 'select', options: ['off', 'day', 'week', 'month', 'year'] },
|
|
331
|
+
{ key: 'blockedDomains', group: 'engines', kind: 'list' },
|
|
332
|
+
{ key: 'safeSearch', group: 'engines', kind: 'select', options: ['off', 'moderate', 'strict'] },
|
|
333
|
+
{ key: 'fallbackOn', group: 'engines', kind: 'list' },
|
|
251
334
|
{ key: 'cacheTtlMs', group: 'cache', kind: 'number', integer: true, min: 0 },
|
|
252
335
|
{ key: 'cacheEntries', group: 'cache', kind: 'number', integer: true, min: 0 },
|
|
253
336
|
{ key: 'cachePersist', group: 'cache', kind: 'select', options: ['true', 'false'], boolean: true },
|
|
@@ -256,11 +339,12 @@
|
|
|
256
339
|
{ key: 'maxCooldownMs', group: 'cache', kind: 'number', integer: true, min: 0 },
|
|
257
340
|
{ key: 'domainSources', group: 'domain', kind: 'list' },
|
|
258
341
|
{ key: 'domainLimit', group: 'domain', kind: 'number', integer: true, min: 1, max: 20 },
|
|
259
|
-
{ key: 'domainTimeoutMs', group: 'domain', kind: 'number', integer: true, min: 500 }
|
|
342
|
+
{ key: 'domainTimeoutMs', group: 'domain', kind: 'number', integer: true, min: 500 },
|
|
343
|
+
{ key: 'toolSurface', group: 'tools', kind: 'select', options: ['unified', 'legacy'] }
|
|
260
344
|
];
|
|
261
345
|
|
|
262
346
|
/** Groups in render order. */
|
|
263
|
-
var GROUPS = ['engines', 'ranking', 'cache', 'domain'].map(function (group) {
|
|
347
|
+
var GROUPS = ['engines', 'ranking', 'fetch', 'cache', 'domain', 'tools'].map(function (group) {
|
|
264
348
|
return { key: group, fields: FIELDS.filter(function (field) { return field.group === group; }) };
|
|
265
349
|
});
|
|
266
350
|
|
|
@@ -479,6 +563,12 @@
|
|
|
479
563
|
var latestPair = React.useState(null);
|
|
480
564
|
var latest = latestPair[0];
|
|
481
565
|
var setLatest = latestPair[1];
|
|
566
|
+
var testPair = React.useState({ phase: 'idle', value: null, error: null });
|
|
567
|
+
var test = testPair[0];
|
|
568
|
+
var setTest = testPair[1];
|
|
569
|
+
var installPair = React.useState({ phase: 'idle', message: '', version: '' });
|
|
570
|
+
var installation = installPair[0];
|
|
571
|
+
var setInstallation = installPair[1];
|
|
482
572
|
|
|
483
573
|
// Ask the npm registry once per mount. A failure (offline, proxy
|
|
484
574
|
// down, registry error) hides the line instead of showing an
|
|
@@ -504,6 +594,47 @@
|
|
|
504
594
|
setErrors({});
|
|
505
595
|
}, [state.revision]);
|
|
506
596
|
|
|
597
|
+
function installUpdate() {
|
|
598
|
+
if (installation.phase === 'working') return;
|
|
599
|
+
setInstallation({ phase: 'working', message: '', version: '' });
|
|
600
|
+
try {
|
|
601
|
+
fetch('/api/dsh-web-search/update', {
|
|
602
|
+
method: 'POST',
|
|
603
|
+
headers: { 'content-type': 'application/json' },
|
|
604
|
+
body: '{}'
|
|
605
|
+
}).then(function (response) {
|
|
606
|
+
return response.json().then(function (body) {
|
|
607
|
+
return { status: response.status, body: body };
|
|
608
|
+
}, function () {
|
|
609
|
+
return { status: response.status, body: null };
|
|
610
|
+
});
|
|
611
|
+
}).then(function (out) {
|
|
612
|
+
var body = out.body;
|
|
613
|
+
if (out.status === 200 && body !== null && body.ok === true) {
|
|
614
|
+
setInstallation({
|
|
615
|
+
phase: body.restartRequired === true ? 'restart' : 'done',
|
|
616
|
+
message: '',
|
|
617
|
+
version: typeof body.version === 'string' ? body.version : ''
|
|
618
|
+
});
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
var code = body === null ? '' : body.code;
|
|
622
|
+
var message = code === 'local-install'
|
|
623
|
+
? t('updateLocal')
|
|
624
|
+
: code === 'manager-unavailable' || out.status === 404 || out.status === 405
|
|
625
|
+
? t('updateUnavailable')
|
|
626
|
+
: body !== null && typeof body.message === 'string'
|
|
627
|
+
? body.message
|
|
628
|
+
: t('updateFailed') + 'HTTP ' + out.status;
|
|
629
|
+
setInstallation({ phase: 'failed', message: message, version: '' });
|
|
630
|
+
}, function (error) {
|
|
631
|
+
setInstallation({ phase: 'failed', message: String(error), version: '' });
|
|
632
|
+
});
|
|
633
|
+
} catch (error) {
|
|
634
|
+
setInstallation({ phase: 'failed', message: String(error), version: '' });
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
507
638
|
var ready = form !== null && form !== undefined && state.status === 'ready';
|
|
508
639
|
var values = ready && state.value !== null && typeof state.value === 'object' ? state.value : {};
|
|
509
640
|
var current = draft === null ? toDraft(values) : draft;
|
|
@@ -520,6 +651,41 @@
|
|
|
520
651
|
}
|
|
521
652
|
}
|
|
522
653
|
|
|
654
|
+
function runEngineTest() {
|
|
655
|
+
if (test.phase === 'running') return;
|
|
656
|
+
setTest({ phase: 'running', value: null, error: null });
|
|
657
|
+
var request;
|
|
658
|
+
try {
|
|
659
|
+
request = fetch('/api/dsh-web-search/engine-test', {
|
|
660
|
+
method: 'POST',
|
|
661
|
+
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
662
|
+
body: JSON.stringify({ query: 'DeepSeek Harness' })
|
|
663
|
+
});
|
|
664
|
+
} catch (error) {
|
|
665
|
+
setTest({ phase: 'failed', value: null, error: t('testUnavailable') });
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
Promise.resolve(request).then(function (response) {
|
|
669
|
+
return Promise.resolve(response.text()).then(function (text) {
|
|
670
|
+
var body = null;
|
|
671
|
+
try {
|
|
672
|
+
body = text.length === 0 ? null : JSON.parse(text);
|
|
673
|
+
} catch (ignored) {
|
|
674
|
+
body = null;
|
|
675
|
+
}
|
|
676
|
+
if (!response.ok || body === null || body.ok !== true || body.value === undefined) {
|
|
677
|
+
var fallback = response.status === 404 || response.status === 405
|
|
678
|
+
? t('testUnavailable')
|
|
679
|
+
: t('testFailed');
|
|
680
|
+
throw new Error(body !== null && typeof body.message === 'string' ? body.message : fallback);
|
|
681
|
+
}
|
|
682
|
+
setTest({ phase: 'done', value: body.value, error: null });
|
|
683
|
+
});
|
|
684
|
+
}).catch(function (error) {
|
|
685
|
+
setTest({ phase: 'failed', value: null, error: error instanceof Error ? error.message : t('testUnavailable') });
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
|
|
523
689
|
function save() {
|
|
524
690
|
if (!ready || state.writable === false || phase === 'saving') return;
|
|
525
691
|
var nextErrors = {};
|
|
@@ -558,12 +724,52 @@
|
|
|
558
724
|
h('p', { key: 'description', style: { margin: 0, fontSize: '13px', lineHeight: 1.5, color: 'var(--dsw-alias-label-tertiary)' } }, t('description'))
|
|
559
725
|
];
|
|
560
726
|
if (latest !== null) {
|
|
561
|
-
var newer = latest
|
|
727
|
+
var newer = isNewerVersion(latest, VERSION);
|
|
562
728
|
children.push(h('p', {
|
|
563
729
|
key: 'latest',
|
|
564
730
|
style: { margin: 0, fontSize: '12px', color: newer ? 'var(--dsw-alias-state-warn-primary)' : 'var(--dsw-alias-label-tertiary)' },
|
|
565
731
|
role: 'status'
|
|
566
732
|
}, t('latest') + ': ' + latest + (newer ? ' — ' + t('updateAvailable') : ' — ' + t('upToDate'))));
|
|
733
|
+
children.push(h('p', {
|
|
734
|
+
key: 'auto-update', style: { margin: 0, fontSize: '11px', lineHeight: 1.5, color: 'var(--dsw-alias-label-tertiary)' }, role: 'note'
|
|
735
|
+
}, t('autoUpdateHint')));
|
|
736
|
+
if (newer) {
|
|
737
|
+
if (isLocalPage()) {
|
|
738
|
+
children.push(h('button', {
|
|
739
|
+
key: 'install-update',
|
|
740
|
+
type: 'button',
|
|
741
|
+
disabled: installation.phase === 'working',
|
|
742
|
+
onClick: installUpdate,
|
|
743
|
+
style: {
|
|
744
|
+
alignSelf: 'flex-start',
|
|
745
|
+
padding: '5px 10px',
|
|
746
|
+
borderRadius: '6px',
|
|
747
|
+
border: '1px solid var(--dsw-alias-border-l1)',
|
|
748
|
+
background: 'var(--dsw-alias-bg-base)',
|
|
749
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
750
|
+
cursor: installation.phase === 'working' ? 'wait' : 'pointer',
|
|
751
|
+
fontSize: '12px'
|
|
752
|
+
}
|
|
753
|
+
}, installation.phase === 'working' ? t('updateInstalling') : t('updateButton')));
|
|
754
|
+
} else {
|
|
755
|
+
children.push(h('p', {
|
|
756
|
+
key: 'update-remote', style: { margin: 0, fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)' }
|
|
757
|
+
}, t('updateRemote')));
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (installation.phase === 'working') {
|
|
761
|
+
children.push(h('p', {
|
|
762
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)' }, role: 'status', 'aria-live': 'polite'
|
|
763
|
+
}, t('updateInstalling')));
|
|
764
|
+
} else if (installation.phase === 'restart' || installation.phase === 'done') {
|
|
765
|
+
children.push(h('p', {
|
|
766
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-state-success-primary, var(--dsw-alias-label-secondary))' }, role: 'status'
|
|
767
|
+
}, t(installation.phase === 'restart' ? 'updateRestart' : 'updateDone') + (installation.version === '' ? '' : ' (' + installation.version + ')')));
|
|
768
|
+
} else if (installation.phase === 'failed') {
|
|
769
|
+
children.push(h('p', {
|
|
770
|
+
key: 'update-status', style: { margin: 0, fontSize: '12px', color: 'var(--dsw-alias-state-warn-primary)' }, role: 'alert'
|
|
771
|
+
}, t('updateFailed') + installation.message));
|
|
772
|
+
}
|
|
567
773
|
}
|
|
568
774
|
|
|
569
775
|
if (!ready) {
|
|
@@ -654,6 +860,38 @@
|
|
|
654
860
|
]);
|
|
655
861
|
})));
|
|
656
862
|
|
|
863
|
+
var testStatus = null;
|
|
864
|
+
if (test.phase === 'running') {
|
|
865
|
+
testStatus = h('p', { key: 'test-running', style: hintStyle, role: 'status' }, t('testRunning'));
|
|
866
|
+
} else if (test.phase === 'failed') {
|
|
867
|
+
testStatus = h('p', { key: 'test-failed', style: errorStyle, role: 'alert' }, test.error === null ? t('testFailed') : test.error);
|
|
868
|
+
} else if (test.phase === 'done' && test.value !== null) {
|
|
869
|
+
var rows = (Array.isArray(test.value.results) ? test.value.results : []).map(function (result) {
|
|
870
|
+
var kind = result.ok === true ? 'OK' : 'FAIL';
|
|
871
|
+
var detail = result.ok === true
|
|
872
|
+
? String(result.latencyMs) + 'ms · ' + String(result.count) + ' result(s)'
|
|
873
|
+
: (typeof result.failureKind === 'string' ? '[' + result.failureKind + '] ' : '') + (typeof result.reason === 'string' ? result.reason : '');
|
|
874
|
+
return h('li', { key: result.engine, style: { margin: '2px 0', fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: '12px' } },
|
|
875
|
+
result.engine + ': ' + kind + ' · ' + detail);
|
|
876
|
+
});
|
|
877
|
+
testStatus = h('div', { key: 'test-done' }, [
|
|
878
|
+
h('p', { key: 'summary', style: hintStyle, role: 'status' }, t('testSummary') + ': ' + String(test.value.ok) + ' / ' + String(test.value.failed)),
|
|
879
|
+
h('ul', { key: 'rows', style: { margin: 0, paddingLeft: '18px' } }, rows)
|
|
880
|
+
]);
|
|
881
|
+
}
|
|
882
|
+
children.push(h('section', { key: 'engine-test', style: groupStyle }, [
|
|
883
|
+
h('h4', { key: 'title', style: { margin: 0, fontSize: '13px', lineHeight: 1.4, color: 'var(--dsw-alias-label-primary)' } }, t('testTitle')),
|
|
884
|
+
h('p', { key: 'hint', style: hintStyle }, t('testHint')),
|
|
885
|
+
h('div', { key: 'actions', style: { display: 'flex', alignItems: 'center', gap: '10px', flexWrap: 'wrap' } }, [
|
|
886
|
+
h('button', {
|
|
887
|
+
key: 'run', type: 'button', style: buttonStyle,
|
|
888
|
+
disabled: test.phase === 'running',
|
|
889
|
+
onClick: runEngineTest
|
|
890
|
+
}, t(test.phase === 'running' ? 'testRunning' : 'testButton')),
|
|
891
|
+
testStatus
|
|
892
|
+
])
|
|
893
|
+
]));
|
|
894
|
+
|
|
657
895
|
var footer = [
|
|
658
896
|
h('button', {
|
|
659
897
|
key: 'save', type: 'button', style: primaryStyle,
|
package/docs/store-evidence.md
CHANGED
|
@@ -23,7 +23,7 @@ Only `0.2.1-rc.2` is declared, because that is the version actually exercised.
|
|
|
23
23
|
## Environment
|
|
24
24
|
|
|
25
25
|
- macOS (arm64), DeepSeek Harness **0.2.1-rc.2** (`dsh --version`), Node 22.18+.
|
|
26
|
-
- Runtime artifacts: `lib/` is committed to this repository (
|
|
26
|
+
- Runtime artifacts: `lib/` is committed to this repository (78 files, 900 KiB),
|
|
27
27
|
so the fixed commit's tree contains `lib/index.js` and `lib/index.d.ts`.
|
|
28
28
|
- Disposable profile for the destructive steps: a fresh `DSH_HOME` created with
|
|
29
29
|
`mktemp -d`; the real `~/.dsh` was never written to. Bundled pnpm 11.28.5.
|
|
@@ -58,10 +58,15 @@ Two independent observations:
|
|
|
58
58
|
status: "schema" }], total: 1 }
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
`status: "schema"` means the entry is active
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
`status: "schema"` means the entry is active; the current build projects a
|
|
62
|
+
29-field Config schema. Eight tools (`domain_search`, `search_many`,
|
|
63
|
+
`advanced_search`, `read_page`, `research`, `cache_search`, `platform_search`,
|
|
64
|
+
`engine_test`) and the
|
|
65
|
+
search/fetch providers are registered from the same mount; the GUI lists the
|
|
66
|
+
plugin as 运行中. This probe was retaken after a restart with the current
|
|
67
|
+
build; a live `advanced_search` window note and a fresh npm publish date were
|
|
68
|
+
observed through those tools, so the list is a live observation rather than a
|
|
69
|
+
projection.
|
|
65
70
|
|
|
66
71
|
2. **Disposable profile, composed tree.** `dsh --profile e2e --dump-config`
|
|
67
72
|
composes the full tree without error and contains the entry above.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { EngineFailure, Source, TimeRange } from './types.ts';
|
|
2
|
+
import type { ToolContent, ToolJsonSchema } from './domain-tool.ts';
|
|
3
|
+
/** The name this tool prefers. */
|
|
4
|
+
export declare const ADVANCED_SEARCH_TOOL_NAME = "advanced_search";
|
|
5
|
+
/** The name used when another plugin already registered `advanced_search`. */
|
|
6
|
+
export declare const ADVANCED_SEARCH_FALLBACK_NAME = "web_search_advanced";
|
|
7
|
+
/** Default result budget when the caller names none. */
|
|
8
|
+
export declare const ADVANCED_SEARCH_DEFAULT_LIMIT = 5;
|
|
9
|
+
/** Largest result budget the tool accepts; the deployment limit still caps it. */
|
|
10
|
+
export declare const ADVANCED_SEARCH_MAX_LIMIT = 20;
|
|
11
|
+
/** What one advanced search produced, including the window that was applied. */
|
|
12
|
+
export interface AdvancedSearchOutcome {
|
|
13
|
+
sources: Source[];
|
|
14
|
+
failures: string[];
|
|
15
|
+
/** Structured failures, kept for callers that want the business class. */
|
|
16
|
+
failureDetails?: EngineFailure[];
|
|
17
|
+
/** Short policy note, such as why the fallback tier was used or skipped. */
|
|
18
|
+
note?: string;
|
|
19
|
+
/** True when the deployment's configured limit cut the requested budget. */
|
|
20
|
+
truncated: boolean;
|
|
21
|
+
/** The effective window, after applying the deployment default if omitted. */
|
|
22
|
+
timeRange: TimeRange;
|
|
23
|
+
}
|
|
24
|
+
/** What the tool returns to the model. */
|
|
25
|
+
export interface AdvancedSearchValue {
|
|
26
|
+
query: string;
|
|
27
|
+
timeRange: TimeRange;
|
|
28
|
+
sources: Source[];
|
|
29
|
+
failures: string[];
|
|
30
|
+
note?: string;
|
|
31
|
+
truncated: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Explain an undated row when a window is active.
|
|
35
|
+
*
|
|
36
|
+
* The engine path prefers dated results inside the window, but falls back to
|
|
37
|
+
* undated rows when no dated result lands inside it. Saying so keeps the model
|
|
38
|
+
* from presenting an undated row as a confirmed "this week" item.
|
|
39
|
+
* @param sources - the rows returned by the search.
|
|
40
|
+
* @param timeRange - the effective window.
|
|
41
|
+
* @returns one sentence, or `undefined` when every row is dated or the window is off.
|
|
42
|
+
*/
|
|
43
|
+
export declare function undatedWindowNote(sources: readonly Source[], timeRange: TimeRange): string | undefined;
|
|
44
|
+
/** Run one search with an optional window; `undefined` means the deployment default. */
|
|
45
|
+
export type AdvancedSearchRunner = (query: string, limit: number, timeRange: TimeRange | undefined, signal?: AbortSignal) => Promise<AdvancedSearchOutcome>;
|
|
46
|
+
/** A tool definition in the host registry's native shape. */
|
|
47
|
+
export interface AdvancedSearchDefinition {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
parameters: ToolJsonSchema;
|
|
51
|
+
output: {
|
|
52
|
+
schema: ToolJsonSchema;
|
|
53
|
+
render: (args: unknown, value: AdvancedSearchValue) => ToolContent[];
|
|
54
|
+
};
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
isConcurrencySafe?: (args: unknown) => boolean;
|
|
57
|
+
execute: (args: unknown, exec: {
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
}) => Promise<AdvancedSearchValue>;
|
|
60
|
+
}
|
|
61
|
+
/** The slice of the tool registry this module needs. */
|
|
62
|
+
export interface AdvancedSearchRegistryLike {
|
|
63
|
+
register(definition: AdvancedSearchDefinition): unknown;
|
|
64
|
+
get?(name: string, scope?: unknown): unknown;
|
|
65
|
+
}
|
|
66
|
+
/** Construction seams. */
|
|
67
|
+
export interface AdvancedSearchOptions {
|
|
68
|
+
/** Registration diagnostics. */
|
|
69
|
+
warn?: (message: string) => void;
|
|
70
|
+
}
|
|
71
|
+
/** A successful registration plus the exact way to undo it. */
|
|
72
|
+
export interface AdvancedSearchRegistration {
|
|
73
|
+
name: string;
|
|
74
|
+
dispose: () => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Remove a relative window phrase that the structured window already carries.
|
|
78
|
+
* "过去 7 天内 Chrome…" searches for `7` and `内`, not for Chrome; with an
|
|
79
|
+
* explicit `timeRange` the phrase is redundant and only adds noise.
|
|
80
|
+
* @param query - the caller's query.
|
|
81
|
+
* @returns the query without a relative-time phrase, or the original when the
|
|
82
|
+
* removal would leave nothing.
|
|
83
|
+
*/
|
|
84
|
+
export declare function stripRelativeWindow(query: string): string;
|
|
85
|
+
/** Format the model-facing result text. */
|
|
86
|
+
export declare function formatAdvancedSearchValue(value: AdvancedSearchValue): string;
|
|
87
|
+
/**
|
|
88
|
+
* Build the tool definition the host registry accepts.
|
|
89
|
+
* @param name - `advanced_search`, or the fallback when that name is taken.
|
|
90
|
+
* @param runSearch - executes one search through the plugin's normal path.
|
|
91
|
+
* @returns a registry-ready definition.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createAdvancedSearchDefinition(name: string, runSearch: AdvancedSearchRunner): AdvancedSearchDefinition;
|
|
94
|
+
/**
|
|
95
|
+
* Pick the tool name this deployment can accept.
|
|
96
|
+
* @param tools - the live registry.
|
|
97
|
+
* @returns the preferred or fallback name.
|
|
98
|
+
*/
|
|
99
|
+
export declare function pickAdvancedSearchToolName(tools: AdvancedSearchRegistryLike): string;
|
|
100
|
+
/**
|
|
101
|
+
* Register the tool when a registry is available.
|
|
102
|
+
* @param tools - the live registry.
|
|
103
|
+
* @param runSearch - executes one search through the plugin's normal path.
|
|
104
|
+
* @param options - diagnostics.
|
|
105
|
+
* @returns the registered name and its disposer, or `undefined` when skipped.
|
|
106
|
+
*/
|
|
107
|
+
export declare function registerAdvancedSearchTool(tools: AdvancedSearchRegistryLike, runSearch: AdvancedSearchRunner, options?: AdvancedSearchOptions): AdvancedSearchRegistration | undefined;
|