@michengai/dsh-codex-ui 2.4.4 → 2.4.5
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/CHANGELOG.zh-CN.md +7 -0
- package/README.de.md +1 -1
- package/README.en.md +1 -1
- package/README.es.md +1 -1
- package/README.fr.md +1 -1
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/README.pt.md +1 -1
- package/README.ru.md +1 -1
- package/README.zh-CN.md +1 -1
- package/lib/client.js +73 -20
- package/lib/composer-plugin.mjs +72 -27
- package/lib/host-services-k-J3TuxA.mjs +25 -0
- package/lib/index.d.mts +41 -1
- package/lib/index.mjs +23 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.5] - 2026-11-25
|
|
4
|
+
|
|
5
|
+
- **Improve Workspace Section Recovery and Real-Time Synchronization**:
|
|
6
|
+
- Enhanced workspace section loading to automatically restore existing section headers upon mid-session login or credential refresh without requiring a page reload;
|
|
7
|
+
- Refined the automatic save mechanism when quickly rearranging workspace sections, ensuring the newest order and membership always persist reliably;
|
|
8
|
+
- Strengthened coordination with the latest host connection authentication services for consistent stability across host environments.
|
|
9
|
+
|
|
3
10
|
## [2.4.4] - 2026-11-24
|
|
4
11
|
|
|
5
12
|
- **Full Compatibility with DeepSeek Harness 0.2.3 Series**:
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [2.4.5] - 2026-11-25
|
|
4
|
+
|
|
5
|
+
- **工作区分区恢复与实时同步体验优化**:
|
|
6
|
+
- 优化工作区分区加载机制,会话中途登录或授权刷新后自动恢复已有分区列表,无需手动刷新页面;
|
|
7
|
+
- 优化快速连续拖拽调整工作区分组时的自动保存机制,确保最新调整的分组归属始终完整保存不遗漏;
|
|
8
|
+
- 增强与宿主最新连接鉴权机制的协同,提升在各类宿主环境下的运行稳定性。
|
|
9
|
+
|
|
3
10
|
## [2.4.4] - 2026-11-24
|
|
4
11
|
|
|
5
12
|
- **全面适配 DeepSeek Harness 0.2.3 最新版本**:
|
package/README.de.md
CHANGED
|
@@ -142,7 +142,7 @@ Direkte Aktionen an jeder Konversation: Anheften, Umbenennen, Als ungelesen/gele
|
|
|
142
142
|
## Host-Kompatibilität
|
|
143
143
|
|
|
144
144
|
* **Unterstützte Generationen**: Vollständige DeepSeek Harness `0.2.x`-Reihe (`>=0.2.2-rc.1 <0.3.0-0`);
|
|
145
|
-
* **Geprüfte Builds**: Alle `0.2.2` Release Candidates (`0.2.2-rc.1`–`0.2.2-rc.5`);
|
|
145
|
+
* **Geprüfte Builds**: Alle `0.2.2` Release Candidates (`0.2.2-rc.1`–`0.2.2-rc.5`) übernehmen die Prüfung aus 2.4.4; `0.2.3` (`0.2.3-alpha.2`) ist mit dem aktuellen Authentifizierungs-Fix geprüft;
|
|
146
146
|
* **Laufzeit-Anforderungen**: Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
147
147
|
|
|
148
148
|
> ⚠️ **Wichtiger Hinweis**: Aktivieren Sie Codex UI und `ds-bot` nicht gleichzeitig, da beide Modifikationen an der Seitenleiste vornehmen.
|
package/README.en.md
CHANGED
|
@@ -147,7 +147,7 @@ Quick actions directly on session rows: Pin, Rename, Unread marker, Archive, For
|
|
|
147
147
|
## Host Compatibility
|
|
148
148
|
|
|
149
149
|
* **Supported Generations**: Full DeepSeek Harness `0.2.x` line (`>=0.2.2-rc.1 <0.3.0-0`);
|
|
150
|
-
* **Verified Builds**:
|
|
150
|
+
* **Verified Builds**: Every `0.2.2` RC (`0.2.2-rc.1`–`0.2.2-rc.5`) carries over the verification from 2.4.4; `0.2.3` (`0.2.3-alpha.2`) is verified with the current authentication fix;
|
|
151
151
|
* **Runtime Requirements**: Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
152
152
|
|
|
153
153
|
> ⚠️ **Notice**: Do not enable Codex UI and `ds-bot` concurrently. Both redesign sidebar and session slots with overlapping layout mechanics. Disable or uninstall one before enabling the other.
|
package/README.es.md
CHANGED
|
@@ -142,7 +142,7 @@ Acciones inmediatas en cada conversación: Fijar, Renombrar, Marcar como no leí
|
|
|
142
142
|
## Compatibilidad del Host
|
|
143
143
|
|
|
144
144
|
* **Versiones Soportadas**: Familia DeepSeek Harness `0.2.x` (`>=0.2.2-rc.1 <0.3.0-0`);
|
|
145
|
-
* **Compilaciones Verificadas**: Todos los RC de `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`);
|
|
145
|
+
* **Compilaciones Verificadas**: Todos los RC de `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`) mantienen la verificación de 2.4.4; `0.2.3` (`0.2.3-alpha.2`) está verificado con la corrección de autenticación actual;
|
|
146
146
|
* **Requisitos de Entorno**: Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
147
147
|
|
|
148
148
|
> ⚠️ **Aviso**: No active simultáneamente Codex UI y `ds-bot`. Ambos rediseñan ranuras de la barra lateral con mecánicas que pueden solaparse.
|
package/README.fr.md
CHANGED
|
@@ -142,7 +142,7 @@ Actions rapides sur chaque session : Épingler, Renommer, Marquer non lu/lu, Arc
|
|
|
142
142
|
## Compatibilité avec l'Hôte
|
|
143
143
|
|
|
144
144
|
* **Générations Prises en Charge** : Famille DeepSeek Harness `0.2.x` (`>=0.2.2-rc.1 <0.3.0-0`) ;
|
|
145
|
-
* **Versions Validées** : Toutes les versions RC de `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`) ;
|
|
145
|
+
* **Versions Validées** : Toutes les versions RC de `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`) reprennent la validation de 2.4.4 ; `0.2.3` (`0.2.3-alpha.2`) est validé avec le correctif d'authentification actuel ;
|
|
146
146
|
* **Prérequis d'Exécution** : Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
147
147
|
|
|
148
148
|
> ⚠️ **Attention** : N'activez pas simultanément Codex UI et `ds-bot`. Les deux extensions modifient les emplacements de la barre latérale avec des risques d'interférence.
|
package/README.ja.md
CHANGED
|
@@ -142,7 +142,7 @@ Ambient Ground の拡散光グラデーションを採用した Codex Light 配
|
|
|
142
142
|
## ホスト互換性
|
|
143
143
|
|
|
144
144
|
* **サポート対象世代**:DeepSeek Harness `0.2.x` 全系(`>=0.2.2-rc.1 <0.3.0-0`);
|
|
145
|
-
* **検証済みビルド**:すべての `0.2.2` RC(`0.2.2-rc.1`~`0.2.2-rc.5
|
|
145
|
+
* **検証済みビルド**:すべての `0.2.2` RC(`0.2.2-rc.1`~`0.2.2-rc.5`)は 2.4.4 の検証結果を引き継ぎ、`0.2.3`(`0.2.3-alpha.2`)は現在の認証修正で検証済みです;
|
|
146
146
|
* **実行要件**:Node.js `^22.19.0 || >=24.0.0`、pnpm `^11.0.0`。
|
|
147
147
|
|
|
148
148
|
> ⚠️ **注意事項**:Codex UI と `ds-bot` を同時に有効化しないでください。サイドバーやセッションスロットの再設計が競合します。一方を有効にする前に、もう一方を無効化またはアンインストールしてください。
|
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
## 宿主兼容性
|
|
148
148
|
|
|
149
149
|
* **支持范围**:DeepSeek Harness `0.2.x` 全系列(`>=0.2.2-rc.1 <0.3.0-0`);
|
|
150
|
-
*
|
|
150
|
+
* **实测验证**:`0.2.2` RC 全系列(`0.2.2-rc.1`~`0.2.2-rc.5`)沿用 2.4.4 的实测结论,`0.2.3`(`0.2.3-alpha.2`)为当前认证修复后的实测版本;
|
|
151
151
|
* **环境要求**:Node.js `^22.19.0 || >=24.0.0`,pnpm `^11.0.0`。
|
|
152
152
|
|
|
153
153
|
> ⚠️ **互斥提示**:请勿同时启用 Codex UI 与 `ds-bot`。两者均重塑侧栏与主会话插槽,功能重叠。启用前请先停用或卸载另一个。
|
package/README.pt.md
CHANGED
|
@@ -142,7 +142,7 @@ Ações imediatas na lista de conversas: Fixar, Renomear, Marcar como não lido/
|
|
|
142
142
|
## Compatibilidade com o Host
|
|
143
143
|
|
|
144
144
|
* **Gerações Suportadas**: Linha completa DeepSeek Harness `0.2.x` (`>=0.2.2-rc.1 <0.3.0-0`);
|
|
145
|
-
* **Compilações Verificadas**: Todas as versões Release Candidate `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`);
|
|
145
|
+
* **Compilações Verificadas**: Todas as versões Release Candidate `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`) mantêm a verificação do 2.4.4; `0.2.3` (`0.2.3-alpha.2`) está verificado com a correção de autenticação atual;
|
|
146
146
|
* **Requisitos de Execução**: Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
147
147
|
|
|
148
148
|
> ⚠️ **Aviso**: Não habilite o Codex UI e o `ds-bot` simultaneamente, pois ambos alteram os slots da barra lateral com potenciais conflitos.
|
package/README.ru.md
CHANGED
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
## Совместимость с хостом
|
|
143
143
|
|
|
144
144
|
* **Поддерживаемые поколения**: Семейство DeepSeek Harness `0.2.x` (`>=0.2.2-rc.1 <0.3.0-0`);
|
|
145
|
-
* **Проверенные сборки**: Все релиз-кандидаты `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`);
|
|
145
|
+
* **Проверенные сборки**: Все релиз-кандидаты `0.2.2` (`0.2.2-rc.1`–`0.2.2-rc.5`) сохраняют результат проверки из 2.4.4; `0.2.3` (`0.2.3-alpha.2`) проверен с текущим исправлением аутентификации;
|
|
146
146
|
* **Требования к окружению**: Node.js `^22.19.0 || >=24.0.0`, pnpm `^11.0.0`.
|
|
147
147
|
|
|
148
148
|
> ⚠️ **Предупреждение**: Не включайте одновременно Codex UI и `ds-bot`, так как они оба модифицируют боковую панель.
|
package/README.zh-CN.md
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
## 宿主兼容性
|
|
148
148
|
|
|
149
149
|
* **支持范围**:DeepSeek Harness `0.2.x` 全系列(`>=0.2.2-rc.1 <0.3.0-0`);
|
|
150
|
-
*
|
|
150
|
+
* **实测验证**:`0.2.2` RC 全系列(`0.2.2-rc.1`~`0.2.2-rc.5`)沿用 2.4.4 的实测结论,`0.2.3`(`0.2.3-alpha.2`)为当前认证修复后的实测版本;
|
|
151
151
|
* **环境要求**:Node.js `^22.19.0 || >=24.0.0`,pnpm `^11.0.0`。
|
|
152
152
|
|
|
153
153
|
> ⚠️ **互斥提示**:请勿同时启用 Codex UI 与 `ds-bot`。两者均重塑侧栏与主会话插槽,功能重叠。启用前请先停用或卸载另一个。
|
package/lib/client.js
CHANGED
|
@@ -10787,7 +10787,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
10787
10787
|
}
|
|
10788
10788
|
for (const root of document.querySelectorAll("[data-phase=hero]")) {
|
|
10789
10789
|
if (mounted.has(root) || !root.querySelector("[data-conversation-scroll]")) continue;
|
|
10790
|
-
const body = root.querySelector("[class*=\"_body\"]");
|
|
10790
|
+
const body = root.querySelector("[class*=\"_body\"]:has([data-conversation-scroll])") ?? root.querySelector("[class*=\"_body\"]");
|
|
10791
10791
|
const clamp = (value) => Math.min(Math.max(640, value), Math.max(640, root.clientWidth - 176));
|
|
10792
10792
|
const current = () => {
|
|
10793
10793
|
const raw = body?.style.getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-user-width") || getComputedStyle(root).getPropertyValue("--dsh-chat-content-width");
|
|
@@ -11338,7 +11338,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11338
11338
|
const cycleRef = react.default.useRef(null);
|
|
11339
11339
|
const currentRef = react.default.useRef("");
|
|
11340
11340
|
const request = react.default.useCallback(async (mode, draftText) => {
|
|
11341
|
-
if (sessionId
|
|
11341
|
+
if (!sessionId || typeof sessionId !== "string" || !sessionId.trim()) return;
|
|
11342
11342
|
if (typeof document !== "undefined" && document.hidden) return;
|
|
11343
11343
|
abortRef.current?.abort();
|
|
11344
11344
|
const controller = new AbortController();
|
|
@@ -13669,19 +13669,32 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13669
13669
|
} else for (let index = 0; index < desired.length; index += 1) if (order[index] !== desired[index]) move(desired[index], order[index]);
|
|
13670
13670
|
return moves;
|
|
13671
13671
|
}
|
|
13672
|
+
//#endregion
|
|
13673
|
+
//#region src/client/sidebar/sections/store.ts
|
|
13674
|
+
/**
|
|
13675
|
+
* 工作区分区的客户端存取层。
|
|
13676
|
+
*
|
|
13677
|
+
* 分区结构与成员归属存在**宿主**(`/api/michengai/dsh-codex-ui/sections`),
|
|
13678
|
+
* 浏览器只用 localStorage 记折叠、展开这类视图偏好——与 Codex 的分层一致
|
|
13679
|
+
* (宿主 DB 存 `thread_sections` / `thread_section_id`,Electron atom state 存折叠与顺序偏好)。
|
|
13680
|
+
*/
|
|
13681
|
+
/** 保留失败状态,让侧栏区分访问被拒绝和宿主暂时不可用。 */
|
|
13682
|
+
var SectionsLoadError = class extends Error {
|
|
13683
|
+
status;
|
|
13684
|
+
constructor(status) {
|
|
13685
|
+
super(`Sections store unavailable: HTTP ${status}`);
|
|
13686
|
+
this.status = status;
|
|
13687
|
+
}
|
|
13688
|
+
};
|
|
13672
13689
|
let transport = {
|
|
13673
13690
|
async load() {
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
return text.trim() === "" ? null : text;
|
|
13682
|
-
} catch {
|
|
13683
|
-
return null;
|
|
13684
|
-
}
|
|
13691
|
+
const response = await fetch(CODEX_UI_API_ENDPOINTS.sections, {
|
|
13692
|
+
credentials: "same-origin",
|
|
13693
|
+
headers: { accept: "application/json" }
|
|
13694
|
+
});
|
|
13695
|
+
if (!response.ok) throw new SectionsLoadError(response.status);
|
|
13696
|
+
const text = await response.text();
|
|
13697
|
+
return text.trim() === "" ? null : text;
|
|
13685
13698
|
},
|
|
13686
13699
|
async save(body) {
|
|
13687
13700
|
try {
|
|
@@ -13699,7 +13712,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13699
13712
|
/**
|
|
13700
13713
|
* 读取宿主里的分区文档。
|
|
13701
13714
|
*
|
|
13702
|
-
* @returns 原始 JSON
|
|
13715
|
+
* @returns 原始 JSON 文本;仅成功读取空内容时返回 `null`,读取失败时抛出异常。
|
|
13703
13716
|
*/
|
|
13704
13717
|
async function loadSectionsDocument() {
|
|
13705
13718
|
return transport.load();
|
|
@@ -13707,14 +13720,16 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13707
13720
|
let pending;
|
|
13708
13721
|
let timer;
|
|
13709
13722
|
let inFlight;
|
|
13723
|
+
let retried = false;
|
|
13710
13724
|
async function flush() {
|
|
13711
13725
|
const body = pending;
|
|
13712
13726
|
pending = void 0;
|
|
13713
13727
|
if (body === void 0) return;
|
|
13714
|
-
if (!await transport.save(body) && pending === void 0) {
|
|
13728
|
+
if (!await transport.save(body) && !retried && pending === void 0) {
|
|
13729
|
+
retried = true;
|
|
13715
13730
|
pending = body;
|
|
13716
13731
|
scheduleSave();
|
|
13717
|
-
}
|
|
13732
|
+
} else retried = false;
|
|
13718
13733
|
}
|
|
13719
13734
|
/** 立刻把待写内容发出去(切换页面、卸载时使用)。 */
|
|
13720
13735
|
async function flushSectionsSave() {
|
|
@@ -13730,7 +13745,10 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13730
13745
|
if (timer !== void 0) window.clearTimeout(timer);
|
|
13731
13746
|
timer = window.setTimeout(() => {
|
|
13732
13747
|
timer = void 0;
|
|
13733
|
-
if (inFlight !== void 0)
|
|
13748
|
+
if (inFlight !== void 0) {
|
|
13749
|
+
if (pending !== void 0) scheduleSave();
|
|
13750
|
+
return;
|
|
13751
|
+
}
|
|
13734
13752
|
inFlight = flush().finally(() => {
|
|
13735
13753
|
inFlight = void 0;
|
|
13736
13754
|
});
|
|
@@ -13743,6 +13761,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
13743
13761
|
*/
|
|
13744
13762
|
function scheduleSectionsSave(body) {
|
|
13745
13763
|
pending = body;
|
|
13764
|
+
retried = false;
|
|
13746
13765
|
scheduleSave();
|
|
13747
13766
|
}
|
|
13748
13767
|
//#endregion
|
|
@@ -14317,19 +14336,53 @@ body[data-dcu-drag-blocked='true'] [class*="dropAfter"]::after{display:none !imp
|
|
|
14317
14336
|
}
|
|
14318
14337
|
};
|
|
14319
14338
|
const domOrder = () => collectProjectBlocks(list ?? document, list).map((block) => block.workspaceId);
|
|
14339
|
+
let hostReloadAttempts = 0;
|
|
14340
|
+
const MAX_HOST_RELOAD_ATTEMPTS = 5;
|
|
14341
|
+
/** 登录 / 权限态可能在会话中途变化:401 时低频再试几次,避免「登录后分区永久消失」。 */
|
|
14342
|
+
let authReloadAttempts = 0;
|
|
14343
|
+
const MAX_AUTH_RELOAD_ATTEMPTS = 3;
|
|
14344
|
+
const AUTH_RELOAD_DELAY = 2e4;
|
|
14320
14345
|
/**
|
|
14321
14346
|
* 从宿主导入分区文档。
|
|
14322
14347
|
*
|
|
14323
|
-
*
|
|
14348
|
+
* 宿主返回 200 且内容为空(首次运行)时按默认结构启动:只有「置顶 + 项目」两个内置分区,
|
|
14324
14349
|
* 首次同步会把宿主现有工作区顺序采纳进「项目」,与以前的全新安装行为一致。
|
|
14350
|
+
* 若宿主未就绪抛出异常(503、网络错误等):不标记 sectionsLoaded,不触发 persist() 存盘,
|
|
14351
|
+
* 避免启动竞态下用空结构冲掉用户已有的真实分区,并在指数退避(最多 5 次)后安排恢复尝试。
|
|
14352
|
+
* 401 另走一条低频重试(最多 3 次、间隔 20s),覆盖「登录态在会话中途变化」的场景;
|
|
14353
|
+
* 403 / 404 这类不会自行恢复的客户端状态直接放弃,由页面重新挂载时再加载。
|
|
14325
14354
|
*/
|
|
14326
14355
|
async function loadStateFromHost() {
|
|
14327
14356
|
let raw = null;
|
|
14328
14357
|
try {
|
|
14329
14358
|
raw = await loadSectionsDocument();
|
|
14330
|
-
} catch {
|
|
14331
|
-
|
|
14359
|
+
} catch (error) {
|
|
14360
|
+
const status = error instanceof SectionsLoadError ? error.status : 0;
|
|
14361
|
+
if (status === 401) {
|
|
14362
|
+
if (!disposed && !sectionsLoaded) {
|
|
14363
|
+
if (authReloadAttempts < MAX_AUTH_RELOAD_ATTEMPTS) {
|
|
14364
|
+
authReloadAttempts++;
|
|
14365
|
+
window.setTimeout(() => {
|
|
14366
|
+
if (!disposed && !sectionsLoaded) loadStateFromHost();
|
|
14367
|
+
}, AUTH_RELOAD_DELAY);
|
|
14368
|
+
} else console.warn("[Codex UI] 工作区分区需要登录后才能加载,已停止自动重试。");
|
|
14369
|
+
}
|
|
14370
|
+
return;
|
|
14371
|
+
}
|
|
14372
|
+
if (status !== 0 && status < 500) return;
|
|
14373
|
+
if (!disposed && !sectionsLoaded) {
|
|
14374
|
+
hostReloadAttempts++;
|
|
14375
|
+
if (hostReloadAttempts <= MAX_HOST_RELOAD_ATTEMPTS) {
|
|
14376
|
+
const delay = Math.min(2e3 * Math.pow(2, hostReloadAttempts - 1), 3e4);
|
|
14377
|
+
window.setTimeout(() => {
|
|
14378
|
+
if (!disposed && !sectionsLoaded) loadStateFromHost();
|
|
14379
|
+
}, delay);
|
|
14380
|
+
} else console.warn("[Codex UI] 工作区分区宿主连接持续不可用,已停止后台恢复重试。");
|
|
14381
|
+
}
|
|
14382
|
+
return;
|
|
14332
14383
|
}
|
|
14384
|
+
hostReloadAttempts = 0;
|
|
14385
|
+
authReloadAttempts = 0;
|
|
14333
14386
|
state = normalizeSections(parseSections(raw) ?? { sections: [] });
|
|
14334
14387
|
committedState = state;
|
|
14335
14388
|
sectionsLoaded = true;
|
package/lib/composer-plugin.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { r as CODEX_UI_API_ENDPOINTS, t as isSubPluginDisabledOnDisk$1 } from "./profile-resolver-DSHfL3KW.mjs";
|
|
2
|
+
import { t as captureScopedConnection } from "./host-services-k-J3TuxA.mjs";
|
|
2
3
|
//#region src/composer-prediction-format.ts
|
|
3
4
|
const PREDICTION_CUES = {
|
|
4
5
|
next: "Predict the user's next message.",
|
|
@@ -83,6 +84,24 @@ function apply$1(ctx, config) {
|
|
|
83
84
|
const options = resolveOptions(config);
|
|
84
85
|
const cache = /* @__PURE__ */ new Map();
|
|
85
86
|
const inflight = /* @__PURE__ */ new Set();
|
|
87
|
+
let injectedSessions;
|
|
88
|
+
if (typeof ctx.inject === "function") try {
|
|
89
|
+
ctx.inject(["sessions"], (sessCtx) => {
|
|
90
|
+
injectedSessions = sessCtx.sessions ?? (typeof sessCtx.get === "function" ? sessCtx.get("sessions") : void 0);
|
|
91
|
+
if (typeof sessCtx.on === "function") sessCtx.on("dispose", () => {
|
|
92
|
+
injectedSessions = void 0;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
} catch {}
|
|
96
|
+
const scopedConnection = captureScopedConnection(ctx);
|
|
97
|
+
const servicesFallback = {
|
|
98
|
+
get sessions() {
|
|
99
|
+
return injectedSessions;
|
|
100
|
+
},
|
|
101
|
+
get connection() {
|
|
102
|
+
return scopedConnection();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
86
105
|
const getWebServer = () => ctx.webServer ?? ctx.get?.("webServer");
|
|
87
106
|
ctx.effect(() => () => {
|
|
88
107
|
for (const controller of inflight) controller.abort();
|
|
@@ -96,7 +115,7 @@ function apply$1(ctx, config) {
|
|
|
96
115
|
kind: "exact",
|
|
97
116
|
path: ENDPOINT,
|
|
98
117
|
auth: "anonymous",
|
|
99
|
-
handler: (request, response) => serveJson(ctx, options, cache, inflight, request, response)
|
|
118
|
+
handler: (request, response) => serveJson(ctx, options, cache, inflight, request, response, servicesFallback)
|
|
100
119
|
});
|
|
101
120
|
});
|
|
102
121
|
ctx.effect(() => {
|
|
@@ -106,7 +125,7 @@ function apply$1(ctx, config) {
|
|
|
106
125
|
kind: "exact",
|
|
107
126
|
path: STREAM_ENDPOINT,
|
|
108
127
|
auth: "anonymous",
|
|
109
|
-
handler: (request, response) => serveStream(ctx, options, cache, inflight, request, response)
|
|
128
|
+
handler: (request, response) => serveStream(ctx, options, cache, inflight, request, response, servicesFallback)
|
|
110
129
|
});
|
|
111
130
|
});
|
|
112
131
|
}
|
|
@@ -133,9 +152,9 @@ function resolveOptions(config) {
|
|
|
133
152
|
function textOption(value, maximum) {
|
|
134
153
|
return typeof value === "string" && value.length <= maximum ? value.trim() : "";
|
|
135
154
|
}
|
|
136
|
-
async function serveJson(ctx, options, cache, inflight, request, response) {
|
|
155
|
+
async function serveJson(ctx, options, cache, inflight, request, response, servicesFallback) {
|
|
137
156
|
try {
|
|
138
|
-
const plan = await planRequest(ctx, request, response);
|
|
157
|
+
const plan = await planRequest(ctx, request, response, servicesFallback);
|
|
139
158
|
if (plan === null) return;
|
|
140
159
|
if (plan.error !== void 0) {
|
|
141
160
|
respond(response, plan.status, {
|
|
@@ -165,16 +184,18 @@ async function serveJson(ctx, options, cache, inflight, request, response) {
|
|
|
165
184
|
});
|
|
166
185
|
}
|
|
167
186
|
} catch (error) {
|
|
168
|
-
|
|
187
|
+
const reason = describeError(error);
|
|
188
|
+
ctx.logger?.warn?.("[Codex UI] 预测处理异常:%s", reason);
|
|
189
|
+
respond(response, 200, {
|
|
169
190
|
suggestion: null,
|
|
170
191
|
suggestions: [],
|
|
171
|
-
reason
|
|
192
|
+
reason
|
|
172
193
|
});
|
|
173
194
|
}
|
|
174
195
|
}
|
|
175
|
-
async function serveStream(ctx, options, cache, inflight, request, response) {
|
|
196
|
+
async function serveStream(ctx, options, cache, inflight, request, response, servicesFallback) {
|
|
176
197
|
try {
|
|
177
|
-
const plan = await planRequest(ctx, request, response);
|
|
198
|
+
const plan = await planRequest(ctx, request, response, servicesFallback);
|
|
178
199
|
if (plan === null) return;
|
|
179
200
|
if (plan.error !== void 0) {
|
|
180
201
|
respond(response, plan.status, {
|
|
@@ -217,24 +238,31 @@ async function serveStream(ctx, options, cache, inflight, request, response) {
|
|
|
217
238
|
closeStream(response);
|
|
218
239
|
}
|
|
219
240
|
} catch (error) {
|
|
241
|
+
const reason = describeError(error);
|
|
242
|
+
ctx.logger?.warn?.("[Codex UI] 预测流处理异常:%s", reason);
|
|
220
243
|
if (response.headersSent === true) closeStream(response);
|
|
221
|
-
else respond(response,
|
|
244
|
+
else respond(response, 200, {
|
|
222
245
|
suggestion: null,
|
|
223
246
|
suggestions: [],
|
|
224
|
-
reason
|
|
247
|
+
reason
|
|
225
248
|
});
|
|
226
249
|
}
|
|
227
250
|
}
|
|
228
|
-
function getService(ctx, name) {
|
|
251
|
+
function getService(ctx, name, fallback) {
|
|
229
252
|
try {
|
|
230
253
|
if (typeof ctx?.get === "function") {
|
|
231
254
|
const svc = ctx.get(name);
|
|
232
255
|
if (svc !== void 0) return svc;
|
|
233
256
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
} catch {}
|
|
258
|
+
try {
|
|
259
|
+
const reflectSvc = ctx?.reflect?.get?.(name, false);
|
|
260
|
+
if (reflectSvc !== void 0) return reflectSvc;
|
|
261
|
+
} catch {}
|
|
262
|
+
try {
|
|
263
|
+
if (ctx?.[name] !== void 0) return ctx[name];
|
|
264
|
+
} catch {}
|
|
265
|
+
return fallback;
|
|
238
266
|
}
|
|
239
267
|
/** Short, safe reason text for a client that only displays nothing. */
|
|
240
268
|
function describeError(error) {
|
|
@@ -245,14 +273,28 @@ function describeError(error) {
|
|
|
245
273
|
* Read and validate one request body, resolving the live Session it names.
|
|
246
274
|
* @returns `null` when the response was already written, a plan, or an error.
|
|
247
275
|
*/
|
|
248
|
-
async function planRequest(ctx, request, response) {
|
|
249
|
-
const connection = getService(ctx, "connection");
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
276
|
+
async function planRequest(ctx, request, response, servicesFallback) {
|
|
277
|
+
const connection = servicesFallback?.connection ?? getService(ctx, "connection");
|
|
278
|
+
let admission;
|
|
279
|
+
try {
|
|
280
|
+
admission = connection?.admit?.(request);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
ctx.logger?.warn?.("[Codex UI] 预测请求认证异常:%s", describeError(error));
|
|
283
|
+
return {
|
|
284
|
+
status: 503,
|
|
285
|
+
error: "authentication-unavailable"
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (!admission || admission.rejection === 503) return {
|
|
289
|
+
status: 503,
|
|
290
|
+
error: "authentication-unavailable"
|
|
291
|
+
};
|
|
292
|
+
if (admission.rejection === 401) return {
|
|
293
|
+
status: 401,
|
|
294
|
+
error: "unauthorized"
|
|
254
295
|
};
|
|
255
|
-
|
|
296
|
+
const peer = admission.peer;
|
|
297
|
+
if (admission.rejection !== void 0 || peer?.principal?.kind !== "owner") return {
|
|
256
298
|
status: 403,
|
|
257
299
|
error: "forbidden"
|
|
258
300
|
};
|
|
@@ -290,11 +332,14 @@ async function planRequest(ctx, request, response) {
|
|
|
290
332
|
status: 400,
|
|
291
333
|
error: "missing-session"
|
|
292
334
|
};
|
|
293
|
-
const sessions = getService(ctx, "sessions");
|
|
294
|
-
if (!sessions || typeof sessions.get !== "function")
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
335
|
+
const sessions = getService(ctx, "sessions", servicesFallback?.sessions);
|
|
336
|
+
if (!sessions || typeof sessions.get !== "function") {
|
|
337
|
+
ctx.logger?.warn?.("[Codex UI] 预测请求跳过:未找到有效的 sessions 服务。");
|
|
338
|
+
return {
|
|
339
|
+
status: 200,
|
|
340
|
+
error: "no-sessions-service"
|
|
341
|
+
};
|
|
342
|
+
}
|
|
298
343
|
const session = sessions.get(sessionId);
|
|
299
344
|
if (session === void 0) return {
|
|
300
345
|
status: 200,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/host-services.ts
|
|
2
|
+
/** 新宿主的 admit 会访问关联认证服务;仅此子作用域依赖它,旧宿主不受启动门控。 */
|
|
3
|
+
function captureScopedConnection(ctx) {
|
|
4
|
+
let connection;
|
|
5
|
+
ctx.inject?.(["connection", "connection.authentication"], (authCtx) => {
|
|
6
|
+
authCtx.effect(() => {
|
|
7
|
+
connection = authCtx.get("connection");
|
|
8
|
+
return () => {
|
|
9
|
+
connection = void 0;
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
return () => connection;
|
|
14
|
+
}
|
|
15
|
+
function requireService(ctx, key, method) {
|
|
16
|
+
const service = ctx.get(key);
|
|
17
|
+
if (service === null || typeof service !== "object" || typeof service[method] !== "function") throw new Error(`michengai-codex-ui 需要宿主服务 “${key}.${String(method)}”`);
|
|
18
|
+
return service;
|
|
19
|
+
}
|
|
20
|
+
/** 在唯一的宿主边界校验服务能力;宿主 API 变更时立即失败,不会静默返回 503。 */
|
|
21
|
+
function hostServices(ctx) {
|
|
22
|
+
return { webServer: requireService(ctx, "webServer", "register") };
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { hostServices as n, captureScopedConnection as t };
|
package/lib/index.d.mts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
//#region src/host-services.d.ts
|
|
3
|
+
type HttpRequest = {
|
|
4
|
+
method?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
/** Node 原生请求头(小写键名),用于跨站请求判定。 */
|
|
7
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
8
|
+
[Symbol.asyncIterator]?: () => AsyncIterator<Uint8Array | string>;
|
|
9
|
+
};
|
|
10
|
+
type ConnectionServiceLike = {
|
|
11
|
+
requestRejection?: (request: {
|
|
12
|
+
headers?: HttpRequest['headers'];
|
|
13
|
+
}) => 401 | 403 | undefined;
|
|
14
|
+
admit?: (request: {
|
|
15
|
+
headers?: HttpRequest['headers'];
|
|
16
|
+
}) => {
|
|
17
|
+
rejection?: 401 | 403 | 503;
|
|
18
|
+
peer?: unknown;
|
|
19
|
+
} | undefined;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
2
22
|
//#region src/index.d.ts
|
|
3
23
|
/**
|
|
4
24
|
* composer 子插件被停用时,由主插件补一个只读状态兜底端点。
|
|
@@ -22,8 +42,28 @@ declare function publicDependencyError(error: unknown): string;
|
|
|
22
42
|
declare class RequestBodyTooLargeError extends Error {}
|
|
23
43
|
/** 有界读取 Node HTTP body;偏好接口只接受很小的 JSON。 */
|
|
24
44
|
declare function readRequestBody(request: HostRequest, maxBytes?: number): Promise<string>;
|
|
45
|
+
type HostResponse = {
|
|
46
|
+
writeHead(status: number, headers?: Record<string, string>): void;
|
|
47
|
+
end(body?: string): void;
|
|
48
|
+
};
|
|
49
|
+
type AuthenticationStatus = 401 | 403 | 503;
|
|
50
|
+
type AuthenticationErrorBody = (status: AuthenticationStatus, message: string) => Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* 解析可用于校验业务请求的连接服务。
|
|
53
|
+
*
|
|
54
|
+
* @internal 仅供用例直接验收宿主契约,不属于本包的公开 API。
|
|
55
|
+
*/
|
|
56
|
+
declare function resolveConnectionService(ctx: Context, injectedConn?: ConnectionServiceLike): ConnectionServiceLike | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 所有业务 REST 依赖 connection >=0.1.2-rc.1 的 Host/Origin/Fetch Metadata 与登录检查。
|
|
59
|
+
* 必须在读取请求体及执行副作用前调用;不得将 undefined 以外的拒绝结果当作放行。
|
|
60
|
+
* 发布包信任边界由 tests/business-rest-auth.assert.ts 的真实宿主契约用例验证。
|
|
61
|
+
*
|
|
62
|
+
* @internal 仅供用例直接验收宿主契约,不属于本包的公开 API。
|
|
63
|
+
*/
|
|
64
|
+
declare function authenticateBusinessRequest(ctx: Context, request: HostRequest, response: HostResponse, errorBody?: AuthenticationErrorBody, peer?: unknown, localConnection?: ConnectionServiceLike): boolean;
|
|
25
65
|
declare const inject: string[];
|
|
26
66
|
/** 提供不泄露地址、命令和凭证的连接器目录。 */
|
|
27
67
|
declare function apply(ctx: Context): void;
|
|
28
68
|
//#endregion
|
|
29
|
-
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback };
|
|
69
|
+
export { type ConnectionServiceLike, RequestBodyTooLargeError, apply, authenticateBusinessRequest, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback, resolveConnectionService };
|
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as resolveCurrentProfile, r as CODEX_UI_API_ENDPOINTS, t as isSubPluginDisabledOnDisk } from "./profile-resolver-DSHfL3KW.mjs";
|
|
2
|
+
import { n as hostServices, t as captureScopedConnection } from "./host-services-k-J3TuxA.mjs";
|
|
2
3
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { readFile } from "node:fs/promises";
|
|
4
5
|
import { homedir } from "node:os";
|
|
@@ -544,17 +545,6 @@ async function installDependenciesLocked(ids, runtime) {
|
|
|
544
545
|
}
|
|
545
546
|
}
|
|
546
547
|
//#endregion
|
|
547
|
-
//#region src/host-services.ts
|
|
548
|
-
function requireService(ctx, key, method) {
|
|
549
|
-
const service = ctx.get(key);
|
|
550
|
-
if (service === null || typeof service !== "object" || typeof service[method] !== "function") throw new Error(`michengai-codex-ui 需要宿主服务 “${key}.${String(method)}”`);
|
|
551
|
-
return service;
|
|
552
|
-
}
|
|
553
|
-
/** 在唯一的宿主边界校验服务能力;宿主 API 变更时立即失败,不会静默返回 503。 */
|
|
554
|
-
function hostServices(ctx) {
|
|
555
|
-
return { webServer: requireService(ctx, "webServer", "register") };
|
|
556
|
-
}
|
|
557
|
-
//#endregion
|
|
558
548
|
//#region src/sections-store.ts
|
|
559
549
|
/**
|
|
560
550
|
* 工作区分区的宿主侧存储。
|
|
@@ -723,11 +713,23 @@ async function readRequestBody(request, maxBytes = 32768) {
|
|
|
723
713
|
return Buffer.concat(chunks).toString("utf8");
|
|
724
714
|
}
|
|
725
715
|
/**
|
|
716
|
+
* 解析可用于校验业务请求的连接服务。
|
|
717
|
+
*
|
|
718
|
+
* @internal 仅供用例直接验收宿主契约,不属于本包的公开 API。
|
|
719
|
+
*/
|
|
720
|
+
function resolveConnectionService(ctx, injectedConn) {
|
|
721
|
+
if (injectedConn && (typeof injectedConn.admit === "function" || typeof injectedConn.requestRejection === "function")) return injectedConn;
|
|
722
|
+
const connection = ctx.get?.("connection");
|
|
723
|
+
if (connection && (typeof connection.admit === "function" || typeof connection.requestRejection === "function")) return connection;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
726
|
* 所有业务 REST 依赖 connection >=0.1.2-rc.1 的 Host/Origin/Fetch Metadata 与登录检查。
|
|
727
727
|
* 必须在读取请求体及执行副作用前调用;不得将 undefined 以外的拒绝结果当作放行。
|
|
728
728
|
* 发布包信任边界由 tests/business-rest-auth.assert.ts 的真实宿主契约用例验证。
|
|
729
|
+
*
|
|
730
|
+
* @internal 仅供用例直接验收宿主契约,不属于本包的公开 API。
|
|
729
731
|
*/
|
|
730
|
-
function authenticateBusinessRequest(ctx, request, response, errorBody = (_status, message) => ({ error: message }), peer) {
|
|
732
|
+
function authenticateBusinessRequest(ctx, request, response, errorBody = (_status, message) => ({ error: message }), peer, localConnection) {
|
|
731
733
|
if (peer) return true;
|
|
732
734
|
const reject = (status, message) => {
|
|
733
735
|
response.writeHead(status, {
|
|
@@ -738,7 +740,7 @@ function authenticateBusinessRequest(ctx, request, response, errorBody = (_statu
|
|
|
738
740
|
return false;
|
|
739
741
|
};
|
|
740
742
|
try {
|
|
741
|
-
const connection = ctx
|
|
743
|
+
const connection = resolveConnectionService(ctx, localConnection);
|
|
742
744
|
if (!connection || typeof connection.requestRejection !== "function" && typeof connection.admit !== "function") {
|
|
743
745
|
ctx.logger.warn("Codex UI 业务 REST 认证不可用:缺少 connection 认证接口。");
|
|
744
746
|
return reject(503, "宿主认证服务暂不可用。");
|
|
@@ -747,13 +749,11 @@ function authenticateBusinessRequest(ctx, request, response, errorBody = (_statu
|
|
|
747
749
|
if (typeof connection.admit === "function") {
|
|
748
750
|
const admission = connection.admit(request);
|
|
749
751
|
if (admission && typeof admission === "object") {
|
|
750
|
-
if ("rejection" in admission)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
}
|
|
752
|
+
if ("rejection" in admission && admission.rejection !== void 0) rejection = admission.rejection;
|
|
753
|
+
else if (!("peer" in admission) || !admission.peer) rejection = 403;
|
|
754
|
+
} else rejection = 503;
|
|
755
755
|
} else if (typeof connection.requestRejection === "function") rejection = connection.requestRejection(request);
|
|
756
|
-
if (rejection !== void 0) return reject(rejection, rejection === 401 ? "请先登录 DSH。" : "已拒绝不可信或跨站请求。");
|
|
756
|
+
if (rejection !== void 0) return reject(rejection, rejection === 401 ? "请先登录 DSH。" : rejection === 503 ? "宿主认证服务暂不可用。" : "已拒绝不可信或跨站请求。");
|
|
757
757
|
return true;
|
|
758
758
|
} catch (error) {
|
|
759
759
|
const reason = error instanceof Error ? `${error.name}: ${error.message}` : typeof error;
|
|
@@ -768,6 +768,7 @@ const inject = [
|
|
|
768
768
|
];
|
|
769
769
|
/** 提供不泄露地址、命令和凭证的连接器目录。 */
|
|
770
770
|
function apply(ctx) {
|
|
771
|
+
const scopedConnection = captureScopedConnection(ctx);
|
|
771
772
|
const host = hostServices(ctx);
|
|
772
773
|
ctx.effect(() => {
|
|
773
774
|
if (typeof ctx.on !== "function") return () => {};
|
|
@@ -787,7 +788,7 @@ function apply(ctx) {
|
|
|
787
788
|
path: dependenciesEndpoint,
|
|
788
789
|
auth: "anonymous",
|
|
789
790
|
handler: async (request, response, peer) => {
|
|
790
|
-
if (!authenticateBusinessRequest(ctx, request, response, void 0, peer)) return;
|
|
791
|
+
if (!authenticateBusinessRequest(ctx, request, response, void 0, peer, scopedConnection())) return;
|
|
791
792
|
const url = new URL(request.url ?? "/", "http://localhost");
|
|
792
793
|
try {
|
|
793
794
|
if (request.method === "GET") {
|
|
@@ -866,7 +867,7 @@ function apply(ctx) {
|
|
|
866
867
|
path: CODEX_UI_API_ENDPOINTS.sections,
|
|
867
868
|
auth: "anonymous",
|
|
868
869
|
handler: async (request, response, peer) => {
|
|
869
|
-
if (!authenticateBusinessRequest(ctx, request, response, void 0, peer)) return;
|
|
870
|
+
if (!authenticateBusinessRequest(ctx, request, response, void 0, peer, scopedConnection())) return;
|
|
870
871
|
const json = (status, body) => {
|
|
871
872
|
response.writeHead(status, {
|
|
872
873
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -926,4 +927,4 @@ function apply(ctx) {
|
|
|
926
927
|
}, "michengai-codex-ui: catalogs");
|
|
927
928
|
}
|
|
928
929
|
//#endregion
|
|
929
|
-
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback };
|
|
930
|
+
export { RequestBodyTooLargeError, apply, authenticateBusinessRequest, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback, resolveConnectionService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-codex-ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"description": "DSH Codex UI — 为 DeepSeek Harness 提供极速历史召回、全屏设置皮肤、原生物理毛玻璃换肤、模块化侧栏与桌面原生窗口菜单 · Input enhancement, settings skin, native glass theme, modular sidebar, and desktop titlebar menu for DSH",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|