import type { HostContext } from './types.js'; export declare function isValidSessionId(id: string): boolean; export interface TrashEntry { sessionId: string; title: string; /** 会话的工作目录(绝对路径);恢复时用于匹配工作区。 */ cwd: string; originalPath: string; trashLocation: string; trashedAt: number; token: string; } export declare const sessionTrash: { remember(entry: Omit): TrashEntry; forget(sessionId: string): boolean; list(): TrashEntry[]; get(sessionId: string): TrashEntry | undefined; }; interface DeleteDeps { sessions?: { get(id: string): unknown; }; agents?: { get(id: string): unknown; }; sessionPersistence?: { list?(): Promise>; /** DSH 0.1.2-rc.1 公开面:读取 artifact(返回 meta)与定位物理路径。 */ locate?(meta: { id: string; cwd?: string; }): { kind: string; path: string; } | undefined; readRaw?(id: string): Promise<{ meta: { id: string; cwd?: string; }; } | undefined>; /** * DSH 0.1.3-alpha.1 起的新公开面:`readRaw`/`locate` 不再公开, * 改用 create/open/stat/list 句柄模型。stat 返回快照(含 header), * 但不提供物理路径——物理目录由 {@link locateSessionDirById} 按 * `~/.dsh/sessions/<项目>/<会话 id>` 布局扫描定位。 */ stat?(id: string): Promise<{ header?: { id: string; cwd?: string; }; meta?: { id: string; cwd?: string; }; } | undefined>; }; workspaceRegistry?: { list(): Array<{ path: string; sessionIds: readonly string[]; detachSession(id: string): Promise; attachSession(id: string): Promise; }>; archivedSessionIds?: readonly string[]; archiveSession?(id: string): Promise; /** * 上游 2026-09-12(5f773a0ded)起公开:registry 串行链上的官方取消 * 归档(全量状态写入 + 内存缓存同步)。存在时必须优先于 storageDomain * 直写——后者绕过 registry 串行器,仅作旧版回退。 */ unarchiveSession?(id: string): Promise; }; storageDomain?: { get?(name: string): { global?: { get(): { archivedSessionIds?: readonly string[]; } | undefined; /** * 整体替换写入(DSH DomainGlobal.set 无合并):value 必须是回读到的 * 全量 state 加字段覆盖——只写单字段会丢掉 workspace 域 schema 必填 * 的 initialized/workspaceIds,下次启动 domain 打开时校验失败, * workspaceRegistry 整体挂载失败、dsh 无法启动(issue #8)。 */ set(value: { archivedSessionIds: readonly string[]; }): Promise; }; } | undefined; }; } /** * 把会话从工作区归档集合移除(取消归档)。 * * 优先走上游公开 API:workspaceRegistry.unarchiveSession(上游 2026-09-12 * 起公开)在 registry 串行链上做全量状态写入并同步内存缓存,即官方取消 * 归档语义。该 API 缺席(旧版 dsh)才回退 storageDomain 直写——此时 * registry 没有公开 unarchive/事务写 API,只能绕过串行器直写持久层; * 且 global.set 是整体替换(无合并):必须回写「回读到的全量 state + * archivedSessionIds 覆盖」,只写单字段会把 workspace 域 schema 必填的 * initialized/workspaceIds 冲掉,下次启动 domain 打开校验失败、整个 * workspaceRegistry 挂载失败、dsh 无法启动(issue #8)。 * * 回退路径的写入无事务保障,但 global.set 排队在域的单一 FIFO 写链上: * set resolve 时所有先前写入均已完成,随后的同步 get 读到的是链上权威 * 真值(内存即权威,无需穿透介质)。因此写后重读一次,目标 id 仍在则 * 基于当时的全量真值重放一次覆盖写;无法覆盖的仅剩“排队更晚的官方 * archiveSession 落地覆盖本写”——那属于归档请求后到、归档生效,语义 * 本应如此。 */ export declare function unarchiveSession(deps: DeleteDeps, sessionId: string): Promise<{ ok: boolean; changed: boolean; }>; /** * 执行会话删除。 * @param deps - 主机服务面(从 ctx.get 解析)。 * @param sessionId - 目标会话 id。 * @param options - { trash: 是否移入系统回收站;false 为彻底删除(不进回收站) }。 * @returns 结果对象;ok=false 时带 code/message。 */ export declare function deleteSession(deps: DeleteDeps, sessionId: string, options: { trash: boolean; title?: string; currentSessionId?: string; }): Promise<{ ok: true; trashed: boolean; hint?: string; } | { ok: false; code: string; message: string; }>; /** * 从回收站恢复一个会话目录(并重新挂回工作区账本)。 * @param deps - 服务面解析器。 * @param entry - 回收站条目。 * @param restoreItemImpl - 恢复实现(可注入;默认平台实现,测试用)。 */ export declare function restoreSession(deps: DeleteDeps, entry: TrashEntry, restoreItemImpl?: (location: string, originalPath: string) => Promise): Promise<{ ok: true; } | { ok: false; code: string; message: string; }>; /** * 安装 /dsh-zh/api 路由:会话删除 / 回收站列表 / 恢复 + GET 服务监控快照。 * @param ctx - 主机上下文(webServer 服务)。 * @param deps - 服务面解析器(惰性读取,支持 HMR 后重新解析)。 */ export declare function installSessionDeleteRoute(ctx: HostContext, deps: () => DeleteDeps): void; export {}; //# sourceMappingURL=session-delete.d.ts.map