dsh-desktop-enhance 0.12.4 → 0.13.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/README.md +8 -2
- package/lib/client.js +13 -2
- package/lib/index.d.ts +45 -34
- package/lib/index.js +132 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,6 +178,12 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
|
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
### 子智能体模型实时跟随
|
|
182
|
+
|
|
183
|
+
默认开启,位于插件设置「会话能力 → 看板与能力治理」,紧随「扩展与能力治理」。沿用宿主「插件 → 子智能体」的模型授权,不需要维护第二份名单。
|
|
184
|
+
|
|
185
|
+
安装此功能后先重启 App;之后保存模型授权,所有已有会话后续的模型查询与显式委派立即跟随,无需新建会话或再次重启。**不会给既有子智能体换模型,不影响默认模型继承,也不覆盖 workflow 内部委派**。关闭此增强后,各会话恢复原有授权快照。详见[子智能体模型实时跟随](docs/features/subagent-model-follow.md)。
|
|
186
|
+
|
|
181
187
|
### 上下文管理
|
|
182
188
|
|
|
183
189
|
压缩是自动的,但**什么时候压、压完还记得什么**过去只能交给默认值。阈值与剪枝放在**原生**上下文占用弹窗里(点输入框上方的占用率按钮);压缩后的 Skill 筛选进度直接显示在对话中。
|
|
@@ -224,7 +230,7 @@ dsh plugin --profile desktop update dsh-desktop-enhance
|
|
|
224
230
|
|
|
225
231
|
只改插件内容的话,**刷新页面即可**,不必重启。
|
|
226
232
|
|
|
227
|
-
> ⚠️ **例外:如果插件更新里改了「宿主半侧」(`src/index.ts` / `src/suggest/**` / `src/session-info/**` / `src/capabilities/**` / `src/tools-manager/**` / `src/skills-manager/**`),必须重启 App** —— 刷新页面不够。此时设置卡片会直接把不可用的项**置灰**并提示你重启,而不是等你点了几次之后才报「设置没写进去」。**看到那句提示 = 重启即可解决。**
|
|
233
|
+
> ⚠️ **例外:如果插件更新里改了「宿主半侧」(`src/index.ts` / `src/suggest/**` / `src/session-info/**` / `src/capabilities/**` / `src/tools-manager/**` / `src/skills-manager/**` / `src/subagent-model-follow/**`),必须重启 App** —— 刷新页面不够。此时设置卡片会直接把不可用的项**置灰**并提示你重启,而不是等你点了几次之后才报「设置没写进去」。**看到那句提示 = 重启即可解决。**
|
|
228
234
|
|
|
229
235
|
## 开关
|
|
230
236
|
|
|
@@ -232,7 +238,7 @@ dsh plugin --profile desktop update dsh-desktop-enhance
|
|
|
232
238
|
|
|
233
239
|
> 侧栏 **插件** → 插件列表里选中 **`dsh-desktop-enhance`** → 页面里的 **「UI 增强」** 一栏
|
|
234
240
|
|
|
235
|
-
开关列表:**页内查找** / **轮次编号** / **压缩行高亮** / **建议** / **每步耗时** / **插件上下文审计** / **已归档会话只读查看** / **侧栏删除已归档会话** / **会话信息** / **扩展与能力治理** / **上下文管理** / **压缩后恢复 Skill** / **压缩后恢复近期原文** / **图片 Token
|
|
241
|
+
开关列表:**页内查找** / **轮次编号** / **压缩行高亮** / **建议** / **每步耗时** / **插件上下文审计** / **已归档会话只读查看** / **侧栏删除已归档会话** / **会话信息** / **扩展与能力治理** / **子智能体模型实时跟随** / **上下文管理** / **压缩后恢复 Skill** / **压缩后恢复近期原文** / **图片 Token 补价**。默认全开;各功能的生效范围见对应说明,可逐项关闭恢复原生行为。
|
|
236
242
|
|
|
237
243
|
|
|
238
244
|
|
package/lib/client.js
CHANGED
|
@@ -1090,6 +1090,8 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
1090
1090
|
"settings.sessionInfo.hint": "在主对话区右上角悬浮展示当前会话的信息看板(如已注入的 Skill、触发方式与轮次),点击条目可打开 Skill 预览",
|
|
1091
1091
|
"settings.capabilityManager": "扩展与能力治理",
|
|
1092
1092
|
"settings.capabilityManager.hint": "按逻辑插件与内置能力组统一管控模型工具、插件 Skill、系统提示词、命令与对话钩子,并独立管理目录发现的本地 Skill(设置页配全局默认,会话右上角按会话实时开关并同步全部子智能体)",
|
|
1093
|
+
"settings.subagentModelFollow": "子智能体模型实时跟随",
|
|
1094
|
+
"settings.subagentModelFollow.hint": "沿用宿主「插件 → 子智能体」的模型授权,保存后所有已有会话的后续查询与显式委派立即跟随;不会切换既有子智能体的模型,不覆盖 workflow;关闭后恢复各会话原快照",
|
|
1093
1095
|
"settings.contextManager": "上下文管理",
|
|
1094
1096
|
"settings.contextManager.hint": "在输入框下方的上下文占用弹窗里,为本会话设定自动压缩阈值并手动触发一次上下文剪枝(阈值只提前、不会推迟宿主触发)",
|
|
1095
1097
|
"settings.recentConversation": "压缩后恢复近期原文",
|
|
@@ -1504,6 +1506,8 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
1504
1506
|
"settings.sessionInfo.hint": "Shows a floating Session Info inspector in the top-right corner of the conversation view (active skills, trigger source, and turn); click an item to open its skill preview",
|
|
1505
1507
|
"settings.capabilityManager": "Plugins & capabilities",
|
|
1506
1508
|
"settings.capabilityManager.hint": "Control model tools, plugin skills, prompts, commands, and hooks by capability unit alongside directory-based local skills (global defaults here; live per-session sync across main & subagents in Session Info)",
|
|
1509
|
+
"settings.subagentModelFollow": "Live subagent model authorization",
|
|
1510
|
+
"settings.subagentModelFollow.hint": "Use model authorization from the host Plugins → Subagents. Once saved, subsequent discovery and explicit delegation in all existing sessions follow immediately; existing subagents keep their models and workflow is not covered. Turning this off restores each session’s original snapshot",
|
|
1507
1511
|
"settings.contextManager": "Context manager",
|
|
1508
1512
|
"settings.contextManager.hint": "Set this session's auto-compaction threshold and trigger one context prune from the context-usage popup above the composer (a threshold only moves compaction earlier, never later)",
|
|
1509
1513
|
"settings.recentConversation": "Restore recent conversation after compaction",
|
|
@@ -2225,6 +2229,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
2225
2229
|
sessionModel: "data-desktop-enhance-off-session-model",
|
|
2226
2230
|
abnormalFork: "data-desktop-enhance-off-abnormal-fork",
|
|
2227
2231
|
capabilityManager: "data-desktop-enhance-off-capability-manager",
|
|
2232
|
+
subagentModelFollow: "data-desktop-enhance-off-subagent-model-follow",
|
|
2228
2233
|
contextManager: "data-desktop-enhance-off-context-manager",
|
|
2229
2234
|
skillRecovery: "data-desktop-enhance-off-skill-recovery",
|
|
2230
2235
|
recentConversation: "data-desktop-enhance-off-recent-conversation",
|
|
@@ -2246,6 +2251,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
2246
2251
|
"sessionModel",
|
|
2247
2252
|
"abnormalFork",
|
|
2248
2253
|
"capabilityManager",
|
|
2254
|
+
"subagentModelFollow",
|
|
2249
2255
|
"contextManager",
|
|
2250
2256
|
"skillRecovery",
|
|
2251
2257
|
"recentConversation",
|
|
@@ -2311,7 +2317,11 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
2311
2317
|
]
|
|
2312
2318
|
}, {
|
|
2313
2319
|
id: "governance",
|
|
2314
|
-
fields: [
|
|
2320
|
+
fields: [
|
|
2321
|
+
"sessionInfo",
|
|
2322
|
+
"capabilityManager",
|
|
2323
|
+
"subagentModelFollow"
|
|
2324
|
+
]
|
|
2315
2325
|
}],
|
|
2316
2326
|
fields: [
|
|
2317
2327
|
"contextManager",
|
|
@@ -2319,7 +2329,8 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
2319
2329
|
"skillRecovery",
|
|
2320
2330
|
"imagePricing",
|
|
2321
2331
|
"sessionInfo",
|
|
2322
|
-
"capabilityManager"
|
|
2332
|
+
"capabilityManager",
|
|
2333
|
+
"subagentModelFollow"
|
|
2323
2334
|
]
|
|
2324
2335
|
},
|
|
2325
2336
|
{
|
package/lib/index.d.ts
CHANGED
|
@@ -191,12 +191,12 @@ interface SessionListMeta {
|
|
|
191
191
|
readonly archived?: boolean;
|
|
192
192
|
}
|
|
193
193
|
declare function handleSessionStateRequest(state: SessionState, request: Request, retry?: () => Promise<void>, lifetime?: AbortSignal, describeSessions?: (sessionIds: readonly string[], signal: AbortSignal) => Promise<ReadonlyMap<string, SessionListMeta>>): Promise<Response>;
|
|
194
|
-
interface HostContext$
|
|
194
|
+
interface HostContext$3 {
|
|
195
195
|
get(name: string): unknown;
|
|
196
196
|
readonly reflect: {
|
|
197
197
|
provide(name: string, value: unknown): () => void;
|
|
198
198
|
};
|
|
199
|
-
inject(deps: readonly string[], callback: (ctx: HostContext$
|
|
199
|
+
inject(deps: readonly string[], callback: (ctx: HostContext$3) => void): {
|
|
200
200
|
dispose(): Promise<unknown>;
|
|
201
201
|
};
|
|
202
202
|
effect(factory: () => unknown, label?: string): unknown;
|
|
@@ -204,7 +204,7 @@ interface HostContext$2 {
|
|
|
204
204
|
warn(message: string): void;
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
declare function installSessionState(ctx: HostContext$
|
|
207
|
+
declare function installSessionState(ctx: HostContext$3): () => Promise<void>;
|
|
208
208
|
//#endregion
|
|
209
209
|
//#region src/session-state/store.d.ts
|
|
210
210
|
declare const sessionStateDomainSpec: {
|
|
@@ -433,9 +433,9 @@ declare function installDiagnostics(ctx: DiagnosticHostContext, config: unknown)
|
|
|
433
433
|
declare function buildPrompt(template?: string): string;
|
|
434
434
|
//#endregion
|
|
435
435
|
//#region src/suggest/host.d.ts
|
|
436
|
-
interface HostContext$
|
|
436
|
+
interface HostContext$2 {
|
|
437
437
|
get(name: string): unknown;
|
|
438
|
-
inject(services: readonly string[], callback: (ctx: HostContext$
|
|
438
|
+
inject(services: readonly string[], callback: (ctx: HostContext$2) => void): unknown;
|
|
439
439
|
effect(factory: () => void | (() => void), label: string): unknown;
|
|
440
440
|
readonly logger?: {
|
|
441
441
|
warn(message: string): void;
|
|
@@ -496,12 +496,12 @@ declare function routeOf(session: HostSession): {
|
|
|
496
496
|
} | null;
|
|
497
497
|
declare function buildMessages(history: readonly HostMessage$1[], instruction: string): HostMessage$1[];
|
|
498
498
|
declare function knownNamesOf(messages: readonly HostMessage$1[]): ReadonlySet<string> | null;
|
|
499
|
-
declare function handleSuggest(ctx: HostContext$
|
|
499
|
+
declare function handleSuggest(ctx: HostContext$2, request: Request, timeoutMs?: number): Promise<Response>;
|
|
500
500
|
declare function quietEffortFor(llm: HostLlm, route: {
|
|
501
501
|
readonly provider: string;
|
|
502
502
|
readonly model: string;
|
|
503
503
|
}, operation?: DiagnosticOperation): Promise<string>;
|
|
504
|
-
declare function listModels(ctx: HostContext$
|
|
504
|
+
declare function listModels(ctx: HostContext$2): Promise<{
|
|
505
505
|
providers: readonly {
|
|
506
506
|
id: string;
|
|
507
507
|
name: string;
|
|
@@ -511,14 +511,14 @@ declare function listModels(ctx: HostContext$1): Promise<{
|
|
|
511
511
|
}[];
|
|
512
512
|
}[];
|
|
513
513
|
}>;
|
|
514
|
-
declare function listEfforts(ctx: HostContext$
|
|
514
|
+
declare function listEfforts(ctx: HostContext$2, provider: string, model: string): Promise<{
|
|
515
515
|
efforts: readonly {
|
|
516
516
|
id: string;
|
|
517
517
|
name: string;
|
|
518
518
|
}[];
|
|
519
519
|
defaultEffort: string | null;
|
|
520
520
|
}>;
|
|
521
|
-
declare function registerSuggestRoute(ctx: HostContext$
|
|
521
|
+
declare function registerSuggestRoute(ctx: HostContext$2): () => void;
|
|
522
522
|
//#endregion
|
|
523
523
|
//#region src/shared/session-info.d.ts
|
|
524
524
|
interface RawSystemSection {
|
|
@@ -528,12 +528,12 @@ interface RawSystemSection {
|
|
|
528
528
|
}
|
|
529
529
|
//#endregion
|
|
530
530
|
//#region src/session-info/host.d.ts
|
|
531
|
-
declare function collectSystemPromptMetadata(ctx: HostContext$
|
|
531
|
+
declare function collectSystemPromptMetadata(ctx: HostContext$2, scope?: unknown, onPartial?: (error?: unknown) => void): {
|
|
532
532
|
readonly systemSections: readonly RawSystemSection[];
|
|
533
533
|
readonly pluginOwners: Readonly<Record<string, string>>;
|
|
534
534
|
};
|
|
535
|
-
declare function handleSessionInfo(ctx: HostContext$
|
|
536
|
-
declare function registerSessionInfoRoute(ctx: HostContext$
|
|
535
|
+
declare function handleSessionInfo(ctx: HostContext$2, request: Request): Promise<Response>;
|
|
536
|
+
declare function registerSessionInfoRoute(ctx: HostContext$2): () => void;
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/shared/tools-manager.d.ts
|
|
539
539
|
type ToolScope = 'builtin' | 'plugin';
|
|
@@ -555,14 +555,14 @@ interface HostPromptAssembly {
|
|
|
555
555
|
}[];
|
|
556
556
|
readonly [key: string]: unknown;
|
|
557
557
|
}
|
|
558
|
-
interface ToolsHostContext extends HostContext$
|
|
558
|
+
interface ToolsHostContext extends HostContext$2 {
|
|
559
559
|
on?(event: string, listener: (assembly: HostPromptAssembly, context: unknown, next: () => Promise<HostPromptAssembly>) => Promise<HostPromptAssembly>): () => void;
|
|
560
560
|
}
|
|
561
|
-
declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$
|
|
561
|
+
declare function resolveSessionIdFromScope(candidate: unknown, ctx?: HostContext$2): string | undefined;
|
|
562
562
|
declare function resolveFiberModuleName(fiber: unknown): string | undefined;
|
|
563
563
|
declare function resolveCallerPackageFromStack(stack?: string): string | undefined;
|
|
564
|
-
declare function scanCordisFiberToolOwners(ctx: HostContext$
|
|
565
|
-
declare function collectAllToolSchemas(ctx: HostContext$
|
|
564
|
+
declare function scanCordisFiberToolOwners(ctx: HostContext$2, targetOwners?: Map<string, string>): Map<string, string>;
|
|
565
|
+
declare function collectAllToolSchemas(ctx: HostContext$2, sessionId?: string): Promise<readonly ToolSummary[]>;
|
|
566
566
|
//#endregion
|
|
567
567
|
//#region src/remote/update.d.ts
|
|
568
568
|
type UpdatePhase = 'idle' | 'checking' | 'available' | 'downloading' | 'verifying' | 'ready' | 'installing' | 'error';
|
|
@@ -603,7 +603,7 @@ interface UpdateDeps {
|
|
|
603
603
|
}, signal: AbortSignal) => Promise<void>;
|
|
604
604
|
}
|
|
605
605
|
declare function createUpdateEngine(deps: UpdateDeps): UpdateEngine;
|
|
606
|
-
interface HostContext {
|
|
606
|
+
interface HostContext$1 {
|
|
607
607
|
get(name: string): unknown;
|
|
608
608
|
readonly logger?: {
|
|
609
609
|
warn(message: string): void;
|
|
@@ -616,8 +616,8 @@ interface UpdateLocations {
|
|
|
616
616
|
readonly logDir: string;
|
|
617
617
|
readonly userDataDir?: string;
|
|
618
618
|
}
|
|
619
|
-
declare function productionDeps(ctx: HostContext, currentVersion: string, locations?: UpdateLocations): UpdateDeps;
|
|
620
|
-
declare function registerUpdateRoute(ctx: HostContext, load?: () => Promise<UpdateEngine>): {
|
|
619
|
+
declare function productionDeps(ctx: HostContext$1, currentVersion: string, locations?: UpdateLocations): UpdateDeps;
|
|
620
|
+
declare function registerUpdateRoute(ctx: HostContext$1, load?: () => Promise<UpdateEngine>): {
|
|
621
621
|
dispose(): Promise<void>;
|
|
622
622
|
};
|
|
623
623
|
//#endregion
|
|
@@ -650,7 +650,7 @@ interface SkillCatalogItem {
|
|
|
650
650
|
}
|
|
651
651
|
//#endregion
|
|
652
652
|
//#region src/skills-manager/host.d.ts
|
|
653
|
-
declare function collectSkillCatalog(ctx: HostContext$
|
|
653
|
+
declare function collectSkillCatalog(ctx: HostContext$2, sessionId?: string): Promise<readonly SkillCatalogItem[]>;
|
|
654
654
|
//#endregion
|
|
655
655
|
//#region src/shared/capabilities.d.ts
|
|
656
656
|
type CapabilitySource = 'third-party' | 'official' | 'builtin' | 'mcp';
|
|
@@ -707,15 +707,15 @@ interface RegistrationSnapshot {
|
|
|
707
707
|
readonly skillCapIdsByName: Map<string, readonly string[]>;
|
|
708
708
|
readonly hookCountByKey: Map<string, number>;
|
|
709
709
|
}
|
|
710
|
-
declare function scanCordisRegistrations(ctx: HostContext$
|
|
711
|
-
declare function collectCapabilitiesCatalog(ctx: HostContext$
|
|
710
|
+
declare function scanCordisRegistrations(ctx: HostContext$2): RegistrationSnapshot;
|
|
711
|
+
declare function collectCapabilitiesCatalog(ctx: HostContext$2, sessionId?: string): Promise<{
|
|
712
712
|
readonly capabilities: readonly CapabilityEntry[];
|
|
713
713
|
readonly localSkills: readonly SkillCatalogItem[];
|
|
714
714
|
}>;
|
|
715
|
-
declare function installCapabilityPolicy(ctx: HostContext$
|
|
716
|
-
declare function isSkillAvailableInSession(ctx: HostContext$
|
|
717
|
-
declare function handleCapabilitiesCatalog(ctx: HostContext$
|
|
718
|
-
declare function registerCapabilitiesRoute(ctx: HostContext$
|
|
715
|
+
declare function installCapabilityPolicy(ctx: HostContext$2, readPolicy: (sessionId?: string) => EffectiveCapabilityPolicy): () => void;
|
|
716
|
+
declare function isSkillAvailableInSession(ctx: HostContext$2, config: unknown, skillName: string, sessionId?: string, state?: Pick<SessionState, 'read'>): boolean;
|
|
717
|
+
declare function handleCapabilitiesCatalog(ctx: HostContext$2, request?: Request): Promise<Response>;
|
|
718
|
+
declare function registerCapabilitiesRoute(ctx: HostContext$2): () => void;
|
|
719
719
|
//#endregion
|
|
720
720
|
//#region src/shared/context-policy.d.ts
|
|
721
721
|
type SessionCap = number | null;
|
|
@@ -811,12 +811,12 @@ interface HostSessionLike {
|
|
|
811
811
|
}
|
|
812
812
|
declare function readCap(state: Pick<SessionState, 'read'>, sessionId: string): SessionCap;
|
|
813
813
|
declare function readContextManagerEnabled(config: unknown): boolean;
|
|
814
|
-
declare function resolveTargetAgent(ctx: HostContext$
|
|
814
|
+
declare function resolveTargetAgent(ctx: HostContext$2, sessionId: string): Promise<HostAgentLike | undefined>;
|
|
815
815
|
interface ContextControlOptions {
|
|
816
816
|
readonly config: () => unknown;
|
|
817
817
|
readonly state?: Pick<SessionState, 'read' | 'change'>;
|
|
818
818
|
}
|
|
819
|
-
declare function createContextControl(ctx: HostContext$
|
|
819
|
+
declare function createContextControl(ctx: HostContext$2, options: ContextControlOptions): {
|
|
820
820
|
setRecentConversation: (sessionId: string, value: {
|
|
821
821
|
readonly turns?: number | null;
|
|
822
822
|
readonly maxTokens?: number | null;
|
|
@@ -829,8 +829,8 @@ declare function createContextControl(ctx: HostContext$1, options: ContextContro
|
|
|
829
829
|
setCap: (sessionId: string, cap: SessionCap) => Promise<ContextSnapshot>;
|
|
830
830
|
};
|
|
831
831
|
declare function handleContextRequest(control: ContextControl, request?: Request): Promise<Response>;
|
|
832
|
-
declare function registerContextRoute(ctx: HostContext$
|
|
833
|
-
interface ContextHookHost extends HostContext$
|
|
832
|
+
declare function registerContextRoute(ctx: HostContext$2, control: ContextControl): () => void;
|
|
833
|
+
interface ContextHookHost extends HostContext$2 {
|
|
834
834
|
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
835
835
|
readonly prepend?: boolean;
|
|
836
836
|
}): () => void;
|
|
@@ -884,7 +884,7 @@ interface HostSessionEventLike {
|
|
|
884
884
|
};
|
|
885
885
|
readonly sourceEventSeqs?: readonly number[];
|
|
886
886
|
}
|
|
887
|
-
interface RecoveryHookHost extends HostContext$
|
|
887
|
+
interface RecoveryHookHost extends HostContext$2 {
|
|
888
888
|
on?(event: string, listener: (...args: never[]) => unknown, options?: {
|
|
889
889
|
readonly prepend?: boolean;
|
|
890
890
|
}): () => void;
|
|
@@ -1072,9 +1072,9 @@ interface ParsedPatchRow {
|
|
|
1072
1072
|
}
|
|
1073
1073
|
declare function parseCordisPatchRows(ymlText: string): readonly ParsedPatchRow[];
|
|
1074
1074
|
declare function createPluginAuditEngine(env: PluginAuditEnv): PluginAuditEngine;
|
|
1075
|
-
declare function productionAuditEnv(ctx: HostContext$
|
|
1076
|
-
declare function handlePluginAudit(engine: PluginAuditEngine, request: Request, readEnabled: () => boolean, ctx?: HostContext$
|
|
1077
|
-
declare function registerPluginAuditRoute(ctx: HostContext$
|
|
1075
|
+
declare function productionAuditEnv(ctx: HostContext$2): PluginAuditEnv;
|
|
1076
|
+
declare function handlePluginAudit(engine: PluginAuditEngine, request: Request, readEnabled: () => boolean, ctx?: HostContext$2): Promise<Response>;
|
|
1077
|
+
declare function registerPluginAuditRoute(ctx: HostContext$2, readEnabled: () => boolean): () => void;
|
|
1078
1078
|
//#endregion
|
|
1079
1079
|
//#region src/plugin-audit/ast.d.ts
|
|
1080
1080
|
interface AstAnalysisResult {
|
|
@@ -1127,6 +1127,13 @@ interface ArchivedViewHostContext {
|
|
|
1127
1127
|
declare function readArchivedViewEnabled(config: unknown): boolean;
|
|
1128
1128
|
declare function installArchivedFollowGuard(ctx: ArchivedViewHostContext, enabled: () => boolean): () => void;
|
|
1129
1129
|
//#endregion
|
|
1130
|
+
//#region src/subagent-model-follow/host.d.ts
|
|
1131
|
+
interface HostContext {
|
|
1132
|
+
get(name: string): unknown;
|
|
1133
|
+
}
|
|
1134
|
+
declare function readSubagentModelFollowEnabled(config: unknown): boolean;
|
|
1135
|
+
declare function installSubagentModelFollow(ctx: HostContext, enabled: () => boolean): () => void;
|
|
1136
|
+
//#endregion
|
|
1130
1137
|
//#region src/session-delete/host.d.ts
|
|
1131
1138
|
interface SessionDeleteDeps {
|
|
1132
1139
|
readonly sessionsRoot: string;
|
|
@@ -1165,6 +1172,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
1165
1172
|
sessionModel: Schema<boolean, boolean, "volatile-defined">;
|
|
1166
1173
|
abnormalFork: Schema<boolean, boolean, "volatile-defined">;
|
|
1167
1174
|
capabilityManager: Schema<boolean, boolean, "volatile-defined">;
|
|
1175
|
+
subagentModelFollow: Schema<boolean, boolean, "volatile-defined">;
|
|
1168
1176
|
suggestModel: Schema<string, string, "volatile-defined">;
|
|
1169
1177
|
suggestReasoning: Schema<string, string, "volatile-defined">;
|
|
1170
1178
|
suggestPrompt: Schema<string, string, "volatile-defined">;
|
|
@@ -1193,6 +1201,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
1193
1201
|
sessionModel: Schema<boolean, boolean, "volatile-defined">;
|
|
1194
1202
|
abnormalFork: Schema<boolean, boolean, "volatile-defined">;
|
|
1195
1203
|
capabilityManager: Schema<boolean, boolean, "volatile-defined">;
|
|
1204
|
+
subagentModelFollow: Schema<boolean, boolean, "volatile-defined">;
|
|
1196
1205
|
suggestModel: Schema<string, string, "volatile-defined">;
|
|
1197
1206
|
suggestReasoning: Schema<string, string, "volatile-defined">;
|
|
1198
1207
|
suggestPrompt: Schema<string, string, "volatile-defined">;
|
|
@@ -1211,6 +1220,8 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
1211
1220
|
}>>, "plain">;
|
|
1212
1221
|
export declare function apply(ctx: ToolsHostContext, config?: unknown): void;
|
|
1213
1222
|
export declare const __test: {
|
|
1223
|
+
installSubagentModelFollow: typeof installSubagentModelFollow;
|
|
1224
|
+
readSubagentModelFollowEnabled: typeof readSubagentModelFollowEnabled;
|
|
1214
1225
|
installRecovery: typeof installRecovery;
|
|
1215
1226
|
prepareRecentConversation: typeof prepareRecentConversation;
|
|
1216
1227
|
isRecentConversationMessage: typeof isRecentConversationMessage;
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { basename, dirname, extname, join, relative, resolve, sep } from "node:p
|
|
|
12
12
|
import { pipeline } from "node:stream/promises";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
14
|
import * as acorn from "acorn";
|
|
15
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
16
|
//#region src/shared/session-state.ts
|
|
16
17
|
const SESSION_STATE_SERVICE = "desktopEnhanceSessionState";
|
|
17
18
|
function applyPolicyDelta(global, delta) {
|
|
@@ -11077,6 +11078,118 @@ function installArchivedFollowGuard(ctx, enabled) {
|
|
|
11077
11078
|
};
|
|
11078
11079
|
}
|
|
11079
11080
|
//#endregion
|
|
11081
|
+
//#region src/subagent-model-follow/host.ts
|
|
11082
|
+
function original(value) {
|
|
11083
|
+
return value?.[Symbol.for("cordis.original")] ?? value;
|
|
11084
|
+
}
|
|
11085
|
+
const POLICY_KEY = "subagentModelSelectionPolicy";
|
|
11086
|
+
const SETTINGS_NS = "subagent-model-selection-settings";
|
|
11087
|
+
const activeWrappers = new WeakSet();
|
|
11088
|
+
function readSubagentModelFollowEnabled(config) {
|
|
11089
|
+
const raw = config?.subagentModelFollow;
|
|
11090
|
+
return (raw !== null && typeof raw === "object" && "get" in raw && typeof raw.get === "function" ? raw.get() : raw) !== false;
|
|
11091
|
+
}
|
|
11092
|
+
function currentRoutes(ctx) {
|
|
11093
|
+
const value = ctx.get("settings")?.describe({ redactSecrets: true }).find((entry) => entry.ns === SETTINGS_NS)?.value;
|
|
11094
|
+
if (typeof value?.enabled !== "boolean") throw new Error("subagent model follow: native authorization setting is unavailable");
|
|
11095
|
+
if (!value.enabled) return null;
|
|
11096
|
+
if (!Array.isArray(value.allowedModels) || value.allowedModels.length === 0) throw new Error("subagent model follow: enabled authorization requires at least one model");
|
|
11097
|
+
const seen = new Set();
|
|
11098
|
+
return value.allowedModels.map((route) => {
|
|
11099
|
+
if (route === null || typeof route !== "object" || !("provider" in route) || !("model" in route) || typeof route.provider !== "string" || route.provider.length === 0 || typeof route.model !== "string" || route.model.length === 0) throw new Error("subagent model follow: invalid authorized model route");
|
|
11100
|
+
const key = `${route.provider}\0${route.model}`;
|
|
11101
|
+
if (seen.has(key)) throw new Error("subagent model follow: duplicate authorized model route");
|
|
11102
|
+
seen.add(key);
|
|
11103
|
+
return {
|
|
11104
|
+
provider: route.provider,
|
|
11105
|
+
model: route.model
|
|
11106
|
+
};
|
|
11107
|
+
});
|
|
11108
|
+
}
|
|
11109
|
+
function installSubagentModelFollow(ctx, enabled) {
|
|
11110
|
+
const registry = original(ctx.get("sessionProjections"));
|
|
11111
|
+
const events = original(ctx.get("events"));
|
|
11112
|
+
if (!registry || typeof registry.cellFor !== "function" || typeof registry.checkpoint !== "function" || !events || typeof events._resolve !== "function") throw new Error("subagent model follow: unsupported session projection registry");
|
|
11113
|
+
const previous = Object.getOwnPropertyDescriptor(registry, "cellFor");
|
|
11114
|
+
if (previous && activeWrappers.has(previous.value)) return () => {};
|
|
11115
|
+
const previousCheckpoint = Object.getOwnPropertyDescriptor(registry, "checkpoint");
|
|
11116
|
+
const base = registry.cellFor;
|
|
11117
|
+
const baseCheckpoint = registry.checkpoint;
|
|
11118
|
+
const previousResolve = Object.getOwnPropertyDescriptor(events, "_resolve");
|
|
11119
|
+
const baseResolve = events._resolve;
|
|
11120
|
+
const nativeReads = new AsyncLocalStorage();
|
|
11121
|
+
let checkpointDepth = 0;
|
|
11122
|
+
const replacement = function(registration, session) {
|
|
11123
|
+
const cell = base.call(this, registration, session);
|
|
11124
|
+
if (!activeWrappers.has(replacement) || checkpointDepth > 0 || nativeReads.getStore()?.active || registration.def.key !== POLICY_KEY || !enabled()) return cell;
|
|
11125
|
+
return {
|
|
11126
|
+
...cell,
|
|
11127
|
+
state: currentRoutes(ctx)
|
|
11128
|
+
};
|
|
11129
|
+
};
|
|
11130
|
+
const checkpoint = function(session) {
|
|
11131
|
+
checkpointDepth += 1;
|
|
11132
|
+
try {
|
|
11133
|
+
return baseCheckpoint.call(this, session);
|
|
11134
|
+
} finally {
|
|
11135
|
+
checkpointDepth -= 1;
|
|
11136
|
+
}
|
|
11137
|
+
};
|
|
11138
|
+
const resolve = function(mode, args) {
|
|
11139
|
+
const name = typeof args[0] === "object" || typeof args[0] === "function" ? args[1] : args[0];
|
|
11140
|
+
const result = baseResolve.call(this, mode, args);
|
|
11141
|
+
if (!activeWrappers.has(replacement) || mode !== "serial" || name !== "agent/created") return result;
|
|
11142
|
+
return [result[0], result[1].map((callback) => async function(...payload) {
|
|
11143
|
+
const scope = { active: true };
|
|
11144
|
+
try {
|
|
11145
|
+
return await nativeReads.run(scope, () => callback.apply(this, payload));
|
|
11146
|
+
} finally {
|
|
11147
|
+
scope.active = false;
|
|
11148
|
+
}
|
|
11149
|
+
})];
|
|
11150
|
+
};
|
|
11151
|
+
const restore = () => {
|
|
11152
|
+
activeWrappers.delete(replacement);
|
|
11153
|
+
if (Object.getOwnPropertyDescriptor(events, "_resolve")?.value === resolve) {
|
|
11154
|
+
if (previousResolve) Object.defineProperty(events, "_resolve", previousResolve);
|
|
11155
|
+
else delete events._resolve;
|
|
11156
|
+
}
|
|
11157
|
+
if (Object.getOwnPropertyDescriptor(registry, "checkpoint")?.value === checkpoint) {
|
|
11158
|
+
if (previousCheckpoint) Object.defineProperty(registry, "checkpoint", previousCheckpoint);
|
|
11159
|
+
else delete registry.checkpoint;
|
|
11160
|
+
}
|
|
11161
|
+
if (Object.getOwnPropertyDescriptor(registry, "cellFor")?.value === replacement) {
|
|
11162
|
+
if (previous) Object.defineProperty(registry, "cellFor", previous);
|
|
11163
|
+
else delete registry.cellFor;
|
|
11164
|
+
}
|
|
11165
|
+
};
|
|
11166
|
+
try {
|
|
11167
|
+
Object.defineProperty(registry, "cellFor", {
|
|
11168
|
+
value: replacement,
|
|
11169
|
+
configurable: true,
|
|
11170
|
+
writable: true,
|
|
11171
|
+
enumerable: previous?.enumerable ?? false
|
|
11172
|
+
});
|
|
11173
|
+
Object.defineProperty(registry, "checkpoint", {
|
|
11174
|
+
value: checkpoint,
|
|
11175
|
+
configurable: true,
|
|
11176
|
+
writable: true,
|
|
11177
|
+
enumerable: previousCheckpoint?.enumerable ?? false
|
|
11178
|
+
});
|
|
11179
|
+
Object.defineProperty(events, "_resolve", {
|
|
11180
|
+
value: resolve,
|
|
11181
|
+
configurable: true,
|
|
11182
|
+
writable: true,
|
|
11183
|
+
enumerable: previousResolve?.enumerable ?? false
|
|
11184
|
+
});
|
|
11185
|
+
activeWrappers.add(replacement);
|
|
11186
|
+
} catch (error) {
|
|
11187
|
+
restore();
|
|
11188
|
+
throw error;
|
|
11189
|
+
}
|
|
11190
|
+
return restore;
|
|
11191
|
+
}
|
|
11192
|
+
//#endregion
|
|
11080
11193
|
//#region src/session-delete/host.ts
|
|
11081
11194
|
function isInside(rootReal, candidateReal) {
|
|
11082
11195
|
return candidateReal === rootReal || candidateReal.startsWith(rootReal + sep);
|
|
@@ -11392,6 +11505,7 @@ const Config = Schema.object({
|
|
|
11392
11505
|
sessionModel: Schema.boolean().default(true).volatile(),
|
|
11393
11506
|
abnormalFork: Schema.boolean().default(true).volatile(),
|
|
11394
11507
|
capabilityManager: Schema.boolean().default(true).volatile(),
|
|
11508
|
+
subagentModelFollow: Schema.boolean().default(true).volatile(),
|
|
11395
11509
|
suggestModel: Schema.string().default("").volatile(),
|
|
11396
11510
|
suggestReasoning: Schema.string().default("").volatile(),
|
|
11397
11511
|
suggestPrompt: Schema.string().default("").volatile(),
|
|
@@ -11416,6 +11530,22 @@ function apply(ctx, config) {
|
|
|
11416
11530
|
ctx.inject(["sessionProjections"], (serviceCtx) => {
|
|
11417
11531
|
serviceCtx.get("sessionProjections").register(sessionModelProjection);
|
|
11418
11532
|
});
|
|
11533
|
+
ctx.inject(["sessionProjections", "settings"], (serviceCtx) => {
|
|
11534
|
+
try {
|
|
11535
|
+
serviceCtx.effect(() => installSubagentModelFollow(serviceCtx, () => readSubagentModelFollowEnabled(config)), "desktop-enhance: subagent model follow");
|
|
11536
|
+
} catch (error) {
|
|
11537
|
+
emitDiagnostic(serviceCtx, {
|
|
11538
|
+
area: "session",
|
|
11539
|
+
event: "diagnostics.registration",
|
|
11540
|
+
phase: "failed",
|
|
11541
|
+
fields: {
|
|
11542
|
+
reason: "install_failed",
|
|
11543
|
+
errorCode: diagnosticErrorCode(error)
|
|
11544
|
+
}
|
|
11545
|
+
});
|
|
11546
|
+
serviceCtx.logger?.warn(`desktop-enhance: subagent model follow not installed: ${String(error)}`);
|
|
11547
|
+
}
|
|
11548
|
+
});
|
|
11419
11549
|
ctx.inject(["llm"], (serviceCtx) => {
|
|
11420
11550
|
serviceCtx.effect(() => installImagePricing(serviceCtx, () => readImagePricingEnabled(config)), "desktop-enhance: image pricing");
|
|
11421
11551
|
});
|
|
@@ -11548,6 +11678,8 @@ function apply(ctx, config) {
|
|
|
11548
11678
|
});
|
|
11549
11679
|
}
|
|
11550
11680
|
const __test = {
|
|
11681
|
+
installSubagentModelFollow,
|
|
11682
|
+
readSubagentModelFollowEnabled,
|
|
11551
11683
|
installRecovery,
|
|
11552
11684
|
prepareRecentConversation,
|
|
11553
11685
|
isRecentConversationMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-enhance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "DSH Desktop 界面增强:页内查找(Cmd+F)、轮次编号、上下文压缩行常显、建议、每步耗时、折叠文件夹状态计数、会话信息(含上下文注入 C1 视图)、插件与能力治理、本地 Skill、插件上下文审计、已归档会话只读查看与侧栏安全删除、独立远程接入与手机体验,以及智能建议、会话能力和远程接入的持久诊断日志。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.svg",
|