dsh-desktop-enhance 0.10.5 → 0.10.6
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 +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +12 -73
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -176,7 +176,7 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
|
|
|
176
176
|
压缩是自动的,但**什么时候压、压完还记得什么**过去只能交给默认值。阈值与剪枝放在**原生**上下文占用弹窗里(点输入框上方的占用率按钮);压缩后的 Skill 筛选进度直接显示在对话中。
|
|
177
177
|
|
|
178
178
|
- **本会话自动压缩阈值**:弹窗下半部分显示当前生效的压缩阈值,点数值即可编辑(单位 K),支持「恢复默认」。生效值恒为 **「你设定的值」与「模型默认值」中的较小者** —— 设定只能让压缩**更早**发生,绝不会推迟。设定高于模型上限时会明确标注「受当前模型上限约束」,不假装生效。判断用的是**这一条请求真实要发出去的内容**(含刚换成的新模型、它的输出预留、你这条输入与压缩后恢复的 Skill 正文),不是上一次请求留下的旧数字
|
|
179
|
-
-
|
|
179
|
+
- **手动剪枝一次**:同一个弹窗里点「剪枝」,把过长的工具输出就地压掉(不需要模型调用)。**点击后先排队,只在当前或下一轮对话的安全点执行**;空闲、停止或维护结束不会立即改写历史,未执行请求保留到你主动开始下一轮。排队本身不发消息、不调用模型;释放会话 Agent 或重启后需重新点击。弹窗会显示已排队、已完成、没有可剪内容或失败原因
|
|
180
180
|
- **压缩记录与筛选块的 Fork**:摘要与筛选都结束、名单安全保存后,两处 Fork 都从**包含筛选结果的位置**另开会话,不必先发送一条消息。等待或保存失败时不会提前开放安全分叉。原来助手回复下面的 Fork 行为完全没变
|
|
181
181
|
- **压缩后自动恢复 Skill**:压缩可能把已加载 Skill 的正文一起摘要掉。插件在压缩时额外并行发起一次模型筛选,复用完整上文的缓存前缀,只把**当前任务仍需保留、正文已被摘要掉**的 Skill 按**当前最新内容**重新注入。独立的「Skill 筛选」块显示进度,可展开查看保留与不保留的名单;失败或超时明确显示全量兜底,不冒充空名单。没有候选时不发筛选请求;禁用或删除的 Skill 不会被偷偷恢复
|
|
182
182
|
|
package/lib/index.d.ts
CHANGED
|
@@ -701,8 +701,6 @@ interface ContextControl {
|
|
|
701
701
|
interface HostAgentLike {
|
|
702
702
|
readonly id: string;
|
|
703
703
|
readonly session: HostSessionLike;
|
|
704
|
-
runMaintenance?<T>(job: (signal: AbortSignal) => Promise<T> | T): Promise<T>;
|
|
705
|
-
whenIdle?(): Promise<void>;
|
|
706
704
|
}
|
|
707
705
|
interface HostMessage {
|
|
708
706
|
readonly source?: {
|
package/lib/index.js
CHANGED
|
@@ -5403,7 +5403,7 @@ async function resolveTargetAgent(ctx, sessionId) {
|
|
|
5403
5403
|
if (typeof resolve !== "function") return void 0;
|
|
5404
5404
|
try {
|
|
5405
5405
|
const resolved = await resolve.call(controller, sessionId);
|
|
5406
|
-
if (
|
|
5406
|
+
if ("agent" in resolved) return resolved.agent;
|
|
5407
5407
|
} catch {
|
|
5408
5408
|
return;
|
|
5409
5409
|
}
|
|
@@ -5472,17 +5472,6 @@ function recentConversationIntent(value) {
|
|
|
5472
5472
|
kind: "recent-conversation"
|
|
5473
5473
|
});
|
|
5474
5474
|
}
|
|
5475
|
-
const PRUNE_STATES = [
|
|
5476
|
-
"done",
|
|
5477
|
-
"queued",
|
|
5478
|
-
"noop",
|
|
5479
|
-
"failed"
|
|
5480
|
-
];
|
|
5481
|
-
function isPruneOutcome(value) {
|
|
5482
|
-
if (value === null || typeof value !== "object") return false;
|
|
5483
|
-
const state = value.state;
|
|
5484
|
-
return typeof state === "string" && PRUNE_STATES.includes(state);
|
|
5485
|
-
}
|
|
5486
5475
|
function createContextControl(ctx, options) {
|
|
5487
5476
|
const jobs = new Map();
|
|
5488
5477
|
const results = new Map();
|
|
@@ -5502,7 +5491,6 @@ function createContextControl(ctx, options) {
|
|
|
5502
5491
|
return outcome;
|
|
5503
5492
|
}
|
|
5504
5493
|
function release(job) {
|
|
5505
|
-
job.cancelWait?.();
|
|
5506
5494
|
if (jobs.get(job.agent.id) === job) jobs.delete(job.agent.id);
|
|
5507
5495
|
}
|
|
5508
5496
|
function pruneStatus(sessionId) {
|
|
@@ -5579,19 +5567,14 @@ function createContextControl(ctx, options) {
|
|
|
5579
5567
|
message: pruneError
|
|
5580
5568
|
};
|
|
5581
5569
|
}
|
|
5582
|
-
function executeJob(job
|
|
5570
|
+
function executeJob(job) {
|
|
5583
5571
|
if (job.task !== void 0) return job.task;
|
|
5584
|
-
job.cancelWait?.();
|
|
5585
5572
|
job.task = Promise.resolve().then(async () => {
|
|
5586
5573
|
if (disposed || jobs.get(job.agent.id) !== job) return failed("剪枝请求已取消");
|
|
5587
5574
|
if (!readContextManagerEnabled(options.config())) {
|
|
5588
5575
|
job.diagnostic.end("cancelled", { reason: "disabled" });
|
|
5589
5576
|
return publish(job, failed("上下文管理已关闭"));
|
|
5590
5577
|
}
|
|
5591
|
-
if (signal?.aborted) {
|
|
5592
|
-
job.diagnostic.end("cancelled", { reason: "cancelled" });
|
|
5593
|
-
return publish(job, failed("剪枝请求已取消"));
|
|
5594
|
-
}
|
|
5595
5578
|
return publish(job, await executePrune(job));
|
|
5596
5579
|
}).catch((error) => publish(job, failed(error instanceof Error ? error.message : String(error))));
|
|
5597
5580
|
return job.task;
|
|
@@ -5600,44 +5583,14 @@ function createContextControl(ctx, options) {
|
|
|
5600
5583
|
const job = jobs.get(sessionId);
|
|
5601
5584
|
if (job === void 0 || disposed) return;
|
|
5602
5585
|
try {
|
|
5586
|
+
const agents = ctx.get("agents");
|
|
5587
|
+
if (agents?.turnBoundaryOf === void 0) throw new Error("没有可用的会话回合边界服务");
|
|
5588
|
+
if (agents.turnBoundaryOf(job.agent.session).openTurnStartSeq === null) return;
|
|
5603
5589
|
await executeJob(job);
|
|
5604
|
-
}
|
|
5605
|
-
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
async function afterIdle(job) {
|
|
5609
|
-
const agent = job.agent;
|
|
5610
|
-
if (agent.whenIdle === void 0 || agent.runMaintenance === void 0) {
|
|
5611
|
-
publish(job, failed("这个 Agent 没有可用的空闲维护接口"));
|
|
5612
|
-
release(job);
|
|
5613
|
-
return;
|
|
5614
|
-
}
|
|
5615
|
-
while (!disposed && jobs.get(agent.id) === job && job.task === void 0) {
|
|
5616
|
-
const ready = await new Promise((resolve, reject) => {
|
|
5617
|
-
job.cancelWait = () => resolve(false);
|
|
5618
|
-
agent.whenIdle?.().then(() => resolve(true), reject);
|
|
5619
|
-
}).catch((error) => {
|
|
5620
|
-
publish(job, failed(error instanceof Error ? error.message : String(error)));
|
|
5621
|
-
return false;
|
|
5622
|
-
});
|
|
5623
|
-
job.cancelWait = void 0;
|
|
5624
|
-
if (!ready) {
|
|
5625
|
-
if (job.task === void 0) release(job);
|
|
5626
|
-
return;
|
|
5627
|
-
}
|
|
5628
|
-
if (disposed || jobs.get(agent.id) !== job || job.task !== void 0) return;
|
|
5629
|
-
try {
|
|
5630
|
-
await agent.runMaintenance((signal) => executeJob(job, signal));
|
|
5631
|
-
release(job);
|
|
5632
|
-
return;
|
|
5633
|
-
} catch (error) {
|
|
5634
|
-
if (job.task !== void 0) {
|
|
5635
|
-
publish(job, failed(error instanceof Error ? error.message : String(error)));
|
|
5636
|
-
release(job);
|
|
5637
|
-
return;
|
|
5638
|
-
}
|
|
5639
|
-
}
|
|
5590
|
+
} catch (error) {
|
|
5591
|
+
publish(job, failed(error instanceof Error ? error.message : String(error)));
|
|
5640
5592
|
}
|
|
5593
|
+
release(job);
|
|
5641
5594
|
}
|
|
5642
5595
|
async function pruneOnce(sessionId) {
|
|
5643
5596
|
const reject = (reason, message) => {
|
|
@@ -5662,35 +5615,24 @@ function createContextControl(ctx, options) {
|
|
|
5662
5615
|
}
|
|
5663
5616
|
const agent = await resolveTargetAgent(ctx, sessionId);
|
|
5664
5617
|
if (agent === void 0) return reject("missing_agent", "会话当前没有可用的 Agent");
|
|
5618
|
+
if (ctx.get("agents")?.get?.(sessionId) !== agent) return reject("agent_disposed", "会话 Agent 已释放,请重新请求剪枝");
|
|
5665
5619
|
const concurrent = jobs.get(sessionId);
|
|
5666
5620
|
if (concurrent !== void 0) {
|
|
5667
5621
|
concurrent.diagnostic.record("queued", { reason: "coalesced" });
|
|
5668
5622
|
return results.get(sessionId).outcome;
|
|
5669
5623
|
}
|
|
5670
5624
|
if (disposed) return reject("disposed", "上下文管理已关闭");
|
|
5671
|
-
const run = agent.runMaintenance;
|
|
5672
|
-
if (typeof run !== "function") return reject("missing_service", "这个 Agent 没有可用的维护接口");
|
|
5673
5625
|
const job = {
|
|
5674
5626
|
agent,
|
|
5675
5627
|
diagnostic: startDiagnostic(ctx, "session", "context.prune", { sessionId })
|
|
5676
5628
|
};
|
|
5677
5629
|
jobs.set(sessionId, job);
|
|
5678
|
-
publish(job, {
|
|
5630
|
+
return publish(job, {
|
|
5679
5631
|
state: "queued",
|
|
5680
5632
|
prunedCount: 0,
|
|
5681
5633
|
charsRemoved: 0,
|
|
5682
|
-
message: "
|
|
5634
|
+
message: "已排队,等待当前或下一轮的安全点;停止后仍保留,重启后需重新点击"
|
|
5683
5635
|
});
|
|
5684
|
-
try {
|
|
5685
|
-
const outcome = await run.call(agent, (signal) => executeJob(job, signal));
|
|
5686
|
-
return isPruneOutcome(outcome) ? outcome : publish(job, failed("维护区返回了无法识别的结果"));
|
|
5687
|
-
} catch (error) {
|
|
5688
|
-
if (job.task !== void 0) return publish(job, failed(error instanceof Error ? error.message : String(error)));
|
|
5689
|
-
afterIdle(job);
|
|
5690
|
-
return results.get(sessionId).outcome;
|
|
5691
|
-
} finally {
|
|
5692
|
-
if (job.task !== void 0) release(job);
|
|
5693
|
-
}
|
|
5694
5636
|
}
|
|
5695
5637
|
function forgetAgent(agent) {
|
|
5696
5638
|
const job = jobs.get(agent.id);
|
|
@@ -5704,7 +5646,6 @@ function createContextControl(ctx, options) {
|
|
|
5704
5646
|
const tasks = [];
|
|
5705
5647
|
for (const job of jobs.values()) {
|
|
5706
5648
|
job.diagnostic.end("cancelled", { reason: "disposed" });
|
|
5707
|
-
job.cancelWait?.();
|
|
5708
5649
|
if (job.task !== void 0) tasks.push(job.task);
|
|
5709
5650
|
}
|
|
5710
5651
|
jobs.clear();
|
|
@@ -6064,9 +6005,7 @@ function installContextHooks(ctx, control, options) {
|
|
|
6064
6005
|
}, { prepend: true }));
|
|
6065
6006
|
disposers.push(on.call(ctx, "agent/pre-step", async (payload, next) => {
|
|
6066
6007
|
const agent = payload.agent;
|
|
6067
|
-
if (agent !== void 0)
|
|
6068
|
-
await control.consumePending(agent.id);
|
|
6069
|
-
} catch {}
|
|
6008
|
+
if (agent !== void 0) await control.consumePending(agent.id);
|
|
6070
6009
|
return next();
|
|
6071
6010
|
}));
|
|
6072
6011
|
disposers.push(on.call(ctx, "agent/turn-stopping", async (payload) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-enhance",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"description": "DSH Desktop 界面增强:页内查找(Cmd+F)、轮次编号、上下文压缩行常显、建议、每步耗时、折叠文件夹状态计数、会话信息(含上下文注入 C1 视图)、工具管理、Skill 管理、独立远程接入与手机体验,以及智能建议、会话能力和远程接入的持久诊断日志。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.svg",
|