@yezack/dsh-remote-mobile 1.10.0 → 1.10.2

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.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * DSH 目录选择器(Directory Picker)配置检测与幂等补丁管理模块
3
+ *
4
+ * 【背景与问题】
5
+ * DSH 官方默认的 `id: directory-picker`(`@deepseek-ai/dsh-host-directory-picker-auto`)
6
+ * 仅在进程启动时根据 `webServer.host` 是否为 127.0.0.1 回环地址来判断“本机 / 远程”:
7
+ * - 本插件默认采用安全接入代理模式(DSH 核心保持 127.0.0.1:3080 回环,由 3081 代理对外);
8
+ * - `auto` 因此将所有来自手机端 3081 的请求误判为“本机桌面操作”,直接调用 PC 的系统原生文件选择窗(native);
9
+ * - 最终导致弹窗出现在 PC 屏幕上,手机浏览器一直转圈等待,无法在手机端选择文件夹或添加工作区。
10
+ *
11
+ * 【解决方案】
12
+ * 1. 运行时检测:结合 Cordis loader 激活树与 `~/.dsh/profiles/web/cordis.patch.yml` 配置文件,
13
+ * 精准判断当前是否已启用网页内目录选择器(`browse` 模式);
14
+ * 2. 幂等补丁写入:支持在设置页一键开启/恢复,写入时对 `directory-picker`、`directory-picker-browse`、
15
+ * `ui-directory-picker-browse` 三项分别执行严格结构化去重,绝不产生重复条目,且完整保留用户其它配置。
16
+ */
17
+ export declare const AUTO_DIRECTORY_PICKER_ID = "directory-picker";
18
+ export declare const AUTO_DIRECTORY_PICKER_PKG = "@deepseek-ai/dsh-host-directory-picker-auto";
19
+ export declare const HOST_DIRECTORY_PICKER_BROWSE_ID = "directory-picker-browse";
20
+ export declare const HOST_DIRECTORY_PICKER_BROWSE_PKG = "@deepseek-ai/dsh-host-directory-picker-browse";
21
+ export declare const UI_DIRECTORY_PICKER_BROWSE_ID = "ui-directory-picker-browse";
22
+ export declare const UI_DIRECTORY_PICKER_BROWSE_PKG = "@deepseek-ai/dsh-client-ui-directory-picker-browse";
23
+ /** 标准可复制/可注入的 YAML 配置片段 */
24
+ export declare const DIRECTORY_PICKER_YAML_SNIPPET: string;
25
+ export interface DirectoryPickerPatchInspection {
26
+ /** `- id: directory-picker` 是否已设置 `disabled: true` */
27
+ autoDisabled: boolean;
28
+ /** 是否存在 `- id: directory-picker` 条目 */
29
+ hasAutoEntry: boolean;
30
+ /** `@deepseek-ai/dsh-host-directory-picker-browse` 是否已插入且未禁用 */
31
+ hostBrowseInserted: boolean;
32
+ /** `@deepseek-ai/dsh-client-ui-directory-picker-browse` 是否已插入且未禁用 */
33
+ uiBrowseInserted: boolean;
34
+ /** 三项配置是否已在 patch 文件中全部就绪 */
35
+ configured: boolean;
36
+ /** 是否仅配置了其中一部分(缺失其余项) */
37
+ partial: boolean;
38
+ }
39
+ export interface DirectoryPickerRuntimeInspection {
40
+ /** 是否能够从 Cordis loader 探测到目录选择器相关条目 */
41
+ detected: boolean;
42
+ /** 运行时中 `browse` 目录选择器(前后端)是否已激活生效 */
43
+ browseActive: boolean;
44
+ /** 运行时中 `auto` 目录选择器是否仍处于启用状态 */
45
+ autoActive: boolean;
46
+ }
47
+ export interface DirectoryPickerStatus {
48
+ /** 配置文件中是否已完整开启 browse 补丁 */
49
+ patchEnabled: boolean;
50
+ /** 配置文件中是否仅开启了部分项 */
51
+ patchPartial: boolean;
52
+ /** 当前运行时中网页目录选择器是否已生效 */
53
+ runtimeActive: boolean;
54
+ /** 配置已变更但当前进程尚未生效(需要重启 DSH 或等待 HMR 重载) */
55
+ restartRequired: boolean;
56
+ /** 当前是否需要向用户展示醒目提醒(回环核心且未开启 browse 时为 true) */
57
+ needsWarning: boolean;
58
+ /** 目标 cordis.patch.yml 的绝对路径 */
59
+ patchFilePath: string;
60
+ /** 标准可复制的 YAML 配置片段 */
61
+ yamlSnippet: string;
62
+ }
63
+ /**
64
+ * 绑定 Cordis 运行时上下文与回环核心判定函数(供 /status 路由实时查询)
65
+ */
66
+ export declare function bindDirectoryPickerRuntime(ctx: any, isLoopbackCore?: () => boolean): void;
67
+ /**
68
+ * 定位当前 DSH 的 web profile `cordis.patch.yml` 路径
69
+ *
70
+ * 优先使用 `~/.dsh/profiles/web/cordis.patch.yml`;若存在其他单 profile 则按优先级兜底。
71
+ */
72
+ export declare function resolveDirectoryPickerPatchPath(customPath?: string): string;
73
+ /**
74
+ * 解析 `cordis.patch.yml` 文本内容,检查目录选择器相关配置状态
75
+ */
76
+ export declare function inspectDirectoryPickerPatchContent(content: string): DirectoryPickerPatchInspection;
77
+ /**
78
+ * 检查 Cordis 运行时 loader 中的目录选择器插件激活状态
79
+ */
80
+ export declare function inspectRuntimeDirectoryPicker(ctx?: any): DirectoryPickerRuntimeInspection;
81
+ /**
82
+ * 幂等合并网页目录选择器配置到 `cordis.patch.yml` 内容中(严格去重)
83
+ *
84
+ * 去重规则:
85
+ * 1. 若已存在一个或多个 `- id: directory-picker`:就地将其设为 `disabled: true`,合并重复项;
86
+ * 2. 若已存在 `directory-picker-browse` 或 `ui-directory-picker-browse`(无论在哪个 `insert` 块下):
87
+ * 不重复插入,仅补充缺失的那一项(若原项被设为 `disabled: true` 则移除禁用标记);
88
+ * 3. 若三项均已就绪,原样返回,`changed: false`。
89
+ */
90
+ export declare function applyDirectoryPickerBrowsePatch(rawContent: string): {
91
+ content: string;
92
+ changed: boolean;
93
+ };
94
+ /**
95
+ * 从 `cordis.patch.yml` 内容中安全移除网页目录选择器补丁(恢复 PC 原生目录选择器)
96
+ *
97
+ * 仅移除与 directory-picker 相关的禁用项与两个 browse 插入项,100% 保留用户其他配置。
98
+ */
99
+ export declare function removeDirectoryPickerBrowsePatch(rawContent: string): {
100
+ content: string;
101
+ changed: boolean;
102
+ };
103
+ /**
104
+ * 获取目录选择器当前综合状态(供 `/api/remote-mobile/status` 与设置页消费)
105
+ */
106
+ export declare function getDirectoryPickerStatus(customPatchPath?: string): DirectoryPickerStatus;
107
+ /**
108
+ * 在目标 `cordis.patch.yml` 中一键开启网页目录选择器(幂等去重)
109
+ */
110
+ export declare function enableDirectoryPickerBrowse(customPatchPath?: string): DirectoryPickerStatus & {
111
+ changed: boolean;
112
+ };
113
+ /**
114
+ * 从目标 `cordis.patch.yml` 中移除网页目录选择器配置(恢复 PC 原生目录选择器)
115
+ */
116
+ export declare function disableDirectoryPickerBrowse(customPatchPath?: string): DirectoryPickerStatus & {
117
+ changed: boolean;
118
+ };