dsh-manage-session 0.5.7 → 2.0.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/CHANGELOG.ja.md +33 -229
- package/CHANGELOG.ko.md +33 -229
- package/CHANGELOG.md +33 -363
- package/INSTALL.ja.md +164 -164
- package/INSTALL.ko.md +164 -164
- package/INSTALL.md +164 -164
- package/INSTALL.zh.md +164 -164
- package/LICENSE +21 -21
- package/README.en.md +41 -46
- package/README.ja.md +33 -57
- package/README.ko.md +32 -55
- package/README.md +64 -64
- package/cordis.patch.yml +19 -16
- package/dsh.plugin.json +4 -4
- package/lib/client.js +661 -3082
- package/lib/index.d.ts +79 -970
- package/lib/index.js +249 -2669
- package/locale/de.json +2 -2
- package/locale/en.json +2 -2
- package/locale/es.json +2 -2
- package/locale/fr.json +2 -2
- package/locale/it.json +2 -2
- package/locale/ja.json +2 -2
- package/locale/ko.json +2 -2
- package/locale/ru.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +15 -25
- package/screenshots.json +3 -3
- package/src/client/bridge-scope.ts +202 -213
- package/src/client/card.tsx +154 -154
- package/src/client/health-panel.tsx +49 -49
- package/src/client/host-api.ts +72 -6
- package/src/client/index.ts +594 -503
- package/src/client/locales.ts +893 -893
- package/src/client/manage-locales.ts +178 -0
- package/src/client/{search/manage.tsx → manage.tsx} +430 -404
- package/src/client/panel.tsx +131 -129
- package/src/client/session-menu-legacy.ts +2 -3
- package/src/client/session-menu.tsx +5 -5
- package/src/config.ts +43 -99
- package/src/host/health/attribution.ts +118 -118
- package/src/host/health/lossless.ts +128 -128
- package/src/host/health/repair.ts +2 -2
- package/src/host/health/source-kind.ts +350 -350
- package/src/host/history/archive-source.ts +250 -250
- package/src/host/history/archive.ts +249 -249
- package/src/host/history/favorites.ts +71 -71
- package/src/host/history/purge.ts +370 -370
- package/src/host/history/tombstones.ts +3 -3
- package/src/host/registry/archive-registry.ts +317 -317
- package/src/host/settings-bridge.ts +222 -264
- package/src/index.ts +66 -694
- package/src/client/search/card.tsx +0 -563
- package/src/client/search/host-api.ts +0 -213
- package/src/client/search/locales.ts +0 -861
- package/src/client/search/locate.ts +0 -330
- package/src/client/search/panel.tsx +0 -940
- package/src/client/search/platform.ts +0 -136
- package/src/host/index/archive-source.ts +0 -90
- package/src/host/index/drs-source.ts +0 -211
- package/src/host/index/engine.ts +0 -699
- package/src/host/index/extract.ts +0 -272
- package/src/host/index/peers.ts +0 -62
- package/src/host/index/rebuild.ts +0 -432
- package/src/host/index/schema.ts +0 -136
- package/src/host/index/snapshot.ts +0 -135
- package/src/host/index/sync.ts +0 -413
package/src/client/host-api.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 客户端 host 调用助手:一切经 fenced `/session
|
|
2
|
+
* 客户端 host 调用助手:一切经 fenced `/manage-session/api/<method>` 路由,
|
|
3
3
|
* 不 value-import 任何官方包(与 dsh-session-search-toggle 的 host-api.ts 同范式,
|
|
4
|
-
*
|
|
4
|
+
* 仅把路由前缀换成会话管理自己的)。
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** 单次 host 调用超时(导入类大响应可单独放宽)。 */
|
|
8
8
|
const FETCH_TIMEOUT = 20_000
|
|
9
9
|
|
|
10
|
-
/** POST 一个 JSON body
|
|
10
|
+
/** POST 一个 JSON body 到会话管理的 fenced API(items 形状)。 */
|
|
11
11
|
export function callHost<T>(method: string, body: unknown): Promise<{ ok: boolean; items: T[]; error?: string }> {
|
|
12
12
|
const controller = typeof AbortController === 'undefined' ? undefined : new AbortController()
|
|
13
13
|
const timer = controller !== undefined && typeof setTimeout === 'function'
|
|
14
14
|
? setTimeout(() => { controller.abort() }, FETCH_TIMEOUT)
|
|
15
15
|
: undefined
|
|
16
|
-
return fetch(`/session
|
|
16
|
+
return fetch(`/manage-session/api/${method}`, {
|
|
17
17
|
method: 'POST',
|
|
18
18
|
headers: { 'content-type': 'application/json' },
|
|
19
19
|
body: JSON.stringify(body),
|
|
@@ -47,7 +47,7 @@ export function callHostAny<T>(
|
|
|
47
47
|
const timer = typeof setTimeout === 'function'
|
|
48
48
|
? setTimeout(() => { controller?.abort() }, timeout)
|
|
49
49
|
: undefined
|
|
50
|
-
return fetch(`/session
|
|
50
|
+
return fetch(`/manage-session/api/${method}`, {
|
|
51
51
|
method: 'POST',
|
|
52
52
|
headers: { 'content-type': 'application/json' },
|
|
53
53
|
body: JSON.stringify(body),
|
|
@@ -184,12 +184,78 @@ export interface SourceMigrateResponse {
|
|
|
184
184
|
error?: string
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* 兼容别名:合并包时代的 `callSteward` 与 `callHostAny` 同实现(同一 fenced
|
|
189
|
+
* 路由、同一返回形状),保留调用面不迁移。
|
|
190
|
+
*/
|
|
191
|
+
export const callSteward = callHostAny
|
|
192
|
+
|
|
193
|
+
/** POST 到 items 形状的 fenced 方法(管理台语料 session-catalog 用)。 */
|
|
194
|
+
export async function callStewardItems<T>(method: string, body: unknown): Promise<{ ok: boolean; items: T[]; error?: string }> {
|
|
195
|
+
const res = await callHostAny<{ items?: T[] }>(method, body)
|
|
196
|
+
if (res.ok === true && Array.isArray(res.items)) return { ok: true, items: res.items }
|
|
197
|
+
return { ok: false, items: [], error: res.error ?? '请求失败' }
|
|
198
|
+
}
|
|
199
|
+
|
|
187
200
|
/** 状态响应。 */
|
|
188
201
|
export interface HealthStatusResponse {
|
|
189
202
|
ok: boolean
|
|
190
|
-
switches?: { enabled: boolean; historyFiles: boolean; healthCheck: boolean }
|
|
203
|
+
switches?: { enabled: boolean; historyFiles: boolean; healthCheck: boolean; directDelete?: boolean }
|
|
191
204
|
historyMethods?: string[]
|
|
192
205
|
healthMethods?: string[]
|
|
193
206
|
home?: string
|
|
194
207
|
error?: string
|
|
195
208
|
}
|
|
209
|
+
|
|
210
|
+
/** One session listed by `session-catalog` (active + archived in one table). */
|
|
211
|
+
export interface HostSessionItem {
|
|
212
|
+
sessionId: string
|
|
213
|
+
title: string
|
|
214
|
+
cwd: string
|
|
215
|
+
updatedAt: number
|
|
216
|
+
/** 归档标记(合表语义):缺省字段按「活跃」对待。 */
|
|
217
|
+
archived?: boolean
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 直接删除入口开关(`manage-session.directDelete`,缺省关)。
|
|
222
|
+
* 由 `session-health-status` 的 switches 面读取;旧宿主半无该字段 → false
|
|
223
|
+
* (破坏性入口不出现是安全方向)。
|
|
224
|
+
*/
|
|
225
|
+
export async function probeDirectDelete(): Promise<boolean> {
|
|
226
|
+
const res = await callHostAny<HealthStatusResponse>('session-health-status', {})
|
|
227
|
+
return res.ok === true && res.switches?.directDelete === true
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The client sessions service face. Host lines before 0.1.7 exposed session
|
|
232
|
+
* navigation here as `open`; the 0.1.7 contract dropped it ("navigation
|
|
233
|
+
* belongs to view owners") — kept only as the legacy fallback of
|
|
234
|
+
* `openSessionThrough`.
|
|
235
|
+
*/
|
|
236
|
+
export interface SwitchSessionsService {
|
|
237
|
+
open(id: string): void
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The client ui-workspace face: session navigation has been owned by this
|
|
242
|
+
* service since host 0.1.7 (`openSession`; a bare session id is accepted).
|
|
243
|
+
*/
|
|
244
|
+
export interface SwitchUiWorkspaceService {
|
|
245
|
+
openSession(target: string): void
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Open a session through whichever face the running host offers:
|
|
250
|
+
* `uiWorkspace.openSession` first (0.1.7+), the pre-0.1.7 `sessions.open` as
|
|
251
|
+
* fallback. Neither present → silent no-op.
|
|
252
|
+
*/
|
|
253
|
+
export function openSessionThrough(get: (name: string) => unknown, sessionId: string): void {
|
|
254
|
+
const uiWorkspace = get('uiWorkspace') as SwitchUiWorkspaceService | undefined
|
|
255
|
+
if (uiWorkspace !== undefined && typeof uiWorkspace.openSession === 'function') {
|
|
256
|
+
uiWorkspace.openSession(sessionId)
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
const sessions = get('sessions') as SwitchSessionsService | undefined
|
|
260
|
+
if (sessions !== undefined && typeof sessions.open === 'function') sessions.open(sessionId)
|
|
261
|
+
}
|