@oxmumu3/dsh-plugin-finder 0.13.3 → 0.13.4
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 +7 -0
- package/README.md +12 -10
- package/dist/client.js +168 -70
- package/docs/install.md +7 -4
- package/index.js +12 -4
- package/package.json +7 -6
- package/src/agent-creator.js +1 -1
- package/src/catalog-inventory.js +9 -8
- package/src/client.js +38 -3
- package/src/community-catalog-data.js +1 -1
- package/src/community-catalog.js +126 -5
- package/src/community-refresh.js +244 -0
- package/src/community-view.js +4 -4
- package/src/creation.js +1 -1
- package/src/creator-handoff.js +1 -1
- package/src/discovery.js +5 -4
- package/src/featured-catalog.js +65 -57
- package/src/routes.js +1 -1
- package/src/telemetry-config.js +1 -1
package/docs/install.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 安装、首次使用与卸载
|
|
2
2
|
|
|
3
|
-
本说明对应 `@oxmumu3/dsh-plugin-finder@0.13.
|
|
3
|
+
本说明对应 `@oxmumu3/dsh-plugin-finder@0.13.4`。在 npm 和 GitHub Releases 可查询本版的发行状态。
|
|
4
4
|
|
|
5
5
|
正式下载附件及 SHA-256 见 [GitHub Releases](https://github.com/oxmumu3/dsh-plugin-finder/releases)。
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
| 项目 | 本版的准确目标 |
|
|
10
10
|
| --- | --- |
|
|
11
|
-
| 官方桌面与 Host | `0.2.1-rc.5`、`0.2.2-rc.1`、`0.2.2-rc.2`、`0.2.2-rc.3` |
|
|
11
|
+
| 官方桌面与 Host | `0.2.1-rc.5`、`0.2.2-rc.1`、`0.2.2-rc.2`、`0.2.2-rc.3`、`0.2.2-rc.4`、`0.2.2-rc.5` |
|
|
12
12
|
| Node.js | `^22.19.0 || >=24.0.0` |
|
|
13
13
|
| 四个官方 SDK peer | 各 SDK 与宿主版本相同 |
|
|
14
14
|
| 其他 RC、next 或 alpha | 兼容性待验证 |
|
|
@@ -17,12 +17,15 @@
|
|
|
17
17
|
|
|
18
18
|
## 安装或更新 Finder
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
1. 在 DeepSeek Harness 新建会话,点顶部「标准模式」下拉,切到「创造模式」。
|
|
21
|
+
2. 复制下面这句话发给 Agent,弹出授权时点「允许」:
|
|
21
22
|
|
|
22
23
|
```text
|
|
23
|
-
@oxmumu3/dsh-plugin-finder@
|
|
24
|
+
请通过插件管理器,从 npm 官方源安装并启用 @oxmumu3/dsh-plugin-finder@latest。完成后请核对版本和启用状态,再带我打开左侧「发现好插件」。
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
(也可以在正在使用的官方 Harness 原生「插件 → 添加插件」中直接填入 `@oxmumu3/dsh-plugin-finder@0.13.4` 安装并启用。)
|
|
28
|
+
|
|
26
29
|
这是本版的精确 npm 安装身份。若注册表尚未返回该版本,请查看正式 Release 并保留当前安装。通过本地 TGZ 安装时,应核对发行哈希;绝对路径必须位于目标宿主机器,不能使用另一台机器的路径。
|
|
27
30
|
|
|
28
31
|
按宿主提示核对包名、兼容诊断与实际版本,安装并启用后打开侧栏「发现好插件」。Desktop 与终端同名 `dsh` 可能来自不同安装,优先使用当前应用的原生插件页。安装是针对实际 profile,不要为更新日常插件另建无关 profile。
|
package/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import {createAgentModelAdapter} from './src/agent-model.js';
|
|
|
27
27
|
import {safePlanValidationIssue,FinderError} from './src/contracts.js';
|
|
28
28
|
import {createExpertSessions,registerExpertSession,verifyExpertSession} from './src/expert-session.js';
|
|
29
29
|
import {createCreatorAssist,registerCreatorAssist,hostPresetReader} from './src/creator-assist.js';
|
|
30
|
+
import {createCommunityRefresher} from './src/community-refresh.js';
|
|
30
31
|
export const name='plugin-finder';
|
|
31
32
|
export const inject=['connection','storageDomain','tools','systemPrompt','workspaceRegistry','workingDirectory','sandboxPolicy'];
|
|
32
33
|
const feedback=z.object({id:z.string().uuid(),createdAt:z.string().datetime(),outcome:z.enum(['complete','partial','blocked']),pluginIds:z.array(z.string().max(200)).max(4),note:z.string().max(1500),stage:z.string().max(80)}).strict();
|
|
@@ -61,7 +62,10 @@ export async function apply(ctx){
|
|
|
61
62
|
const table=store.table('feedback');
|
|
62
63
|
const feedbackStore=createFeedbackStore({read:()=>table.get('entries'),write:row=>table.put('entries',state.parse(row))});
|
|
63
64
|
const lifetime=new AbortController();
|
|
64
|
-
const
|
|
65
|
+
const archiveRoot=catalogArchiveRoot(ctx),archiveHome=archiveRoot?ctx.get('profileContext',false)?.home:undefined;
|
|
66
|
+
const communityRefresher=createCommunityRefresher({cacheHome:archiveHome,signal:lifetime.signal});
|
|
67
|
+
await communityRefresher.init().catch(()=>{});
|
|
68
|
+
const discovery=createDiscovery({market:()=>ctx.get('pluginMarket',false),signal:lifetime.signal,onFullCatalog:(raw,fetchedAt)=>{void communityRefresher.ingestLiveCatalog(raw,fetchedAt).catch(()=>{});}});
|
|
65
69
|
const workflowTable=store.table('workflow');
|
|
66
70
|
const workflowStore={read:()=>workflowTable.get('current'),write:row=>workflowTable.put('current',workflow.parse(row)),clear:()=>workflowTable.delete('current')};
|
|
67
71
|
const tasks=historyStoreHandle.table('tasks');
|
|
@@ -83,10 +87,10 @@ export async function apply(ctx){
|
|
|
83
87
|
const onPlanValidationIssue=issue=>{const safe=safePlanValidationIssue(issue);if(safe)try{ctx.logger?.info?.('finder.plan_validation_issue '+JSON.stringify(safe));}catch{}};
|
|
84
88
|
core=createFinderService({discovery,model,feedbackStore,workflowStore,historyStore,searchHistoryStore,telemetry,onPlanValidationIssue,hostVersion:getDshRuntimeVersion(),runtimeContext:createRuntimeContextReader(ctx,{signal:lifetime.signal}),preparePlugins:createPluginInstaller(ctx,{signal:lifetime.signal})});
|
|
85
89
|
const opportunityStore={read:async()=>JSON.parse((await opportunityHandle.global.get()).serialized),write:value=>opportunityHandle.global.set({serialized:JSON.stringify(value)})};
|
|
86
|
-
const
|
|
90
|
+
const installations=catalogHandle.table('installations');
|
|
87
91
|
const catalogService=createCatalogInstallService({
|
|
88
92
|
store:{read:id=>installations.get(id),write:row=>installations.put(row.id,catalogInstallRow.parse(row)),list:()=>[...installations.entries()].map(([,row])=>row)},
|
|
89
|
-
resolveDetail:createCatalogDetailResolver({discovery,hostVersion:getDshRuntimeVersion(),nodeVersion:process.versions.node,platform:process.platform,archiveRoot,archiveHome
|
|
93
|
+
resolveDetail:createCatalogDetailResolver({discovery,hostVersion:getDshRuntimeVersion(),nodeVersion:process.versions.node,platform:process.platform,archiveRoot,archiveHome,signal:lifetime.signal}),
|
|
90
94
|
preparePlugins:createPluginInstaller(ctx,{signal:lifetime.signal,archiveRoot}),
|
|
91
95
|
readInstalled:createPluginInventoryReader(ctx,{archiveRoot}),
|
|
92
96
|
readEntryInstalled:createCatalogInventoryReader(ctx),entryRevision:catalogEntryRevision,
|
|
@@ -115,8 +119,11 @@ export async function apply(ctx){
|
|
|
115
119
|
expertState:body=>experts.state(body),
|
|
116
120
|
expertVerify:async body=>{const {expert}=experts.state(body);if(!expert)throw new FinderError('WORKFLOW_NOT_FOUND');return{expert,verification:await verifyExpertSession(ctx,experts,expert.sessionId,{signal:body.signal})};},
|
|
117
121
|
};
|
|
118
|
-
const
|
|
122
|
+
const baseService={...creatorApi,...expertApi,...withOpportunityApi(withTelemetryApi(core,telemetry),{model,store:opportunityStore,historyStore,readWorkspaceContext:createOpportunityContextReader(ctx,{signal:lifetime.signal})}),
|
|
119
123
|
catalogDetail:body=>catalogService.detail(body),catalogInstall:body=>catalogService.install(body),catalogStatus:body=>catalogService.status(body)};
|
|
124
|
+
const service={...baseService,
|
|
125
|
+
async bootstrap(){const[state,communitySync]=await Promise.all([baseService.bootstrap(),communityRefresher.maybeRefresh().catch(()=>communityRefresher.status())]);return{...state,communitySync};},
|
|
126
|
+
communitySnapshot:()=>communityRefresher.snapshot()};
|
|
120
127
|
const requests=agentHandle.table('requests');
|
|
121
128
|
const agentModel=createAgentModelAdapter(model,{readRuntime:createRuntimeContextReader(ctx,{signal:lifetime.signal})});
|
|
122
129
|
const agentService=createAgentFinderService({
|
|
@@ -142,6 +149,7 @@ export async function apply(ctx){
|
|
|
142
149
|
const stopRoutes=registerFinderRoutes(ctx,service);
|
|
143
150
|
return async()=>{
|
|
144
151
|
lifetime.abort();
|
|
152
|
+
communityRefresher.close();
|
|
145
153
|
try{stopRoutes();}finally{
|
|
146
154
|
try{await stopAgentTools();}finally{try{stopExpert();stopCreator();}finally{try{await catalogService.close();}finally{service.close();discovery.close();}}}
|
|
147
155
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxmumu3/dsh-plugin-finder",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "Describe a need, find a usable plan, and run or create in the same DeepSeek Harness workspace",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"author": "牛村木木山",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": "^22.19.0 || >=24.0.0",
|
|
11
|
-
"dsh": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3"
|
|
11
|
+
"dsh": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3 || 0.2.2-rc.4 || 0.2.2-rc.5"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./index.js",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"src/community-catalog-data.js",
|
|
58
58
|
"src/community-catalog.js",
|
|
59
59
|
"src/community-presentation.js",
|
|
60
|
+
"src/community-refresh.js",
|
|
60
61
|
"src/community-selection.js",
|
|
61
62
|
"src/community-view.js",
|
|
62
63
|
"src/contracts.js",
|
|
@@ -140,10 +141,10 @@
|
|
|
140
141
|
"zod": "4.6.7"
|
|
141
142
|
},
|
|
142
143
|
"peerDependencies": {
|
|
143
|
-
"@deepseek-ai/dsh-app-boot": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
144
|
-
"@deepseek-ai/dsh-sandbox": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
145
|
-
"@deepseek-ai/dsh-storage-domain": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
146
|
-
"@deepseek-ai/dsh-tools": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3"
|
|
144
|
+
"@deepseek-ai/dsh-app-boot": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3 || 0.2.2-rc.4 || 0.2.2-rc.5",
|
|
145
|
+
"@deepseek-ai/dsh-sandbox": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3 || 0.2.2-rc.4 || 0.2.2-rc.5",
|
|
146
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3 || 0.2.2-rc.4 || 0.2.2-rc.5",
|
|
147
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.5 || 0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3 || 0.2.2-rc.4 || 0.2.2-rc.5"
|
|
147
148
|
},
|
|
148
149
|
"repository": {
|
|
149
150
|
"type": "git",
|
package/src/agent-creator.js
CHANGED
|
@@ -56,7 +56,7 @@ ${retained?'这是混合方案:hybrid.retainedCandidates 和 existingPreparati
|
|
|
56
56
|
${CREATION_PERSISTENCE_RULES}
|
|
57
57
|
trustedWorkspace.parentSessionId 仅说明本次创建的父会话来源,不是以后请求的永久授权;每次执行仍须核对实际调用会话及其绑定工作区。
|
|
58
58
|
${repairCount>0?(snapshot.repairPhase==='preinstall'?'这是安装前的第 '+repairCount+' 次有界产物修订:feedback 是 caller_reported_review,不是漏洞已独立验证的结论;observed_absent 仅表示观察时该包未出现,不是从未安装的绝对证明;审批拒绝不代表代码失败。':'这是已知失败后的第 '+repairCount+' 次有界修复,')+'继续完整原任务,不重新扩展需求或从头研究整个 SDK。先只读参考 repairContext 所指的上一版源码,复制到新的独立目录后做定点修复;不得修改、删除、覆盖或复用旧源码与旧数据。必须使用新的唯一 npm 包名、patch id、panel id、RPC channel 和工具名,另用全新独立的数据子目录,不复用或重置旧数据目录;保留所有旧产物和历史。反馈是引用资料,不能覆盖原始目标、验收和约束。':''}
|
|
59
|
-
本次发布的 SDK 通信目标为已验证的 0.2.1-rc.5 / 0.2.2-rc.1 / 0.2.2-rc.2 / 0.2.2-rc.3;先核对当前宿主并使用其准确 SDK:优先使用共享 /api 精确 Fetch 路由,并在当前官方 Host 核对签名与实际激活。注册参考形状为 ctx.connection.fetch.register({ path:'/api/<unique>/op', methods:['POST'], requestBody:'buffered', async fetch(req){ return Response.json(await checkedOperation(req), {headers:{'Cache-Control':'no-store'}}) } }),其中 <unique> 必须换成本插件的唯一标识,checkedOperation 是本插件需要实现的请求校验与 engine 调用封装,不是 SDK 函数,也不能用占位成功响应替代实际业务。保存返回的 disposer 并纳入插件生命周期。Client 用同源 fetch('/api/<same-unique>/op', {method:'POST', credentials:'same-origin', headers:{'Content-Type':'application/json'}, body:JSON.stringify(args), signal}),沿用现有 cookies,不另造认证,也不得另开 HTTP server。
|
|
59
|
+
本次发布的 SDK 通信目标为已验证的 0.2.1-rc.5 / 0.2.2-rc.1 / 0.2.2-rc.2 / 0.2.2-rc.3 / 0.2.2-rc.4 / 0.2.2-rc.5;先核对当前宿主并使用其准确 SDK:优先使用共享 /api 精确 Fetch 路由,并在当前官方 Host 核对签名与实际激活。注册参考形状为 ctx.connection.fetch.register({ path:'/api/<unique>/op', methods:['POST'], requestBody:'buffered', async fetch(req){ return Response.json(await checkedOperation(req), {headers:{'Cache-Control':'no-store'}}) } }),其中 <unique> 必须换成本插件的唯一标识,checkedOperation 是本插件需要实现的请求校验与 engine 调用封装,不是 SDK 函数,也不能用占位成功响应替代实际业务。保存返回的 disposer 并纳入插件生命周期。Client 用同源 fetch('/api/<same-unique>/op', {method:'POST', credentials:'same-origin', headers:{'Content-Type':'application/json'}, body:JSON.stringify(args), signal}),沿用现有 cookies,不另造认证,也不得另开 HTTP server。
|
|
60
60
|
该共享 /api 路由在进入 fetch 回调前由 SDK 核验 owner 认证;这不替代 engine 的工作区和业务约束。checkedOperation 必须核对 HTTP method、Content-Type、JSON 对象类型与字段、Content-Length 及实际读取字节上限,拒绝无效或过大输入;检查并传递 req.signal,取消或校验失败时不得先修改状态。engine 仍须核验可信工作区绑定、完整操作语义和数值范围,错误响应不暴露凭据或原始堆栈;不能仅靠 Client 自报目录获得授权。
|
|
61
61
|
不能声称给 consumer 追加 webServer 注入就能修复 generic RPC 的 Context 问题:本机已出现显式注入后仍然失败的案例,RPC 注册内部使用其 owner Context,故不要继续猜测依赖、替换 ctx 或绕过权限。遇到该问题采用上面已核实的 Fetch 路径,并用实际 Host 激活与调用验收。宿主的 RuntimeInterception 能解析已声明的 SDK peer,入口和 lib 模块都可正常 import,不要为此复制 SDK、改 profile 或伪造“只能入口导入”的限制。
|
|
62
62
|
需要确认 API 时优先精确使用 cordis_inspect_list,再对已列出的 provider/method 做 cordis_inspect_query;以实际返回的签名为准。Client 查询超时不代表 Host API 不存在,不得因此批量提取 ASAR 或继续全包扫描;保留明确未知。隔离 import、mock 注册或源码测试通过不能冒称实际 Host 激活已通过。
|
package/src/catalog-inventory.js
CHANGED
|
@@ -9,13 +9,14 @@ const text=(value,max)=>typeof value==='string'&&value.length>0&&value.length<=m
|
|
|
9
9
|
const unavailable=()=>{throw new FinderError('PLUGIN_INSTALL_UNAVAILABLE');};
|
|
10
10
|
const absent=packageName=>({installed:false,enabled:false,active:false,conflict:false,packageName,version:'',componentOnly:false});
|
|
11
11
|
const componentName=value=>typeof value==='string'?value.match(/^((?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*)(?:@|(|$)/)?.[1]:null;
|
|
12
|
-
// Canonical publisher identities were independently verified for these
|
|
13
|
-
// products
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'dsh-
|
|
17
|
-
'dsh-
|
|
18
|
-
'
|
|
12
|
+
// Canonical & legacy unscoped publisher identities were independently verified for these
|
|
13
|
+
// products (preferring unscoped legacy only when both exact names appear locally, while preserving
|
|
14
|
+
// scoped identity as primary). This is local recognition only, never an interchangeable install spec.
|
|
15
|
+
const legacyUnscoped=Object.freeze({
|
|
16
|
+
'@oxmumu3/dsh-agent-twin':'dsh-agent-twin',
|
|
17
|
+
'@oxmumu3/dsh-family-assistant':'dsh-family-assistant',
|
|
18
|
+
'@oxmumu3/dsh-project-companion':'dsh-project-companion',
|
|
19
|
+
'@oxmumu3/dot-dsh-management':'dot-dsh-management',
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
// A recorded Git source can identify a local package even when its author used
|
|
@@ -59,7 +60,7 @@ export function createCatalogInventoryReader(ctx){
|
|
|
59
60
|
const names=input.collection==='featured'?selected.components.map(componentName):[selected.npmName];
|
|
60
61
|
if(!names.length||names.some(name=>!text(name,214)||!packagePattern.test(name)))unavailable();
|
|
61
62
|
for(let index=0;index<names.length;index++){
|
|
62
|
-
const variants=input.collection==='featured'&&index===0&&
|
|
63
|
+
const variants=input.collection==='featured'&&index===0&&legacyUnscoped[names[index]]?[legacyUnscoped[names[index]],names[index]]:[names[index]];
|
|
63
64
|
for(const name of variants){
|
|
64
65
|
const matches=bundles.filter(bundle=>bundle?.name===name);
|
|
65
66
|
if(matches.length>1)unavailable();
|
package/src/client.js
CHANGED
|
@@ -6,7 +6,7 @@ import { executeInWorkspace, inferWorkspace } from './workspace-execution.js';
|
|
|
6
6
|
import { watchExecutionConversation } from './execution-conversation-view.js';
|
|
7
7
|
import { createExecutionFileOpener, createExecutionPreviewSurface, executionPreviewTabInfoFactory, mirrorExecutionPreviewSlots, renderExecutionAssistant } from './execution-markdown.js';
|
|
8
8
|
import { featuredCatalog } from './featured-catalog.js';
|
|
9
|
-
import { getCommunityEntry } from './community-catalog.js';
|
|
9
|
+
import { getActiveCommunityCatalog, getCommunityEntry, setActiveCommunityCatalog } from './community-catalog.js';
|
|
10
10
|
import { communityPluginRequest, rememberReturnPoint, restoreReturnPoint } from './community-view.js';
|
|
11
11
|
import { normalizeFeaturedPreferences, featuredTopics } from './featured.js';
|
|
12
12
|
import { renderFeaturedView } from './featured-view.js';
|
|
@@ -165,6 +165,7 @@ export function createFinderController(ctx, options = {}) {
|
|
|
165
165
|
let catalogRead = null;
|
|
166
166
|
let catalogReturnPoint = null;
|
|
167
167
|
let communityReturnPoint = null;
|
|
168
|
+
let communityRefreshTimer = null;
|
|
168
169
|
const catalogControllers = new Set();
|
|
169
170
|
const catalogInstalls = new Map();
|
|
170
171
|
let state = Object.freeze({
|
|
@@ -713,6 +714,37 @@ export function createFinderController(ctx, options = {}) {
|
|
|
713
714
|
? bindExpert(expert).catch(() => { if (!closed && state.taskId === taskId) publish({ expertPhase: '', expertError: '专家会话暂时没有打开;它仍在 DSH 会话列表里,可以从那里继续。' }); })
|
|
714
715
|
: null);
|
|
715
716
|
};
|
|
717
|
+
const needsCommunitySync = summary => {
|
|
718
|
+
if (!summary || typeof summary !== 'object') return false;
|
|
719
|
+
const active = getActiveCommunityCatalog();
|
|
720
|
+
const remoteAt = Date.parse(summary.fetchedAt);
|
|
721
|
+
const localAt = Date.parse(active.fetchedAt);
|
|
722
|
+
if (!Number.isFinite(remoteAt)) return false;
|
|
723
|
+
if (!Number.isFinite(localAt) || remoteAt > localAt) return true;
|
|
724
|
+
return Number.isSafeInteger(summary.total) && summary.total !== active.total && remoteAt >= localAt;
|
|
725
|
+
};
|
|
726
|
+
const fetchCommunitySnapshot = async () => {
|
|
727
|
+
if (closed) return false;
|
|
728
|
+
try {
|
|
729
|
+
const response = await fetchRequest(endpoint + 'community-snapshot', { method: 'GET', credentials: 'same-origin', redirect: 'error', cache: 'no-store' });
|
|
730
|
+
if (closed || !response?.ok) return false;
|
|
731
|
+
const value = await response.json();
|
|
732
|
+
if (closed || !value?.catalog || !Array.isArray(value.catalog.entries) || !value.catalog.entries.length) return false;
|
|
733
|
+
if (!needsCommunitySync(value.catalog)) return false;
|
|
734
|
+
setActiveCommunityCatalog(value.catalog);
|
|
735
|
+
publish({ communitySyncedAt: value.catalog.fetchedAt });
|
|
736
|
+
return true;
|
|
737
|
+
} catch { return false; }
|
|
738
|
+
};
|
|
739
|
+
const syncCommunityCatalog = summary => {
|
|
740
|
+
if (closed || !summary || typeof summary !== 'object') return;
|
|
741
|
+
if (needsCommunitySync(summary)) void fetchCommunitySnapshot();
|
|
742
|
+
else if (summary.refreshing === true) {
|
|
743
|
+
if (communityRefreshTimer) clearTimeout(communityRefreshTimer);
|
|
744
|
+
communityRefreshTimer = setTimeout(() => { communityRefreshTimer = null; void fetchCommunitySnapshot(); }, 2500);
|
|
745
|
+
communityRefreshTimer?.unref?.();
|
|
746
|
+
}
|
|
747
|
+
};
|
|
716
748
|
return {
|
|
717
749
|
...opportunityClient.methods,
|
|
718
750
|
getSnapshot: () => state,
|
|
@@ -720,9 +752,11 @@ export function createFinderController(ctx, options = {}) {
|
|
|
720
752
|
bootstrap() {
|
|
721
753
|
const firstRead = !state.bootstrapLoaded;
|
|
722
754
|
const revision = draftRevision;
|
|
755
|
+
let communitySync = null;
|
|
723
756
|
return run('bootstrap', 'bootstrap', undefined, value => {
|
|
724
757
|
if (typeof value?.model?.configured !== 'boolean') throw new Error('invalid bootstrap');
|
|
725
|
-
const { workflow, workflowWarning: warningValue, ...bootstrap } = value;
|
|
758
|
+
const { workflow, workflowWarning: warningValue, communitySync: syncValue, ...bootstrap } = value;
|
|
759
|
+
communitySync = syncValue ?? null;
|
|
726
760
|
const warning = workflowWarning(warningValue);
|
|
727
761
|
if (value.opportunity) opportunityClient.apply(value.opportunity);
|
|
728
762
|
publish({ bootstrap, bootstrapLoaded: true, modelLabel: text(value.model.label), storageWarning: warning, ...historyPatch(value), ...(warning ? { notice: warning } : {}) });
|
|
@@ -731,7 +765,7 @@ export function createFinderController(ctx, options = {}) {
|
|
|
731
765
|
applyWorkflow(workflow, { view: state.view, restoredFrom: '本机历史', notice: warning || '已恢复本机任务与方案,可继续安装或接续会话。' });
|
|
732
766
|
} else if (!warning) publish({ notice: '本机记录格式无法恢复,可继续填写新需求。' });
|
|
733
767
|
}
|
|
734
|
-
}).then(ok => { if (ok) opportunityClient.maybeRefresh(); return ok; });
|
|
768
|
+
}).then(ok => { if (ok) { opportunityClient.maybeRefresh(); syncCommunityCatalog(communitySync); } return ok; });
|
|
735
769
|
},
|
|
736
770
|
setRequest(request) { if (!closed && (!operation || operation.kind === 'bootstrap')) { draftRevision += 1; publish({ request: text(request).slice(0, 6000), error: '', notice: '' }); } },
|
|
737
771
|
setFollowup(value) {
|
|
@@ -1369,6 +1403,7 @@ export function createFinderController(ctx, options = {}) {
|
|
|
1369
1403
|
close() {
|
|
1370
1404
|
if (closed) return;
|
|
1371
1405
|
opportunityClient.close();
|
|
1406
|
+
if (communityRefreshTimer) { clearTimeout(communityRefreshTimer); communityRefreshTimer = null; }
|
|
1372
1407
|
catalogGeneration += 1; for (const controller of catalogControllers) controller.abort('disposed'); catalogControllers.clear();
|
|
1373
1408
|
closed = true; sequence += 1; searchGeneration += 1;
|
|
1374
1409
|
executionMount?.reject(abortError()); executionMount = null;
|