dsh-desktop-enhance 0.10.3 → 0.10.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/README.md +3 -3
- package/lib/client.js +426 -11
- package/lib/index.d.ts +14 -2
- package/lib/index.js +397 -135
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -173,12 +173,12 @@ Web 版(浏览器里打开的那种)**不提供插件查找的默认快捷
|
|
|
173
173
|
|
|
174
174
|
### 上下文管理
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
压缩是自动的,但**什么时候压、压完还记得什么**过去只能交给默认值。阈值与剪枝放在**原生**上下文占用弹窗里(点输入框上方的占用率按钮);压缩后的 Skill 筛选进度直接显示在对话中。
|
|
177
177
|
|
|
178
178
|
- **本会话自动压缩阈值**:弹窗下半部分显示当前生效的压缩阈值,点数值即可编辑(单位 K),支持「恢复默认」。生效值恒为 **「你设定的值」与「模型默认值」中的较小者** —— 设定只能让压缩**更早**发生,绝不会推迟。设定高于模型上限时会明确标注「受当前模型上限约束」,不假装生效。判断用的是**这一条请求真实要发出去的内容**(含刚换成的新模型、它的输出预留、你这条输入与压缩后恢复的 Skill 正文),不是上一次请求留下的旧数字
|
|
179
179
|
- **手动剪枝一次**:同一个弹窗里点「剪枝」,把过长的工具输出就地压掉(不需要模型调用)。**会话空闲时立刻执行;正在跑的时候会排队,并在这一轮结束、你点停止或维护任务结束时自动执行**(不用再发一条消息去触发),弹窗里会如实告诉你结果(已完成 / 已排队 / 没有可剪的内容 / 失败原因)
|
|
180
|
-
-
|
|
181
|
-
- **压缩后自动恢复 Skill**:压缩可能把已加载 Skill 的正文一起摘要掉。插件在压缩时额外并行发起一次模型筛选,复用完整上文的缓存前缀,只把**当前任务仍需保留、正文已被摘要掉**的 Skill
|
|
180
|
+
- **压缩记录与筛选块的 Fork**:摘要与筛选都结束、名单安全保存后,两处 Fork 都从**包含筛选结果的位置**另开会话,不必先发送一条消息。等待或保存失败时不会提前开放安全分叉。原来助手回复下面的 Fork 行为完全没变
|
|
181
|
+
- **压缩后自动恢复 Skill**:压缩可能把已加载 Skill 的正文一起摘要掉。插件在压缩时额外并行发起一次模型筛选,复用完整上文的缓存前缀,只把**当前任务仍需保留、正文已被摘要掉**的 Skill 按**当前最新内容**重新注入。独立的「Skill 筛选」块显示进度,可展开查看保留与不保留的名单;失败或超时明确显示全量兜底,不冒充空名单。没有候选时不发筛选请求;禁用或删除的 Skill 不会被偷偷恢复
|
|
182
182
|
|
|
183
183
|
### 会话设定的保存
|
|
184
184
|
|
package/lib/client.js
CHANGED
|
@@ -843,6 +843,27 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
843
843
|
//#endregion
|
|
844
844
|
//#region src/client/strings.ts
|
|
845
845
|
const zh = {
|
|
846
|
+
"retention.title": "Skill 筛选",
|
|
847
|
+
"retention.retry": "重试读取",
|
|
848
|
+
"retention.details": "查看筛选名单",
|
|
849
|
+
"retention.drop": "不保留",
|
|
850
|
+
"retention.loading": "正在读取筛选状态…",
|
|
851
|
+
"retention.running": "正在筛选需保留的 Skill…",
|
|
852
|
+
"retention.waiting-compaction": "筛选已结束,等待压缩完成…",
|
|
853
|
+
"retention.waiting-selection": "压缩已完成,等待 Skill 筛选…",
|
|
854
|
+
"retention.saving": "正在安全保存名单,暂不能 Fork…",
|
|
855
|
+
"retention.ready": "名单已安全保存,可 Fork;正文将在正常准入时恢复。",
|
|
856
|
+
"retention.fallback": "筛选未成功,已安全保存保守保留名单,可 Fork。",
|
|
857
|
+
"retention.failed": "名单保存失败,不能确认安全 Fork 切点。",
|
|
858
|
+
"retention.cancelled": "筛选已取消,未确认安全 Fork 切点。",
|
|
859
|
+
"retention.unavailable": "没有实时任务或可回放结果,不能确认安全 Fork 切点。",
|
|
860
|
+
"retention.skipped": "没有候选或恢复已关闭,无需筛选。",
|
|
861
|
+
"retention.read-failed": "读取筛选状态失败,未确认完成;请重新打开会话重试。",
|
|
862
|
+
"retention.candidates": "候选",
|
|
863
|
+
"retention.keep": "保留",
|
|
864
|
+
"retention.none": "无",
|
|
865
|
+
"retention.fork": "从已保存的 Skill 名单 Fork",
|
|
866
|
+
"retention.compactionFork": "从此压缩结果 Fork",
|
|
846
867
|
"sessionState.title": "会话策略存储",
|
|
847
868
|
"sessionState.startupCleanup": "启动时复核已删除会话;运行中删除的会话将在下次启动时清理策略记录,归档会话保留。",
|
|
848
869
|
"sessionState.hint": "工具、Skill 与压缩阈值按会话独立持久保存;归档会话保留。全局默认仍在下方设置。",
|
|
@@ -1079,6 +1100,27 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
1079
1100
|
"settings.writeFailed": "设置没写进去,开关已退回原状态;请重试。"
|
|
1080
1101
|
};
|
|
1081
1102
|
const en = {
|
|
1103
|
+
"retention.title": "Skill selection",
|
|
1104
|
+
"retention.retry": "Retry reading",
|
|
1105
|
+
"retention.details": "View selection list",
|
|
1106
|
+
"retention.drop": "Not retained",
|
|
1107
|
+
"retention.loading": "Reading selection status…",
|
|
1108
|
+
"retention.running": "Selecting Skills to retain…",
|
|
1109
|
+
"retention.waiting-compaction": "Selection finished; waiting for compaction…",
|
|
1110
|
+
"retention.waiting-selection": "Compaction finished; waiting for Skill selection…",
|
|
1111
|
+
"retention.saving": "Saving the list safely; Fork is not ready…",
|
|
1112
|
+
"retention.ready": "List safely saved; Fork is ready. Skill content will be restored at normal admission.",
|
|
1113
|
+
"retention.fallback": "Selection failed; conservative retention safely saved. Fork is ready.",
|
|
1114
|
+
"retention.failed": "Saving failed; no confirmed safe Fork boundary.",
|
|
1115
|
+
"retention.cancelled": "Selection cancelled; no confirmed safe Fork boundary.",
|
|
1116
|
+
"retention.unavailable": "No live job or replayable result; no confirmed safe Fork boundary.",
|
|
1117
|
+
"retention.skipped": "No candidates or recovery disabled; selection not needed.",
|
|
1118
|
+
"retention.read-failed": "Could not read selection status; completion is unconfirmed. Reopen the session to retry.",
|
|
1119
|
+
"retention.candidates": "Candidates",
|
|
1120
|
+
"retention.keep": "Retained",
|
|
1121
|
+
"retention.none": "None",
|
|
1122
|
+
"retention.fork": "Fork with the saved Skill list",
|
|
1123
|
+
"retention.compactionFork": "Fork from this compaction",
|
|
1082
1124
|
"sessionState.title": "Session policy storage",
|
|
1083
1125
|
"sessionState.startupCleanup": "Deleted sessions are checked at startup. Policies for sessions deleted while running are cleaned up at the next startup. Archived sessions are retained.",
|
|
1084
1126
|
"sessionState.hint": "Tools, skills and compaction caps are persisted per session. Archived sessions are retained. Global defaults remain in the settings below.",
|
|
@@ -1783,6 +1825,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
1783
1825
|
const TOOLS_ROUTE = "/api/desktop-enhance/tools";
|
|
1784
1826
|
const SKILLS_ROUTE = "/api/desktop-enhance/skills";
|
|
1785
1827
|
const CONTEXT_ROUTE = "/api/desktop-enhance/context";
|
|
1828
|
+
const SKILL_RETENTION_ROUTE = "/api/desktop-enhance/skill-retention";
|
|
1786
1829
|
const SESSION_STATE_ROUTE = "/api/desktop-enhance/session-state";
|
|
1787
1830
|
const UPDATE_ROUTE = "/api/desktop-enhance/update";
|
|
1788
1831
|
//#endregion
|
|
@@ -9106,7 +9149,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9106
9149
|
}
|
|
9107
9150
|
//#endregion
|
|
9108
9151
|
//#region \0dsh-desktop-enhance-css:/Users/lijiechengbj/projects/AI-agents/dsh-desktop-enhance/src/client/remote/styles.css.mjs
|
|
9109
|
-
var styles_css_default$
|
|
9152
|
+
var styles_css_default$4 = "\n[data-desktop-enhance-remote] { display:flex; flex-direction:column; gap:var(--dsh-de-space-section); min-width:0; padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-body,\n[data-desktop-enhance-remote] .de-remote-content { display:flex; flex-direction:column; gap:var(--dsh-de-space-lg); min-width:0; }\n[data-desktop-enhance-remote] h3,\n[data-desktop-enhance-remote] h4,\n[data-desktop-enhance-remote] p { margin:0; }\n[data-desktop-enhance-remote] h3 { font-size:var(--dsh-de-font-heading); font-weight:600; }\n[data-desktop-enhance-remote] h4 { font-size:var(--dsh-de-font-body); font-weight:600; }\n[data-desktop-enhance-remote] p { color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); line-height:1.5; overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] [role=\"alert\"] { color:var(--dsh-de-danger); }\n[data-desktop-enhance-remote] .de-remote-heading { display:flex; align-items:center; justify-content:space-between; gap:var(--dsh-de-space-lg); }\n[data-desktop-enhance-remote] .de-remote-heading > div { display:grid; gap:4px; }\n[data-desktop-enhance-remote] .de-remote-port-row,\n[data-desktop-enhance-remote] .de-remote-field,\n[data-desktop-enhance-remote] .de-remote-actions { display:flex; align-items:center; gap:var(--dsh-de-space-md); flex-wrap:wrap; }\n[data-desktop-enhance-remote] .de-remote-field { font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-devices { display:grid; gap:var(--dsh-de-space-md); border-top:1px solid var(--dsh-de-border); padding-top:var(--dsh-de-space-section); }\n[data-desktop-enhance-remote] input { box-sizing:border-box; width:104px; min-width:0; max-width:100%; min-height:var(--dsh-de-control-height); padding:6px 8px; border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-control); background:var(--dsh-de-surface); color:var(--dsh-de-text); font:inherit; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary { color:var(--dsw-alias-label-primary-bluish); background:var(--dsw-alias-state-business-tertiary); border-color:var(--dsh-de-accent); font-weight:600; }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-primary:hover:not(:disabled) { background:var(--dsw-alias-state-business-tertiary); filter:brightness(.96); }\n[data-desktop-enhance-remote] .de-remote-device-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(210px,100%),1fr)); gap:var(--dsh-de-space-md); }\n[data-desktop-enhance-remote] .de-remote-device { min-width:0; display:flex; flex-direction:column; align-items:flex-start; gap:var(--dsh-de-space-sm); padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-remote] .de-remote-device > .de-remote-heading { align-self:stretch; margin-bottom:4px; }\n[data-desktop-enhance-remote] .de-remote-device strong { overflow-wrap:anywhere; }\n[data-desktop-enhance-remote] .de-remote-device-icon { width:28px; height:28px; color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-badge { border-radius:var(--dsh-de-radius-control); padding:3px 7px; background:var(--dsh-de-hover); font-size:var(--dsh-de-font-caption); color:var(--dsh-de-muted); }\n[data-desktop-enhance-remote] .de-remote-device[data-revoked=\"true\"] { opacity:.65; }\n[data-desktop-enhance-remote] .de-remote-device-footer { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:var(--dsh-de-space-sm); align-self:stretch; margin-top:auto; padding-top:var(--dsh-de-space-md); border-top:1px solid var(--dsh-de-border); color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-settings] [data-desktop-enhance-remote] button.de-remote-revoke { padding:4px 0; color:var(--dsh-de-danger); background:transparent; border-color:transparent; font-size:var(--dsh-de-font-caption); }\n[data-desktop-enhance-remote] .de-remote-empty { padding:var(--dsh-de-space-section); border:1px dashed var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); }\n@media (max-width:600px) {\n [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--dsh-de-space-sm); }\n [data-desktop-enhance-remote] .de-remote-device { padding:var(--dsh-de-space-md); }\n}\n@media (max-width:360px) { [data-desktop-enhance-remote] .de-remote-device-grid { grid-template-columns:1fr; } }\n\n\n[data-desktop-enhance-remote] .de-remote-stack { display:flex; flex-direction:column; gap:var(--dsh-de-space-section); min-width:0; }\n\n\n[data-desktop-enhance-update] { display:flex; flex-direction:column; gap:var(--dsh-de-space-md); min-width:0; padding:var(--dsh-de-space-lg); border:1px solid var(--dsh-de-border); border-radius:var(--dsh-de-radius-card); background:var(--dsh-de-surface); }\n[data-desktop-enhance-update] .de-update-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:var(--dsh-de-space-lg); flex-wrap:wrap; }\n[data-desktop-enhance-update] .de-update-heading > div { display:grid; gap:4px; min-width:0; }\n[data-desktop-enhance-update] h3 { margin:0; font-size:var(--dsh-de-font-heading); font-weight:600; }\n[data-desktop-enhance-update] p { margin:0; color:var(--dsh-de-muted); font-size:var(--dsh-de-font-caption); line-height:1.5; overflow-wrap:anywhere; }\n[data-desktop-enhance-update] .de-update-status { color:var(--dsh-de-text); }\n[data-desktop-enhance-update] .de-update-status[data-update-phase=\"error\"] { color:var(--dsh-de-danger); }\n[data-desktop-enhance-update] .de-update-warning { color:var(--dsh-de-muted); }\n[data-desktop-enhance-update] .de-update-error { color:var(--dsh-de-danger); }\n[data-desktop-enhance-settings] [data-desktop-enhance-update] button.de-update-primary { color:var(--dsw-alias-label-primary-bluish); background:var(--dsw-alias-state-business-tertiary); border-color:var(--dsh-de-accent); font-weight:600; }\n[data-desktop-enhance-settings] [data-desktop-enhance-update] button.de-update-primary:hover:not(:disabled) { background:var(--dsw-alias-state-business-tertiary); filter:brightness(.96); }\n";
|
|
9110
9153
|
//#endregion
|
|
9111
9154
|
//#region src/shared/session-model.ts
|
|
9112
9155
|
const SESSION_MODEL_PROJECTION = "desktop-enhance.session-model";
|
|
@@ -9140,7 +9183,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9140
9183
|
}
|
|
9141
9184
|
//#endregion
|
|
9142
9185
|
//#region \0dsh-desktop-enhance-css:/Users/lijiechengbj/projects/AI-agents/dsh-desktop-enhance/src/client/session-model/styles.css.mjs
|
|
9143
|
-
var styles_css_default$
|
|
9186
|
+
var styles_css_default$3 = ":root[data-desktop-enhance-off-session-model] [data-desktop-enhance-session-model] { display: none !important; }\n\n\n:root:not([data-desktop-enhance-off-session-model]) [data-desktop-enhance-session-model] {\n display: flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n max-width: min(360px, 45cqw);\n height: 28px;\n padding: 0 4px 0 8px;\n color: var(--dsw-alias-label-secondary);\n font-size: 13px;\n font-weight: 400;\n line-height: 20px;\n}\n.de-session-model-name,\n.de-session-model-effort {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.de-session-model-effort { flex-shrink: 1000; }\n.de-readonly-model-composer {\n border: 0.5px solid var(--dsw-alias-border-l1);\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-secondary);\n margin: 0 24px 20px;\n padding: 10px 16px;\n font-size: 13px;\n line-height: 20px;\n}\n.de-readonly-model-notice {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n gap: 8px;\n}\n.de-readonly-model-notice strong { color: var(--dsw-alias-label-primary); font-weight: 510; }\n.de-readonly-model-row { display: flex; justify-content: flex-end; margin-top: 8px; }\n";
|
|
9144
9187
|
//#endregion
|
|
9145
9188
|
//#region src/client/abnormal-fork/model.ts
|
|
9146
9189
|
function closedTurnBoundary(turn) {
|
|
@@ -9426,7 +9469,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
9426
9469
|
}
|
|
9427
9470
|
//#endregion
|
|
9428
9471
|
//#region \0dsh-desktop-enhance-css:/Users/lijiechengbj/projects/AI-agents/dsh-desktop-enhance/src/client/abnormal-fork/styles.css.mjs
|
|
9429
|
-
var styles_css_default$
|
|
9472
|
+
var styles_css_default$2 = "\n:root:not([data-desktop-enhance-off-abnormal-fork]) [data-desktop-enhance-abnormal-fork-button] {\n cursor: pointer;\n opacity: 1;\n}\n:root:not([data-desktop-enhance-off-abnormal-fork]) [data-desktop-enhance-abnormal-fork-button][aria-disabled=\"true\"] {\n cursor: default;\n opacity: .45;\n}\n[data-desktop-enhance-abnormal-fork] { display: contents; }\n[data-desktop-enhance-abnormal-fork-actions] {\n display: flex;\n align-items: center;\n gap: 8px;\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n}\n[data-desktop-enhance-abnormal-fork-new] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n border: none;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n[data-desktop-enhance-abnormal-fork-new] svg {\n width: calc(17px + var(--dsh-content-font-delta, 0px));\n height: calc(17px + var(--dsh-content-font-delta, 0px));\n}\n[data-desktop-enhance-abnormal-fork-new]:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n}\n[data-desktop-enhance-abnormal-fork-new]:focus-visible {\n outline: 2px solid var(--dsw-alias-state-business-primary);\n outline-offset: 2px;\n}\n[data-desktop-enhance-abnormal-fork-new]:disabled { opacity: .45; cursor: default; }\n[data-desktop-enhance-abnormal-fork-error] {\n color: var(--dsw-alias-label-primary);\n font-size: var(--dsh-content-font-size-secondary, 13px);\n}\n";
|
|
9430
9473
|
//#endregion
|
|
9431
9474
|
//#region src/shared/recent-conversation.ts
|
|
9432
9475
|
const DEFAULT_RECENT_CONVERSATION_MAX_TOKENS = 32768;
|
|
@@ -10123,8 +10166,282 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10123
10166
|
remove();
|
|
10124
10167
|
};
|
|
10125
10168
|
}
|
|
10169
|
+
const RECORD_TAG = "desktop_enhance_skill_retention";
|
|
10170
|
+
function readSkillRetentionRecord(message) {
|
|
10171
|
+
if (!isObject(message) || message.role !== "user" || !isObject(message.source) || message.source.kind !== "desktop-enhance-skill-retention" || !Array.isArray(message.content)) return null;
|
|
10172
|
+
if (Object.hasOwn(message.source, "retention")) return message.content.length === 0 ? readRetentionPayload(message.source.retention) : null;
|
|
10173
|
+
if (message.content.length !== 1) return null;
|
|
10174
|
+
const block = message.content[0];
|
|
10175
|
+
if (!isObject(block) || !hasExactKeys(block, ["type", "text"]) || block.type !== "text" || typeof block.text !== "string") return null;
|
|
10176
|
+
const start = `<${RECORD_TAG}>`;
|
|
10177
|
+
const end = `</${RECORD_TAG}>`;
|
|
10178
|
+
if (!block.text.startsWith(start) || !block.text.endsWith(end)) return null;
|
|
10179
|
+
let payload;
|
|
10180
|
+
try {
|
|
10181
|
+
payload = JSON.parse(block.text.slice(start.length, -end.length));
|
|
10182
|
+
} catch {
|
|
10183
|
+
return null;
|
|
10184
|
+
}
|
|
10185
|
+
return readRetentionPayload(payload);
|
|
10186
|
+
}
|
|
10187
|
+
function readRetentionPayload(payload) {
|
|
10188
|
+
if (!isObject(payload) || !hasExactKeys(payload, [
|
|
10189
|
+
"schemaVersion",
|
|
10190
|
+
"compactionId",
|
|
10191
|
+
"summarySeq",
|
|
10192
|
+
"candidates",
|
|
10193
|
+
"keep"
|
|
10194
|
+
]) || payload.schemaVersion !== 1 || !isNonEmptyString(payload.compactionId) || !isSeq(payload.summarySeq) || !Array.isArray(payload.candidates)) return null;
|
|
10195
|
+
const candidates = [];
|
|
10196
|
+
const names = new Set();
|
|
10197
|
+
for (const candidate of payload.candidates) {
|
|
10198
|
+
if (!isObject(candidate) || !hasExactKeys(candidate, ["name", "seq"]) || !isNonEmptyString(candidate.name) || !isSeq(candidate.seq) || names.has(candidate.name)) return null;
|
|
10199
|
+
names.add(candidate.name);
|
|
10200
|
+
candidates.push({
|
|
10201
|
+
name: candidate.name,
|
|
10202
|
+
seq: candidate.seq
|
|
10203
|
+
});
|
|
10204
|
+
}
|
|
10205
|
+
if (!isKeepList(payload.keep, names)) return null;
|
|
10206
|
+
return {
|
|
10207
|
+
compactionId: payload.compactionId,
|
|
10208
|
+
summarySeq: payload.summarySeq,
|
|
10209
|
+
candidates,
|
|
10210
|
+
keep: [...payload.keep]
|
|
10211
|
+
};
|
|
10212
|
+
}
|
|
10213
|
+
function isObject(value) {
|
|
10214
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10215
|
+
}
|
|
10216
|
+
function hasExactKeys(value, keys) {
|
|
10217
|
+
return Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
10218
|
+
}
|
|
10219
|
+
function isNonEmptyString(value) {
|
|
10220
|
+
return typeof value === "string" && value.trim() !== "";
|
|
10221
|
+
}
|
|
10222
|
+
function isSeq(value) {
|
|
10223
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
10224
|
+
}
|
|
10225
|
+
function isKeepList(value, allowed) {
|
|
10226
|
+
if (!Array.isArray(value)) return false;
|
|
10227
|
+
const seen = new Set();
|
|
10228
|
+
for (const name of value) {
|
|
10229
|
+
if (typeof name !== "string" || !allowed.has(name) || seen.has(name)) return false;
|
|
10230
|
+
seen.add(name);
|
|
10231
|
+
}
|
|
10232
|
+
return true;
|
|
10233
|
+
}
|
|
10234
|
+
//#endregion
|
|
10235
|
+
//#region src/shared/skill-retention-status.ts
|
|
10236
|
+
function readSkillRetentionSelection(message) {
|
|
10237
|
+
if (typeof message !== "object" || message === null) return null;
|
|
10238
|
+
const source = message.source;
|
|
10239
|
+
if (typeof source !== "object" || source === null) return null;
|
|
10240
|
+
const value = source.selection;
|
|
10241
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
10242
|
+
const data = value;
|
|
10243
|
+
if (data.status !== "completed" && data.status !== "fallback" || typeof data.completedAt !== "number" || !Number.isFinite(data.completedAt) || data.completedAt < 0 || data.reason !== void 0 && (typeof data.reason !== "string" || data.reason.trim() === "") || Object.keys(data).some((key) => ![
|
|
10244
|
+
"status",
|
|
10245
|
+
"reason",
|
|
10246
|
+
"completedAt"
|
|
10247
|
+
].includes(key))) return null;
|
|
10248
|
+
return {
|
|
10249
|
+
status: data.status,
|
|
10250
|
+
completedAt: data.completedAt,
|
|
10251
|
+
...data.reason === void 0 ? {} : { reason: data.reason }
|
|
10252
|
+
};
|
|
10253
|
+
}
|
|
10254
|
+
//#endregion
|
|
10255
|
+
//#region src/client/skill-retention/conversation.ts
|
|
10256
|
+
const RETENTION_KIND = "desktop-enhance-skill-retention";
|
|
10257
|
+
function durableRetention(event) {
|
|
10258
|
+
if (event.type !== "user/message" || typeof event.seq !== "number" || !Number.isSafeInteger(event.seq) || event.seq < 0) return;
|
|
10259
|
+
const record = readSkillRetentionRecord(event.data);
|
|
10260
|
+
const selection = readSkillRetentionSelection(event.data);
|
|
10261
|
+
if (!record || !selection || event.seq <= record.summarySeq) return;
|
|
10262
|
+
const phase = selection.status === "fallback" ? "fallback" : selection.reason === "no_candidates" || selection.reason === "disabled" ? "skipped" : "ready";
|
|
10263
|
+
return {
|
|
10264
|
+
compactionId: record.compactionId,
|
|
10265
|
+
phase,
|
|
10266
|
+
candidates: record.candidates.map((item) => item.name),
|
|
10267
|
+
keep: record.keep,
|
|
10268
|
+
forkSeq: event.seq,
|
|
10269
|
+
...selection.reason ? { reason: selection.reason } : {}
|
|
10270
|
+
};
|
|
10271
|
+
}
|
|
10272
|
+
function dataOf(match) {
|
|
10273
|
+
const record = match.event.type === "user/message" ? readSkillRetentionRecord(match.event.data) : null;
|
|
10274
|
+
const data = match.event.data;
|
|
10275
|
+
return {
|
|
10276
|
+
compactionId: record?.compactionId ?? data.compactionId,
|
|
10277
|
+
durable: durableRetention(match.event)
|
|
10278
|
+
};
|
|
10279
|
+
}
|
|
10280
|
+
const retentionDefinition = {
|
|
10281
|
+
kind: RETENTION_KIND,
|
|
10282
|
+
target: "chat",
|
|
10283
|
+
match(event) {
|
|
10284
|
+
if (event.type === "compaction/start") {
|
|
10285
|
+
const data = event.data;
|
|
10286
|
+
return typeof data?.compactionId === "string" ? {
|
|
10287
|
+
id: data.compactionId,
|
|
10288
|
+
role: "start"
|
|
10289
|
+
} : null;
|
|
10290
|
+
}
|
|
10291
|
+
const record = event.type === "user/message" ? readSkillRetentionRecord(event.data) : null;
|
|
10292
|
+
return record ? {
|
|
10293
|
+
id: record.compactionId,
|
|
10294
|
+
role: "start",
|
|
10295
|
+
exclusive: true
|
|
10296
|
+
} : null;
|
|
10297
|
+
},
|
|
10298
|
+
start(_context, match) {
|
|
10299
|
+
return dataOf(match);
|
|
10300
|
+
},
|
|
10301
|
+
update(context, match) {
|
|
10302
|
+
return {
|
|
10303
|
+
...context.state,
|
|
10304
|
+
...dataOf(match),
|
|
10305
|
+
durable: durableRetention(match.event) ?? context.state?.durable
|
|
10306
|
+
};
|
|
10307
|
+
},
|
|
10308
|
+
buildViewNode(context) {
|
|
10309
|
+
return {
|
|
10310
|
+
key: context.key,
|
|
10311
|
+
kind: RETENTION_KIND,
|
|
10312
|
+
id: context.id,
|
|
10313
|
+
target: "chat",
|
|
10314
|
+
anchorSeq: context.start?.event.seq,
|
|
10315
|
+
location: context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" },
|
|
10316
|
+
visibility: "visible",
|
|
10317
|
+
groupTree: "turn",
|
|
10318
|
+
data: context.state
|
|
10319
|
+
};
|
|
10320
|
+
}
|
|
10321
|
+
};
|
|
10322
|
+
//#endregion
|
|
10323
|
+
//#region src/client/skill-retention/read.ts
|
|
10324
|
+
const LOADING = { phase: "loading" };
|
|
10325
|
+
const settling = new Set([
|
|
10326
|
+
"running",
|
|
10327
|
+
"waiting-compaction",
|
|
10328
|
+
"waiting-selection",
|
|
10329
|
+
"saving"
|
|
10330
|
+
]);
|
|
10331
|
+
function createRetentionReads(fetcher) {
|
|
10332
|
+
const entries = new Map();
|
|
10333
|
+
const keyOf = (sessionId, compactionId) => JSON.stringify([sessionId, compactionId]);
|
|
10334
|
+
return {
|
|
10335
|
+
get(sessionId, compactionId) {
|
|
10336
|
+
return entries.get(keyOf(sessionId, compactionId))?.value ?? LOADING;
|
|
10337
|
+
},
|
|
10338
|
+
subscribe(sessionId, compactionId, listener) {
|
|
10339
|
+
const key = keyOf(sessionId, compactionId);
|
|
10340
|
+
let entry = entries.get(key);
|
|
10341
|
+
if (!entry) {
|
|
10342
|
+
entry = {
|
|
10343
|
+
value: LOADING,
|
|
10344
|
+
listeners: new Set(),
|
|
10345
|
+
abort: new globalThis.AbortController()
|
|
10346
|
+
};
|
|
10347
|
+
entries.set(key, entry);
|
|
10348
|
+
}
|
|
10349
|
+
const owner = entry;
|
|
10350
|
+
const first = owner.listeners.size === 0;
|
|
10351
|
+
owner.listeners.add(listener);
|
|
10352
|
+
const read = async () => {
|
|
10353
|
+
try {
|
|
10354
|
+
const response = await fetcher(`${SKILL_RETENTION_ROUTE}?sessionId=${encodeURIComponent(sessionId)}&compactionId=${encodeURIComponent(compactionId)}`, {
|
|
10355
|
+
method: "GET",
|
|
10356
|
+
signal: owner.abort.signal
|
|
10357
|
+
});
|
|
10358
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
10359
|
+
const value = parseStatus(await response.json(), compactionId);
|
|
10360
|
+
if (owner.abort.signal.aborted) return;
|
|
10361
|
+
owner.value = value;
|
|
10362
|
+
for (const notify of owner.listeners) notify();
|
|
10363
|
+
if (!owner.abort.signal.aborted && settling.has(value.phase)) owner.timer = globalThis.setTimeout(() => {
|
|
10364
|
+
read();
|
|
10365
|
+
}, 1e3);
|
|
10366
|
+
} catch (error) {
|
|
10367
|
+
if (owner.abort.signal.aborted) return;
|
|
10368
|
+
owner.value = {
|
|
10369
|
+
phase: "read-failed",
|
|
10370
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
10371
|
+
};
|
|
10372
|
+
for (const notify of owner.listeners) notify();
|
|
10373
|
+
}
|
|
10374
|
+
};
|
|
10375
|
+
if (first) {
|
|
10376
|
+
owner.retry = () => {
|
|
10377
|
+
owner.value = LOADING;
|
|
10378
|
+
for (const notify of owner.listeners) notify();
|
|
10379
|
+
read();
|
|
10380
|
+
};
|
|
10381
|
+
read();
|
|
10382
|
+
}
|
|
10383
|
+
return () => {
|
|
10384
|
+
owner.listeners.delete(listener);
|
|
10385
|
+
if (owner.listeners.size) return;
|
|
10386
|
+
owner.abort.abort();
|
|
10387
|
+
globalThis.clearTimeout(owner.timer);
|
|
10388
|
+
entries.delete(key);
|
|
10389
|
+
};
|
|
10390
|
+
},
|
|
10391
|
+
retry(sessionId, compactionId) {
|
|
10392
|
+
const entry = entries.get(keyOf(sessionId, compactionId));
|
|
10393
|
+
if (entry?.value.phase === "read-failed") entry.retry?.();
|
|
10394
|
+
},
|
|
10395
|
+
dispose() {
|
|
10396
|
+
for (const entry of entries.values()) {
|
|
10397
|
+
entry.abort.abort();
|
|
10398
|
+
globalThis.clearTimeout(entry.timer);
|
|
10399
|
+
}
|
|
10400
|
+
entries.clear();
|
|
10401
|
+
}
|
|
10402
|
+
};
|
|
10403
|
+
}
|
|
10404
|
+
function parseStatus(body, compactionId) {
|
|
10405
|
+
const snapshot = body?.snapshot;
|
|
10406
|
+
if (!snapshot || snapshot.compactionId !== compactionId || ![
|
|
10407
|
+
"running",
|
|
10408
|
+
"waiting-compaction",
|
|
10409
|
+
"waiting-selection",
|
|
10410
|
+
"saving",
|
|
10411
|
+
"ready",
|
|
10412
|
+
"fallback",
|
|
10413
|
+
"failed",
|
|
10414
|
+
"cancelled",
|
|
10415
|
+
"unavailable",
|
|
10416
|
+
"skipped"
|
|
10417
|
+
].includes(snapshot.phase) || !Array.isArray(snapshot.candidates) || !snapshot.candidates.every((name) => typeof name === "string") || !Array.isArray(snapshot.keep) || !snapshot.keep.every((name) => typeof name === "string") || snapshot.reason !== void 0 && typeof snapshot.reason !== "string" || snapshot.forkSeq !== void 0 && (!Number.isSafeInteger(snapshot.forkSeq) || snapshot.forkSeq < 0)) throw new Error("invalid-status");
|
|
10418
|
+
return snapshot;
|
|
10419
|
+
}
|
|
10420
|
+
function retentionView(live, durable) {
|
|
10421
|
+
return live.phase === "unavailable" && durable ? durable : live;
|
|
10422
|
+
}
|
|
10423
|
+
function retentionForkSeq(value) {
|
|
10424
|
+
return value.phase === "ready" || value.phase === "fallback" || value.phase === "skipped" ? value.forkSeq : void 0;
|
|
10425
|
+
}
|
|
10126
10426
|
//#endregion
|
|
10127
10427
|
//#region src/client/context-manager/fork.ts
|
|
10428
|
+
function retentionByCommand(entries) {
|
|
10429
|
+
const result = new Map();
|
|
10430
|
+
const durable = new Map();
|
|
10431
|
+
for (const event of unwrapEvents(entries)) {
|
|
10432
|
+
const record = durableRetention(event);
|
|
10433
|
+
if (record) durable.set(record.compactionId, record);
|
|
10434
|
+
const source = event.data?.source;
|
|
10435
|
+
if (event.type === "user/message" && source?.kind === "compact-checkpoint" && typeof source.sourceCommandId === "string" && typeof source.compactionId === "string") result.set(source.sourceCommandId, { compactionId: source.compactionId });
|
|
10436
|
+
}
|
|
10437
|
+
for (const item of result.values()) item.durable = durable.get(item.compactionId);
|
|
10438
|
+
return result;
|
|
10439
|
+
}
|
|
10440
|
+
function safeCompactionBoundary(boundary, identity, sessionId, reads, recoveryEnabled) {
|
|
10441
|
+
if (!recoveryEnabled) return boundary;
|
|
10442
|
+
const seq = retentionForkSeq(retentionView(reads.get(sessionId, identity.compactionId), identity.durable));
|
|
10443
|
+
return seq !== void 0 && seq >= boundary ? seq : void 0;
|
|
10444
|
+
}
|
|
10128
10445
|
const COMPACTION_FORK_ATTR = "data-desktop-enhance-compaction-fork";
|
|
10129
10446
|
const COMPACTION_KIND = "manual-compaction";
|
|
10130
10447
|
function commandIdOfRowKey(rowKey) {
|
|
@@ -10170,13 +10487,19 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10170
10487
|
if (row.querySelector(`[data-desktop-enhance-compaction-fork]`) !== null) return () => {};
|
|
10171
10488
|
const holder = globalThis.document.createElement("div");
|
|
10172
10489
|
holder.setAttribute(COMPACTION_FORK_ATTR, "");
|
|
10173
|
-
holder.dataset.boundary = String(boundary);
|
|
10490
|
+
holder.dataset.boundary = String(boundary ?? "pending");
|
|
10174
10491
|
holder.dataset.rowKey = rowKey;
|
|
10175
10492
|
const button = globalThis.document.createElement("button");
|
|
10176
10493
|
button.type = "button";
|
|
10177
10494
|
button.className = "de-compaction-fork";
|
|
10178
10495
|
button.setAttribute("aria-label", label);
|
|
10179
10496
|
button.title = label;
|
|
10497
|
+
button.disabled = boundary === void 0;
|
|
10498
|
+
if (boundary === void 0) {
|
|
10499
|
+
const reason = globalThis.document.createElement("span");
|
|
10500
|
+
reason.textContent = label;
|
|
10501
|
+
holder.appendChild(reason);
|
|
10502
|
+
}
|
|
10180
10503
|
button.innerHTML = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1\" aria-hidden=\"true\"><path d=\"M1.01503 8.0001L5.6964 8.0001C6.41913 8.0001 6.78049 8.0001 7.12115 7.91951C7.4232 7.84804 7.71233 7.73014 7.97821 7.57C8.27809 7.38939 8.5364 7.13669 9.05303 6.63129L11.3281 4.40564\"/><path d=\"M1.01221 7.9999L5.6964 7.9999C6.41913 7.9999 6.78049 7.9999 7.12115 8.08049C7.4232 8.15196 7.71233 8.26986 7.97821 8.43C8.27809 8.61061 8.5364 8.86331 9.05303 9.36871L11.3281 11.5944\"/><circle cx=\"12.4502\" cy=\"3.3079\" r=\"1.56962\"/><circle cx=\"12.4502\" cy=\"12.6921\" r=\"1.56962\"/></svg>";
|
|
10181
10504
|
holder.appendChild(button);
|
|
10182
10505
|
row.appendChild(holder);
|
|
@@ -10185,6 +10508,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10185
10508
|
let created;
|
|
10186
10509
|
button.addEventListener("click", () => {
|
|
10187
10510
|
(async () => {
|
|
10511
|
+
if (boundary === void 0) return;
|
|
10188
10512
|
const diagnostic = startClientDiagnostic("session", "session.client.fork", { sessionId }, {
|
|
10189
10513
|
source: "manual-compaction",
|
|
10190
10514
|
atSeq: boundary
|
|
@@ -10244,8 +10568,74 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10244
10568
|
};
|
|
10245
10569
|
}
|
|
10246
10570
|
//#endregion
|
|
10571
|
+
//#region src/client/skill-retention/index.ts
|
|
10572
|
+
function installSkillRetention(ctx, settings, reads, t) {
|
|
10573
|
+
const offDefinition = ctx.get("uiConversation").events.register(retentionDefinition);
|
|
10574
|
+
function View({ node, sessionId, useAccess }) {
|
|
10575
|
+
const enabled = React.useSyncExternalStore(settings.subscribe, () => settings.get().value?.contextManager !== false && settings.get().value?.skillRecovery !== false);
|
|
10576
|
+
const allowed = useAccess("session/fork");
|
|
10577
|
+
const { compactionId, durable } = node.data;
|
|
10578
|
+
const subscribe = React.useCallback((notify) => enabled ? reads.subscribe(sessionId, compactionId, notify) : () => {}, [
|
|
10579
|
+
sessionId,
|
|
10580
|
+
compactionId,
|
|
10581
|
+
enabled
|
|
10582
|
+
]);
|
|
10583
|
+
const value = retentionView(React.useSyncExternalStore(subscribe, () => reads.get(sessionId, compactionId)), durable);
|
|
10584
|
+
const seq = retentionForkSeq(value);
|
|
10585
|
+
const root = React.useRef(null);
|
|
10586
|
+
const access = React.useRef(allowed);
|
|
10587
|
+
access.current = allowed;
|
|
10588
|
+
React.useEffect(() => {
|
|
10589
|
+
if (!enabled || !allowed || seq === void 0 || !root.current) return;
|
|
10590
|
+
return attachCompactionFork(root.current, compactionId, seq, sessionId, {
|
|
10591
|
+
fork(options) {
|
|
10592
|
+
const sessions = ctx.get("sessions");
|
|
10593
|
+
if (!sessions) throw new Error("sessions service unavailable");
|
|
10594
|
+
return sessions.fork(options);
|
|
10595
|
+
},
|
|
10596
|
+
openSession(id) {
|
|
10597
|
+
const workspace = ctx.get("uiWorkspace");
|
|
10598
|
+
if (!workspace) throw new Error("workspace service unavailable");
|
|
10599
|
+
workspace.openSession(id);
|
|
10600
|
+
}
|
|
10601
|
+
}, t("retention.fork"), () => access.current && settings.get().value?.contextManager !== false && settings.get().value?.skillRecovery !== false && retentionForkSeq(retentionView(reads.get(sessionId, compactionId), durable)) === seq);
|
|
10602
|
+
}, [
|
|
10603
|
+
sessionId,
|
|
10604
|
+
compactionId,
|
|
10605
|
+
seq,
|
|
10606
|
+
allowed,
|
|
10607
|
+
enabled
|
|
10608
|
+
]);
|
|
10609
|
+
if (!enabled) return null;
|
|
10610
|
+
return h("section", {
|
|
10611
|
+
"data-desktop-enhance-retention": compactionId,
|
|
10612
|
+
style: {
|
|
10613
|
+
borderLeft: "2px solid var(--dsw-alias-label-primary-bluish)",
|
|
10614
|
+
padding: "8px 12px",
|
|
10615
|
+
color: "var(--dsw-alias-label-primary)"
|
|
10616
|
+
}
|
|
10617
|
+
}, h("strong", null, t("retention.title")), h("div", {
|
|
10618
|
+
role: "status",
|
|
10619
|
+
"data-retention-phase": value.phase
|
|
10620
|
+
}, t(`retention.${value.phase}`)), value.reason ? h("div", { style: { color: "var(--dsw-alias-label-secondary)" } }, value.reason) : null, value.phase === "read-failed" ? h("button", {
|
|
10621
|
+
type: "button",
|
|
10622
|
+
onClick: () => reads.retry(sessionId, compactionId)
|
|
10623
|
+
}, t("retention.retry")) : null, "candidates" in value ? h("details", null, h("summary", null, t("retention.details")), h("div", null, `${t("retention.candidates")}: ${value.candidates.join(", ") || t("retention.none")}`), value.phase === "ready" || value.phase === "fallback" ? h("div", null, h("div", null, `${t("retention.keep")}: ${value.keep.join(", ") || t("retention.none")}`), h("div", null, `${t("retention.drop")}: ${value.candidates.filter((name) => !value.keep.includes(name)).join(", ") || t("retention.none")}`)) : null) : null, h("div", { ref: root }));
|
|
10624
|
+
}
|
|
10625
|
+
const offSlot = ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
|
|
10626
|
+
name: "conversation.chat.node",
|
|
10627
|
+
key: RETENTION_KIND,
|
|
10628
|
+
locale: NS,
|
|
10629
|
+
inject: (sessionId) => ({ sessionId })
|
|
10630
|
+
}, View));
|
|
10631
|
+
return () => {
|
|
10632
|
+
offSlot();
|
|
10633
|
+
offDefinition();
|
|
10634
|
+
};
|
|
10635
|
+
}
|
|
10636
|
+
//#endregion
|
|
10247
10637
|
//#region src/client/index.tsx
|
|
10248
|
-
const PLUGIN_STYLESHEET = enhance_css_default + "\n" + tabs_css_default + "\n" + styles_css_default$
|
|
10638
|
+
const PLUGIN_STYLESHEET = "[data-desktop-enhance-retention] {\n font: inherit;\n overflow-wrap: anywhere;\n}\n[data-desktop-enhance-retention] > button {\n font: inherit;\n color: var(--dsw-alias-label-primary);\n background: transparent;\n border: 1px solid var(--dsw-alias-border-l1);\n cursor: pointer;\n}\n[data-desktop-enhance-retention] summary { cursor: pointer; }\n\n" + enhance_css_default + "\n" + tabs_css_default + "\n" + styles_css_default$4 + "\n" + styles_css_default$3 + "\n" + styles_css_default$2 + "\n\n\n.de-context-controls {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-divider {\n height: 0;\n margin: 8px 0 6px;\n border: 0;\n border-top: 0.5px solid var(--dsw-alias-border-l3);\n}\n\n.de-context-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n min-height: 24px;\n padding: 2px 0;\n}\n\n.de-context-label {\n color: var(--dsw-alias-label-secondary);\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n\n.de-context-value {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-controls-inline {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n margin-left: auto;\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-btn {\n font: inherit;\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-primary);\n background: none;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n padding: 0 5px;\n margin-right: -5px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n transition: background-color .12s, color .12s;\n}\n\n.de-context-btn:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.de-context-btn:disabled {\n cursor: default;\n opacity: .5;\n background: none;\n}\n\n.de-context-btn:focus-visible,\n.de-context-input:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n.de-context-reset {\n font-size: 11px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 0;\n padding: 0 4px;\n}\n\n.de-context-reset:hover {\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-context-save {\n color: var(--dsw-alias-state-business-primary, #3979be);\n font-weight: 500;\n}\n\n.de-context-input {\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n width: 50px;\n height: 22px;\n padding: 0 5px;\n text-align: right;\n border: 0.5px solid var(--dsw-alias-border-l1);\n border-radius: var(--dsw-radius-sm, 4px);\n background: var(--dsw-alias-bg-base);\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n\n.de-context-unit {\n font-size: 11px;\n color: var(--dsw-alias-label-tertiary);\n margin-right: 2px;\n}\n\n.de-context-note {\n font-size: 11px;\n line-height: 16px;\n color: var(--dsw-alias-label-tertiary);\n padding-top: 2px;\n overflow-wrap: anywhere;\n}\n\n.de-context-recent-result {\n padding: 4px 0;\n}\n\n.de-context-recent-result summary {\n cursor: pointer;\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-context-recent-details {\n font: inherit;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n max-height: 240px;\n max-width: 320px;\n overflow: auto;\n margin: 4px 0;\n}\n\n\n[data-desktop-enhance-compaction-fork] {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0 0;\n}\n\n.de-compaction-fork {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: 0;\n border-radius: var(--dsw-radius-sm, 4px);\n background: none;\n color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n transition: background-color .12s, color .12s;\n}\n\n.de-compaction-fork:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-secondary);\n}\n\n.de-compaction-fork:disabled {\n cursor: default;\n opacity: .5;\n}\n\n.de-compaction-fork:focus-visible {\n outline: 1.5px solid var(--dsw-focus-ring-color, #578cc9);\n outline-offset: 1px;\n}\n\n\n:root[data-desktop-enhance-off-context-manager] [data-desktop-enhance-context-controls] {\n display: none !important;\n}\n\n\n\n:root:not([data-desktop-enhance-off-context-manager]) [data-desktop-enhance-context-controls] {\n display: revert;\n}\n\n\n:root[data-desktop-enhance-off-recent-conversation] [data-desktop-enhance-item=\"recentConversation\"] [data-desktop-enhance-hint],\n:root[data-desktop-enhance-off-skill-recovery] [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 0.55;\n}\n\n:root:not([data-desktop-enhance-off-recent-conversation]) [data-desktop-enhance-item=\"recentConversation\"] [data-desktop-enhance-hint],\n:root:not([data-desktop-enhance-off-skill-recovery]) [data-desktop-enhance-item=\"skillRecovery\"] [data-desktop-enhance-hint] {\n opacity: 1;\n}\n";
|
|
10249
10639
|
const inject = [
|
|
10250
10640
|
"slots",
|
|
10251
10641
|
"locale",
|
|
@@ -10301,6 +10691,11 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10301
10691
|
value: void 0,
|
|
10302
10692
|
writable: true
|
|
10303
10693
|
});
|
|
10694
|
+
const retentionReads = createRetentionReads((...args) => globalThis.fetch(...args));
|
|
10695
|
+
ctx.effect(() => () => retentionReads.dispose(), "desktop-enhance: skill retention reads");
|
|
10696
|
+
ctx.inject(["uiConversation"], (conversationCtx) => {
|
|
10697
|
+
conversationCtx.effect(() => installSkillRetention(ctx, settings, retentionReads, t), "desktop-enhance: skill retention conversation");
|
|
10698
|
+
});
|
|
10304
10699
|
ctx.effect(() => installAbnormalFork(ctx, settings, t), "desktop-enhance: abnormal turn fork");
|
|
10305
10700
|
ctx.effect(() => {
|
|
10306
10701
|
let dispose;
|
|
@@ -10453,12 +10848,17 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10453
10848
|
if (typeof globalThis.MutationObserver !== "function") return () => void 0;
|
|
10454
10849
|
const sessionsService = () => ctx.get("sessions");
|
|
10455
10850
|
const workspaceService = () => ctx.get("uiWorkspace");
|
|
10456
|
-
const label =
|
|
10851
|
+
const label = t("retention.compactionFork");
|
|
10457
10852
|
const disposers = new Map();
|
|
10458
10853
|
let observer;
|
|
10459
10854
|
let watchedSource;
|
|
10460
10855
|
let unsubscribeEvents;
|
|
10461
10856
|
let lastSession;
|
|
10857
|
+
const retentionSubscriptions = new Map();
|
|
10858
|
+
const stopRetentionReads = () => {
|
|
10859
|
+
for (const stop of retentionSubscriptions.values()) stop();
|
|
10860
|
+
retentionSubscriptions.clear();
|
|
10861
|
+
};
|
|
10462
10862
|
let disposed = false;
|
|
10463
10863
|
let scheduled = false;
|
|
10464
10864
|
const stopEventWatch = () => {
|
|
@@ -10500,6 +10900,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10500
10900
|
const allowed = sessionId !== void 0 && flagOn(settings.get().value, "contextManager") && forkAccess.get(sessionId) === true;
|
|
10501
10901
|
if (!allowed || sessionId !== lastSession) {
|
|
10502
10902
|
stopEventWatch();
|
|
10903
|
+
stopRetentionReads();
|
|
10503
10904
|
for (const dispose of disposers.values()) dispose();
|
|
10504
10905
|
disposers.clear();
|
|
10505
10906
|
}
|
|
@@ -10507,7 +10908,16 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10507
10908
|
if (!allowed || sessionId === void 0) return;
|
|
10508
10909
|
const sessions = sessionsService();
|
|
10509
10910
|
syncEventWatch(sessionEventSource(sessions, sessionId));
|
|
10510
|
-
const
|
|
10911
|
+
const entries = readSessionEvents(sessions, sessionId);
|
|
10912
|
+
const boundaries = compactionBoundaryByCommand(entries);
|
|
10913
|
+
const identities = retentionByCommand(entries);
|
|
10914
|
+
const recoveryEnabled = settings.get().value?.skillRecovery !== false;
|
|
10915
|
+
const wanted = new Set(recoveryEnabled ? [...boundaries.keys()].map((id) => identities.get(id)?.compactionId).filter((id) => id !== void 0) : []);
|
|
10916
|
+
for (const [id, stop] of retentionSubscriptions) if (!wanted.has(id)) {
|
|
10917
|
+
stop();
|
|
10918
|
+
retentionSubscriptions.delete(id);
|
|
10919
|
+
}
|
|
10920
|
+
for (const id of wanted) if (!retentionSubscriptions.has(id)) retentionSubscriptions.set(id, retentionReads.subscribe(sessionId, id, schedule));
|
|
10511
10921
|
for (const [row, dispose] of disposers) if (!row.isConnected) {
|
|
10512
10922
|
dispose();
|
|
10513
10923
|
disposers.delete(row);
|
|
@@ -10516,12 +10926,16 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10516
10926
|
const key = row.getAttribute("data-chat-anchor-key") ?? "";
|
|
10517
10927
|
const commandId = commandIdOfRowKey(key);
|
|
10518
10928
|
if (commandId === null) continue;
|
|
10519
|
-
const
|
|
10929
|
+
const nativeBoundary = boundaries.get(commandId);
|
|
10930
|
+
const identity = identities.get(commandId);
|
|
10931
|
+
const boundary = nativeBoundary === void 0 || identity === void 0 ? void 0 : safeCompactionBoundary(nativeBoundary, identity, sessionId, retentionReads, recoveryEnabled);
|
|
10520
10932
|
const existing = row.querySelector(`[${COMPACTION_FORK_ATTR}]`);
|
|
10521
|
-
|
|
10933
|
+
const status = identity ? retentionView(retentionReads.get(sessionId, identity.compactionId), identity.durable) : void 0;
|
|
10934
|
+
const buttonLabel = boundary === void 0 && status ? t(`retention.${status.phase}`) : label;
|
|
10935
|
+
if (nativeBoundary !== void 0 && existing?.dataset.boundary === String(boundary ?? "pending") && existing.querySelector("button")?.title === buttonLabel) continue;
|
|
10522
10936
|
disposers.get(row)?.();
|
|
10523
10937
|
disposers.delete(row);
|
|
10524
|
-
if (
|
|
10938
|
+
if (nativeBoundary === void 0) continue;
|
|
10525
10939
|
disposers.set(row, attachCompactionFork(row, key, boundary, sessionId, {
|
|
10526
10940
|
fork: (options) => {
|
|
10527
10941
|
const sessions = sessionsService();
|
|
@@ -10529,7 +10943,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10529
10943
|
return sessions.fork(options);
|
|
10530
10944
|
},
|
|
10531
10945
|
openSession: (id) => workspaceService()?.openSession?.(id)
|
|
10532
|
-
},
|
|
10946
|
+
}, buttonLabel, () => !disposed && currentSessionId() === sessionId && flagOn(settings.get().value, "contextManager") && forkAccess.get(sessionId) === true && identity !== void 0 && nativeBoundary !== void 0 && safeCompactionBoundary(nativeBoundary, identity, sessionId, retentionReads, settings.get().value?.skillRecovery !== false) === boundary));
|
|
10533
10947
|
}
|
|
10534
10948
|
};
|
|
10535
10949
|
const schedule = () => {
|
|
@@ -10547,6 +10961,7 @@ ABORT_ERR ETIMEDOUT ECONNREFUSED ECONNRESET EPIPE EADDRINUSE ENOSPC EACCES STORE
|
|
|
10547
10961
|
return () => {
|
|
10548
10962
|
disposed = true;
|
|
10549
10963
|
stopEventWatch();
|
|
10964
|
+
stopRetentionReads();
|
|
10550
10965
|
observer?.disconnect();
|
|
10551
10966
|
unsubscribe();
|
|
10552
10967
|
accessListeners.delete(schedule);
|