dsh-projects-panel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -0
- package/cordis.patch.yml +4 -0
- package/lib/client.d.ts +462 -0
- package/lib/client.js +7288 -0
- package/lib/index.d.ts +464 -0
- package/lib/index.js +1025 -0
- package/package.json +77 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
+
|
|
5
|
+
//#region src/core/types.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 领域模型与持久化结构的纯类型定义。
|
|
9
|
+
*
|
|
10
|
+
* 本文件只允许类型声明与接口注释,禁止任何运行时代码
|
|
11
|
+
* (运行时工具函数见 ./workspace.ts)。
|
|
12
|
+
*/
|
|
13
|
+
/** 官方 settingsScope bind 接口最小投影(客户端读写 settings.yaml)。 */
|
|
14
|
+
interface SettingsScopeBind {
|
|
15
|
+
get(): unknown;
|
|
16
|
+
update(patch: Record<string, unknown>): void;
|
|
17
|
+
}
|
|
18
|
+
/** 工作区成员关系:记录工作区加入项目的时间。 */
|
|
19
|
+
interface WorkspaceMembership {
|
|
20
|
+
joinedAt: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 项目树中的一个项目节点。
|
|
24
|
+
*
|
|
25
|
+
* 节点既可持有直接子项目(projects),也可持有归属的工作区(workspaces);
|
|
26
|
+
* 归档的工作区 id 记录在 archivedProjectIds,但保留在 workspaces 中不再展开。
|
|
27
|
+
*/
|
|
28
|
+
interface ProjectNode {
|
|
29
|
+
/** 项目名:磁盘目录名,满足 validateProjectName 的约束。 */
|
|
30
|
+
name: string;
|
|
31
|
+
/** 可选的宿主工作区绝对路径链接。 */
|
|
32
|
+
link?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
projectIds: string[];
|
|
37
|
+
workspaceIds: string[];
|
|
38
|
+
archivedProjectIds: string[];
|
|
39
|
+
projects: Record<string, ProjectNode>;
|
|
40
|
+
workspaces: Record<string, WorkspaceMembership>;
|
|
41
|
+
}
|
|
42
|
+
/** projects.json 的持久化结构:根持有顶层项目与归档项目。 */
|
|
43
|
+
interface ProjectTree {
|
|
44
|
+
unit: {
|
|
45
|
+
name: 'project';
|
|
46
|
+
version: 1;
|
|
47
|
+
};
|
|
48
|
+
global: {
|
|
49
|
+
initialized: boolean;
|
|
50
|
+
};
|
|
51
|
+
projectIds: string[];
|
|
52
|
+
archivedProjectIds: string[];
|
|
53
|
+
projects: Record<string, ProjectNode>;
|
|
54
|
+
}
|
|
55
|
+
/** 工作区视图:由宿主注入的扁平工作区列表条目。 */
|
|
56
|
+
interface WorkspaceView {
|
|
57
|
+
/** 官方工作区标识(view id);跨域稳定键取 workspaceId ?? id。 */
|
|
58
|
+
id?: string;
|
|
59
|
+
workspaceId?: string;
|
|
60
|
+
path: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
createdAt?: number | string;
|
|
64
|
+
updatedAt?: number | string;
|
|
65
|
+
sessionIds?: readonly string[];
|
|
66
|
+
}
|
|
67
|
+
/** 会话级待用户应答交互的类型(官方 ui-approval / ui-user-questions 注册的 kind 收敛)。 */
|
|
68
|
+
type SessionPendingKind = 'approval' | 'plan-review' | 'question';
|
|
69
|
+
/** 会话视图:用于在树中按工作区聚合会话。 */
|
|
70
|
+
interface SessionView {
|
|
71
|
+
id: string;
|
|
72
|
+
workspaceId?: string;
|
|
73
|
+
title?: string;
|
|
74
|
+
updatedAt?: number;
|
|
75
|
+
/** 是否正在运行(宿主会话摘要的 running)。 */
|
|
76
|
+
running?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 空会话:仅在当前会话为空白时展示(tree.ts 的可见性规则)。
|
|
79
|
+
* RPC 快照只在面板动作后重拉,故客户端实时列表会把该位只降不升地覆盖
|
|
80
|
+
* (见 client/session-facts.ts),避免真实会话停留在创建时的 true。
|
|
81
|
+
*/
|
|
82
|
+
blank?: boolean;
|
|
83
|
+
/** 子代理会话:不参与树展示。 */
|
|
84
|
+
subagent?: boolean;
|
|
85
|
+
archived?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 客户端实时覆盖(由官方 sessions.list / uiSession 快照合并而来,
|
|
88
|
+
* 后端 /tree RPC 不产生这些字段):本次运行结束且未打开的完成提醒。
|
|
89
|
+
*/
|
|
90
|
+
completed?: boolean;
|
|
91
|
+
/** 客户端实时覆盖:运行中的子代理后代数量(沿父链累加)。 */
|
|
92
|
+
runningSubagentCount?: number;
|
|
93
|
+
/** 客户端实时覆盖:会话级 UI 待用户应答交互。 */
|
|
94
|
+
pendingInteraction?: SessionPendingKind;
|
|
95
|
+
/** 客户端实时覆盖:当前列表投影含活动定时任务记录。 */
|
|
96
|
+
hasActiveSchedule?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/** 插件设置:settings.json 的持久化结构。 */
|
|
99
|
+
interface ProjectsSettings {
|
|
100
|
+
wordmark?: {
|
|
101
|
+
markText?: string;
|
|
102
|
+
name?: string;
|
|
103
|
+
markImageUrl?: string;
|
|
104
|
+
brandPrimary?: string;
|
|
105
|
+
};
|
|
106
|
+
previewUrl?: string;
|
|
107
|
+
defaultProject?: string | null;
|
|
108
|
+
tree?: {
|
|
109
|
+
expandCurrent?: boolean;
|
|
110
|
+
filter?: FilterSelection | null;
|
|
111
|
+
};
|
|
112
|
+
version: 1;
|
|
113
|
+
}
|
|
114
|
+
/** 树顶层的筛选口径:全部 / 单个项目 / 单个工作区。 */
|
|
115
|
+
type FilterSelection = {
|
|
116
|
+
kind: 'all';
|
|
117
|
+
} | {
|
|
118
|
+
kind: 'project';
|
|
119
|
+
id: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: 'workspace';
|
|
122
|
+
id: string;
|
|
123
|
+
};
|
|
124
|
+
/** 目录浏览的一行(官方 host.listDirectory 投影):只承载展示字段。 */
|
|
125
|
+
interface DirectoryEntryLike {
|
|
126
|
+
name: string;
|
|
127
|
+
path: string;
|
|
128
|
+
hidden: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** 目录浏览结果(官方 host.listDirectory 响应投影)。 */
|
|
131
|
+
interface DirectoryListingLike {
|
|
132
|
+
path: string;
|
|
133
|
+
home: string;
|
|
134
|
+
crumbs: readonly DirectoryEntryLike[];
|
|
135
|
+
entries: readonly DirectoryEntryLike[];
|
|
136
|
+
truncated: boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 工作区/会话的官方客户端动作集(渲染层注入,纯接口)。
|
|
140
|
+
*
|
|
141
|
+
* 方法语义与官方 IWorkspaces/ISessions 一致;实现绑定在插件入口
|
|
142
|
+
* (client/index.tsx),由宿主注册的官方运行时提供。目录浏览能力
|
|
143
|
+
* 缺失(browse 能力未启用)时 listDirectory/createDirectory 为
|
|
144
|
+
* undefined,界面降级为手工输入路径。
|
|
145
|
+
*/
|
|
146
|
+
interface BrowserActions {
|
|
147
|
+
/** 打开(并选中)会话。 */
|
|
148
|
+
openSession(sessionId: string): void;
|
|
149
|
+
/** 在指定工作区(或默认目标)新建/复用空白会话并打开。 */
|
|
150
|
+
startSession(workspaceId?: string): Promise<void>;
|
|
151
|
+
/** 幂等创建或解析已存在目录的工作区;返回官方 workspaceId。 */
|
|
152
|
+
createWorkspace(path: string): Promise<string>;
|
|
153
|
+
/** 重命名工作区(官方持久化标题)。 */
|
|
154
|
+
renameWorkspace(workspaceId: string, title: string): Promise<void>;
|
|
155
|
+
/** 删除工作区注册(目录与会话日志保留)。 */
|
|
156
|
+
deleteWorkspace(workspaceId: string): Promise<void>;
|
|
157
|
+
/** 重命名会话(官方持久化标题)。 */
|
|
158
|
+
renameSession(sessionId: string, title: string): Promise<void>;
|
|
159
|
+
/** 分叉会话并在完成后打开子会话。 */
|
|
160
|
+
forkSession(sessionId: string): Promise<void>;
|
|
161
|
+
/** 归档会话(registry 全局归档集)。 */
|
|
162
|
+
archiveSession(sessionId: string): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* 官方工作区排序(顶层悬浮工作区与按工作区分组模式专用)。
|
|
165
|
+
*
|
|
166
|
+
* 语义与官方 insertBefore 一致:省略锚点追加末尾;缺失时界面降级为不可排序。
|
|
167
|
+
*/
|
|
168
|
+
insertWorkspaceBefore?(workspaceId: string, beforeId?: string): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* 官方会话排序(同工作区内专用,不写插件树)。
|
|
171
|
+
*
|
|
172
|
+
* 语义与官方 insertSessionBefore 一致;缺失时界面降级为不可排序。
|
|
173
|
+
*/
|
|
174
|
+
insertSessionBefore?(workspaceId: string, sessionId: string, beforeId?: string): Promise<void>;
|
|
175
|
+
/** 应用内目录浏览能力(可选)。 */
|
|
176
|
+
listDirectory?(path?: string, signal?: AbortSignal): Promise<DirectoryListingLike>;
|
|
177
|
+
/** 应用内新建目录能力(可选)。 */
|
|
178
|
+
createDirectory?(path: string, name: string): Promise<string>;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/core/workspace.d.ts
|
|
182
|
+
/**
|
|
183
|
+
* 解析工作区的稳定标识。
|
|
184
|
+
*
|
|
185
|
+
* 宿主注入的 WorkspaceView 可能带显式 workspaceId;没有时退化为 view 自身的 id。
|
|
186
|
+
* 树推导、筛选与展开状态都以该返回值作为统一键。
|
|
187
|
+
*/
|
|
188
|
+
declare function workspaceIdOf(workspace: WorkspaceView): string;
|
|
189
|
+
/**
|
|
190
|
+
* 把主目录下路径缩写为 `~` 形式(hover 卡展示用,与官方
|
|
191
|
+
* abbreviateHomePath 语义一致):home 缺省/空、非 POSIX 路径、
|
|
192
|
+
* home 为根或不在该 home 下时原样返回。
|
|
193
|
+
* @param path 绝对路径。
|
|
194
|
+
* @param home 宿主主目录;缺省或空表示无法缩写。
|
|
195
|
+
* @returns 缩写后的展示路径。
|
|
196
|
+
*/
|
|
197
|
+
declare function abbreviateHomePath(path: string, home?: string): string;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/host-tree.d.ts
|
|
200
|
+
/** 项目目录集合的磁盘路径:数据根下 projects/ 子目录(不创建)。 */
|
|
201
|
+
declare function projectStoreRoot(root: string): string;
|
|
202
|
+
/** 新建一棵空的项目树:unit 标记沿用 Cordis 数据文件约定。 */
|
|
203
|
+
declare const emptyTree: () => ProjectTree;
|
|
204
|
+
/**
|
|
205
|
+
* 校验项目名。
|
|
206
|
+
*
|
|
207
|
+
* 项目名仅做展示用(目录名 = 项目 ID),因此放宽为:非空、不含路径
|
|
208
|
+
* 分隔符(/ \)、不含控制字符、长度不超过 255。
|
|
209
|
+
*/
|
|
210
|
+
declare function validateProjectName(name: string): void;
|
|
211
|
+
/**
|
|
212
|
+
* 校验整棵项目树的根结构:顶层 id 不得重复、必须可解析,
|
|
213
|
+
* 且活动与归档两个集合不允许出现同一项目。
|
|
214
|
+
*/
|
|
215
|
+
declare function validateProjectTree(tree: unknown): asserts tree is ProjectTree;
|
|
216
|
+
/**
|
|
217
|
+
* 以「临时文件 + fsync + rename」方式原子写入 JSON。
|
|
218
|
+
*
|
|
219
|
+
* rename 在同一文件系统内是原子的,避免读者读到写了一半的文件;
|
|
220
|
+
* 0o600 保证项目数据目录不被他人在磁盘上读取。
|
|
221
|
+
*/
|
|
222
|
+
declare function atomicWriteJson(file: string, value: unknown): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* 读取项目树;projects.json 缺失或损坏时以项目目录集合内容重建。
|
|
225
|
+
*
|
|
226
|
+
* 缺失(ENOENT)或 JSON 损坏(SyntaxError)都视为首次启动:
|
|
227
|
+
* 扫描 root/projects 下 UUID 格式的目录,为每个目录建立一个顶层项目
|
|
228
|
+
* (名称缺省为 id,可由用户后续通过编辑补全)。
|
|
229
|
+
*/
|
|
230
|
+
declare function readProjectTree(root: string): Promise<ProjectTree>;
|
|
231
|
+
/** 校验后原子写入项目树。 */
|
|
232
|
+
declare function writeProjectTree(root: string, tree: ProjectTree): Promise<void>;
|
|
233
|
+
/** 构造一个新项目节点;默认时间戳为当前时间。 */
|
|
234
|
+
declare function newProject(name: string, now?: string, description?: string, link?: string): ProjectNode;
|
|
235
|
+
/** 项目对应的磁盘目录路径:root/projects/<id>(不创建目录)。 */
|
|
236
|
+
declare function projectDirectory(root: string, id: string): string;
|
|
237
|
+
/** link 必须是宿主已有的绝对路径,拒绝相对路径与空值。 */
|
|
238
|
+
declare function isSafeLinkPath(link: string): boolean;
|
|
239
|
+
/** 持有子项目列表的容器:根树或项目节点均含 projectIds/projects。 */
|
|
240
|
+
interface ProjectHolder {
|
|
241
|
+
projectIds: string[];
|
|
242
|
+
projects: Record<string, ProjectNode>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 断言整树改写未改变任何项目的父归属(换父一律走 moveProject)。
|
|
246
|
+
*
|
|
247
|
+
* 比较口径:每个项目 id 的父容器 id(顶层为空串);新增项目允许
|
|
248
|
+
* (设置页新建经 project 路由,此处仅防换父脱节),删除项目允许
|
|
249
|
+
* (归档经 project 路由)。
|
|
250
|
+
*/
|
|
251
|
+
declare function assertNoParentChange(oldTree: ProjectTree, nextTree: ProjectTree): void;
|
|
252
|
+
/**
|
|
253
|
+
* 断言工作区归属在全树唯一(同一工作区至多出现一次)。
|
|
254
|
+
*
|
|
255
|
+
* 仅供整树替换(POST /projects-panel/tree)写边界兜底;日常挂载
|
|
256
|
+
* 走先摘除再挂载已天然保证唯一,不经此断言。
|
|
257
|
+
*/
|
|
258
|
+
declare function assertWorkspaceUnique(tree: ProjectTree): void;
|
|
259
|
+
/**
|
|
260
|
+
* 移动项目归属与排序(UUID 身份不变)。
|
|
261
|
+
*
|
|
262
|
+
* 项目目录 = projects/<id>/,与名称/归属解耦,因此移动只改树,不碰目录。
|
|
263
|
+
* 同容器纯排序只改顺序;换父只改父子引用。移动到自身或后代下、
|
|
264
|
+
* 锚点不存在或锚点已归档时拒绝且不落盘;同容器内锚点指向源自身
|
|
265
|
+
* 视为无排序变化,同样不落盘。
|
|
266
|
+
*/
|
|
267
|
+
declare function moveProject(root: string, sourceId: string, parentId?: string, beforeId?: string): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* 在内存树上执行换父(摘除源容器引用并按锚插入目标容器)。
|
|
270
|
+
*
|
|
271
|
+
* @param anchor 排序锚(省略=追加目标末尾)。
|
|
272
|
+
*/
|
|
273
|
+
declare function applyProjectMove(tree: ProjectTree, oldHolder: ProjectHolder, targetHolder: ProjectHolder, sourceId: string, node: ProjectNode, anchor: string | undefined): void;
|
|
274
|
+
/**
|
|
275
|
+
* 挂载工作区到指定项目下(新增成员关系或移动归属)。
|
|
276
|
+
*
|
|
277
|
+
* 无论目标如何,都会先把该工作区从原有位置摘除再挂到目标项目,
|
|
278
|
+
* 保证同一工作区在整棵活动树中至多出现一次;加入时间保留原记录。
|
|
279
|
+
* parentId 省略时视为「移到顶层」——顶层不记录成员关系,因此等价于
|
|
280
|
+
* 仅摘除(工作区随后以悬浮节点显示,此时 beforeId 不允许)。
|
|
281
|
+
* beforeId 省略表示追加到目标末尾,否则插入到锚点之前;锚点等于
|
|
282
|
+
* 工作区自身或锚点已归属异常时视为无操作或拒绝(锚点须为目标现成员)。
|
|
283
|
+
*/
|
|
284
|
+
declare function attachWorkspace(root: string, workspaceId: string, parentId?: string, beforeId?: string): Promise<void>;
|
|
285
|
+
/** 从活动树摘除某工作区的全部成员关系(官方工作区删除后的清理)。 */
|
|
286
|
+
declare function detachWorkspace(root: string, workspaceId: string): Promise<void>;
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/host-project.d.ts
|
|
289
|
+
/** 按 id 深度查找节点,返回节点与其直接父(顶层项目无父)。 */
|
|
290
|
+
declare function findNode(tree: ProjectTree, id: string): {
|
|
291
|
+
node: ProjectNode;
|
|
292
|
+
parent?: ProjectNode;
|
|
293
|
+
path: string[];
|
|
294
|
+
} | undefined;
|
|
295
|
+
/**
|
|
296
|
+
* 创建项目:建磁盘目录 + 挂入项目树。
|
|
297
|
+
*
|
|
298
|
+
* 目录名 = 项目 ID(UUID),与名称解耦。目录创建成功而树写入失败时,
|
|
299
|
+
* 残留一个孤儿目录,下次启动会通过 readProjectTree 的扫描恢复逻辑被重新挂载。
|
|
300
|
+
*/
|
|
301
|
+
declare function createProject(root: string, input: {
|
|
302
|
+
name: string;
|
|
303
|
+
description?: string;
|
|
304
|
+
link?: string;
|
|
305
|
+
parentId?: string;
|
|
306
|
+
}): Promise<string>;
|
|
307
|
+
/**
|
|
308
|
+
* 更新项目:可改名、改描述、改 link。
|
|
309
|
+
*
|
|
310
|
+
* 改名只更新 projects.json 的 name 字段,不碰磁盘目录(目录名 = ID,
|
|
311
|
+
* 与名称解耦)。重名检查在父级(顶层为树根)内进行。
|
|
312
|
+
*/
|
|
313
|
+
declare function updateProject(root: string, id: string, patch: {
|
|
314
|
+
name?: string;
|
|
315
|
+
description?: string;
|
|
316
|
+
link?: string;
|
|
317
|
+
}): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* 归档项目:移出活动树(加入 archivedProjectIds),不碰磁盘目录。
|
|
320
|
+
*
|
|
321
|
+
* 目录名 = ID,与归档状态解耦,恢复零成本,数据零丢失。
|
|
322
|
+
*/
|
|
323
|
+
declare function archiveProject(root: string, id: string): Promise<void>;
|
|
324
|
+
/**
|
|
325
|
+
* 读取 link 指向目录内的约定文件(如 AGENTS.md 供侧栏摘要展示)。
|
|
326
|
+
*
|
|
327
|
+
* @returns 文件不存在时返回 undefined;相对路径、绝对子路径或白名单外的
|
|
328
|
+
* 文件名一律抛错,防止把任意宿主文件暴露给客户端。
|
|
329
|
+
*/
|
|
330
|
+
declare function readLinkFile(link: string, relative: string): Promise<string | undefined>;
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/host-settings.d.ts
|
|
333
|
+
/** settings.json 缺失字段时的默认值(旧路由兼容)。 */
|
|
334
|
+
declare const defaultSettings: ProjectsSettings;
|
|
335
|
+
/**
|
|
336
|
+
* 读取插件设置(旧路由兼容):与默认值做浅合并。
|
|
337
|
+
*/
|
|
338
|
+
declare function readSettings(root: string): Promise<ProjectsSettings>;
|
|
339
|
+
/** 写入设置(旧路由兼容):version 固定为当前结构版本 1。 */
|
|
340
|
+
declare function writeSettings(root: string, settings: ProjectsSettings): Promise<void>;
|
|
341
|
+
/** settings 命名空间名称。 */
|
|
342
|
+
declare const SETTINGS_NAMESPACE = "projects-panel";
|
|
343
|
+
/** projects-panel 命名空间的用户可写结构。 */
|
|
344
|
+
interface ProjectsPanelSettings {
|
|
345
|
+
/** 工作区(项目分组浏览器)开关。 */
|
|
346
|
+
workspaces: {
|
|
347
|
+
enabled: boolean;
|
|
348
|
+
};
|
|
349
|
+
/** 系统通知开关。 */
|
|
350
|
+
notifications: {
|
|
351
|
+
enabled: boolean;
|
|
352
|
+
};
|
|
353
|
+
/** 品牌 mark/name(空 = 不渲染)。 */
|
|
354
|
+
brand: {
|
|
355
|
+
mark: string;
|
|
356
|
+
name: string;
|
|
357
|
+
};
|
|
358
|
+
/** 底栏「预演」目标 URL。 */
|
|
359
|
+
previewUrl: string;
|
|
360
|
+
/** 新建工作区默认挂入的项目(null = 顶层)。 */
|
|
361
|
+
defaultProject: string | null;
|
|
362
|
+
/** 树行为偏好。 */
|
|
363
|
+
tree: {
|
|
364
|
+
expandCurrent: boolean;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/** projects-panel 命名空间 schema(schemastery)。 */
|
|
368
|
+
declare const PROJECTS_PANEL_SETTINGS_SCHEMA: z<ProjectsPanelSettings>;
|
|
369
|
+
/** base 默认层(schema 校验后与用户层合并)。 */
|
|
370
|
+
declare const PROJECTS_PANEL_SETTINGS_BASE: ProjectsPanelSettings;
|
|
371
|
+
/** 宿主上下文最小投影(包含 settings 服务)。 */
|
|
372
|
+
type HostContextLike = {
|
|
373
|
+
settings?: {
|
|
374
|
+
register(namespace: string, schema: unknown, options?: {
|
|
375
|
+
base?: unknown;
|
|
376
|
+
}): unknown;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
/** 注册 projects-panel 设置命名空间到宿主(fail-open:settings 服务缺失时不抛)。 */
|
|
380
|
+
declare function registerSettingsNamespace(ctx: HostContextLike): void;
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/index.d.ts
|
|
383
|
+
interface WebServerLike {
|
|
384
|
+
register(route: {
|
|
385
|
+
kind: 'exact' | 'prefix';
|
|
386
|
+
path: string;
|
|
387
|
+
handler: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
388
|
+
}): () => void;
|
|
389
|
+
}
|
|
390
|
+
/** 官方 workspace 宿主实体的最小投影(与 @deepseek-ai/dsh-workspace 的 Workspace 同构)。 */
|
|
391
|
+
interface HostWorkspace {
|
|
392
|
+
id: string;
|
|
393
|
+
path: string;
|
|
394
|
+
title: string;
|
|
395
|
+
createdAt: string;
|
|
396
|
+
updatedAt: string;
|
|
397
|
+
sessionIds: readonly string[];
|
|
398
|
+
}
|
|
399
|
+
/** 官方 workspace 域服务(ctx.workspaceRegistry)的最小投影。 */
|
|
400
|
+
interface WorkspaceRegistryLike {
|
|
401
|
+
list(): readonly HostWorkspace[];
|
|
402
|
+
/** 全局归档会话 id 集合(getter)。 */
|
|
403
|
+
readonly archivedSessionIds: readonly string[];
|
|
404
|
+
}
|
|
405
|
+
/** 官方 session.list 返回的会话摘要的最小投影(字段对齐 SessionSummary)。 */
|
|
406
|
+
interface HostSessionSummary {
|
|
407
|
+
sessionId: string;
|
|
408
|
+
updatedAt: number;
|
|
409
|
+
running: boolean;
|
|
410
|
+
blank: boolean;
|
|
411
|
+
origin?: 'subagent';
|
|
412
|
+
cwd?: string;
|
|
413
|
+
projections?: {
|
|
414
|
+
values: Record<string, unknown>;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
/** 官方会话控制器服务(ctx.sessionController)的最小投影。 */
|
|
418
|
+
interface SessionControllerLike {
|
|
419
|
+
/** Remote 信封:list 返回 { items }(与官方 SessionController.list 一致)。 */
|
|
420
|
+
list(request: Record<string, never>, signal?: AbortSignal): Promise<{
|
|
421
|
+
items: readonly HostSessionSummary[];
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
interface HostContext extends Context {
|
|
425
|
+
webServer: WebServerLike;
|
|
426
|
+
workspaceRegistry: WorkspaceRegistryLike;
|
|
427
|
+
sessionController: SessionControllerLike;
|
|
428
|
+
/** 官方设置服务(projects-panel 命名空间注册与读取)。 */
|
|
429
|
+
settings: {
|
|
430
|
+
register(namespace: string, schema: unknown, options?: {
|
|
431
|
+
base?: unknown;
|
|
432
|
+
}): unknown;
|
|
433
|
+
get(namespace: string): Record<string, unknown>;
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
declare const inject: string[];
|
|
437
|
+
/**
|
|
438
|
+
* 计算项目数据根目录。
|
|
439
|
+
*
|
|
440
|
+
* DSH_PROJECTS_ROOT_DIR 设置时直接采用(支持 "~" 缩写,展开为用户主目录);
|
|
441
|
+
* 未设置时回落到 DSH_HOME(缺省 ~/.dsh)下的 dsh-projects-panel 目录。
|
|
442
|
+
*
|
|
443
|
+
* @param home 宿主数据根,测试时可注入临时目录
|
|
444
|
+
*/
|
|
445
|
+
declare function projectsRoot(home?: string): string;
|
|
446
|
+
/** 模块解析器:把模块标识符解析为绝对路径。 */
|
|
447
|
+
type ModuleResolver = (id: string) => string;
|
|
448
|
+
/** 清单读取器:从 package.json 绝对路径读出 version 字段。 */
|
|
449
|
+
type ManifestReader = (manifestPath: string) => string | undefined;
|
|
450
|
+
/**
|
|
451
|
+
* 解析 DSH 官方版本号,与 `dsh --version` 同源:同读 `@deepseek-ai/dsh/package.json`。
|
|
452
|
+
*
|
|
453
|
+
* DSH 启动时把安装依赖闭包镜像到 `$DSH_HOME/profiles/node_modules`,插件由自身
|
|
454
|
+
* 安装位置向上即可解析到该清单,因此结果与 `dsh --version` 恒等;清单不可解析或
|
|
455
|
+
* 读取失败(非标准安装)时回退插件版本。
|
|
456
|
+
* @param resolveManifest - 模块解析器,默认取本模块的 createRequire。
|
|
457
|
+
* @param readManifest - 清单读取器,默认 readPackageVersion。
|
|
458
|
+
* @returns DSH 版本号;解析失败回退 PLUGIN_VERSION。
|
|
459
|
+
*/
|
|
460
|
+
declare function readDshVersion(resolveManifest?: ModuleResolver, readManifest?: ManifestReader): string;
|
|
461
|
+
/** 插件入口:注册全部 HTTP 路由。数据根目录就绪后注册数据路由,健康检查立即生效。 */
|
|
462
|
+
declare function apply(ctx: HostContext): void;
|
|
463
|
+
//#endregion
|
|
464
|
+
export { BrowserActions, DirectoryEntryLike, DirectoryListingLike, FilterSelection, PROJECTS_PANEL_SETTINGS_BASE, PROJECTS_PANEL_SETTINGS_SCHEMA, ProjectHolder, ProjectNode, ProjectTree, ProjectsPanelSettings, ProjectsSettings, SETTINGS_NAMESPACE, SessionPendingKind, SessionView, SettingsScopeBind, WorkspaceMembership, WorkspaceView, abbreviateHomePath, apply, applyProjectMove, archiveProject, assertNoParentChange, assertWorkspaceUnique, atomicWriteJson, attachWorkspace, createProject, defaultSettings, detachWorkspace, emptyTree, findNode, inject, isSafeLinkPath, moveProject, newProject, projectDirectory, projectStoreRoot, projectsRoot, readDshVersion, readLinkFile, readProjectTree, readSettings, registerSettingsNamespace, updateProject, validateProjectName, validateProjectTree, workspaceIdOf, writeProjectTree, writeSettings };
|