@xsok/dsh-enhanced 0.0.0-stage → 0.2.2-10
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 +92 -0
- package/LICENSE +21 -0
- package/README.md +149 -2
- package/client.js +3791 -0
- package/cordis.patch.yml +4 -0
- package/host/engine/archive.js +150 -0
- package/host/engine/atomic.js +27 -0
- package/host/engine/attachments.js +102 -0
- package/host/engine/config.js +214 -0
- package/host/engine/index.js +355 -0
- package/host/engine/ledger.js +108 -0
- package/host/engine/paths.js +81 -0
- package/host/engine/pluginlist.js +81 -0
- package/host/engine/projcache.js +202 -0
- package/host/engine/prune.js +187 -0
- package/host/engine/scan.js +177 -0
- package/host/engine/session.js +138 -0
- package/host/engine/sessions.js +395 -0
- package/host/engine/workspace.js +255 -0
- package/host/engine/zstd.js +91 -0
- package/host/envcheck.js +289 -0
- package/host/mirror.js +502 -0
- package/host/move.js +196 -0
- package/host/overwrite.js +305 -0
- package/host/restart.js +158 -0
- package/host/schedule.js +315 -0
- package/host/search.js +250 -0
- package/host/sync.js +608 -0
- package/host/trash.js +738 -0
- package/host/trashsync.js +204 -0
- package/host/webdav.js +429 -0
- package/icon.svg +1 -0
- package/index.js +376 -0
- package/locale/en.json +68 -0
- package/locale/zh.json +68 -0
- package/package.json +79 -4
package/index.js
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH增强 — Host half.
|
|
3
|
+
*
|
|
4
|
+
* Owns one exact Connection fetch route (`POST /api/dsh-enhanced/rpc`) that the
|
|
5
|
+
* browser half calls. Connection applies its Host/Origin fence and browser
|
|
6
|
+
* authentication before this handler runs, and only an owner principal reaches
|
|
7
|
+
* an exact route, so the handler itself carries no token logic.
|
|
8
|
+
*
|
|
9
|
+
* The plugin adds no session events, no model-facing tools, and no prompt text:
|
|
10
|
+
* it only reads session logs, moves local files, and mutates workspace
|
|
11
|
+
* accounting through the official registry write path.
|
|
12
|
+
*/
|
|
13
|
+
import {
|
|
14
|
+
clearTrash,
|
|
15
|
+
deleteSession,
|
|
16
|
+
failure,
|
|
17
|
+
listTrash,
|
|
18
|
+
purgeSession,
|
|
19
|
+
purgeWorkspace,
|
|
20
|
+
readSettings,
|
|
21
|
+
restoreSession,
|
|
22
|
+
resolvePaths,
|
|
23
|
+
writeSettings,
|
|
24
|
+
} from './host/trash.js';
|
|
25
|
+
import path from 'node:path';
|
|
26
|
+
import { appendFile } from 'node:fs/promises';
|
|
27
|
+
import { createSearch } from './host/search.js';
|
|
28
|
+
import { restartApplication } from './host/restart.js';
|
|
29
|
+
import { pluginVersion } from './host/version.js';
|
|
30
|
+
import { inspectOverride, overwriteCloud, overwriteLocal } from './host/overwrite.js';
|
|
31
|
+
import { moveCandidates, moveSession, readAllEvents } from './host/move.js';
|
|
32
|
+
import { inspectSyncTarget, readSyncHistory, readSyncState, recordOverwrite, resolveSyncTarget, runSync } from './host/sync.js';
|
|
33
|
+
import { installSyncScheduler } from './host/schedule.js';
|
|
34
|
+
import { appVersion, readEnvRecord, runEnvironmentCheck, writeEnvironmentReport, writeEnvRecord } from './host/envcheck.js';
|
|
35
|
+
import { testConnection } from './host/webdav.js';
|
|
36
|
+
import { pullMirror, pushMirror } from './host/mirror.js';
|
|
37
|
+
|
|
38
|
+
/** Stable Cordis plugin name. */
|
|
39
|
+
export const name = 'dsh-enhanced';
|
|
40
|
+
|
|
41
|
+
/** Host services this plugin needs before or while it activates. */
|
|
42
|
+
export const inject = ['webServer', 'connection', 'sessionPersistence', 'workspaceRegistry'];
|
|
43
|
+
|
|
44
|
+
const ROUTE_PATH = '/api/dsh-enhanced/rpc';
|
|
45
|
+
const SESSION_ID_PATTERN = /^session-[A-Za-z0-9._-]+$/u;
|
|
46
|
+
|
|
47
|
+
function jsonResponse(value, status = 200) {
|
|
48
|
+
return new Response(JSON.stringify(value), {
|
|
49
|
+
status,
|
|
50
|
+
headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function requireSessionId(value) {
|
|
55
|
+
if (typeof value !== 'string' || !SESSION_ID_PATTERN.test(value)) {
|
|
56
|
+
throw failure('bad-session-id', '会话标识无效。');
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Mount the Host half.
|
|
63
|
+
* @param ctx - owning Cordis context.
|
|
64
|
+
* @param config - optional path overrides (`root`, `sessionsRoot`, `projcacheRoot`).
|
|
65
|
+
*/
|
|
66
|
+
export function apply(ctx, config = {}) {
|
|
67
|
+
const paths = resolvePaths(config);
|
|
68
|
+
const search = createSearch({ persistence: ctx.sessionPersistence });
|
|
69
|
+
|
|
70
|
+
void (async () => {
|
|
71
|
+
try {
|
|
72
|
+
await appendFile(
|
|
73
|
+
path.join(paths.base, 'restart.log'),
|
|
74
|
+
`${new Date().toISOString()} plugin applied; execPath=${process.execPath}; ppid=${String(process.ppid)}; version=0.2.2-rc.1-1.3\n`,
|
|
75
|
+
'utf8',
|
|
76
|
+
);
|
|
77
|
+
} catch {
|
|
78
|
+
// Diagnostics only.
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
|
|
82
|
+
// Bumped for every committed user message; the composer badge watches it to
|
|
83
|
+
// know the reader sent something and the finished-sync line may go away.
|
|
84
|
+
let userMessageSeq = 0;
|
|
85
|
+
const watchWaiters = new Set();
|
|
86
|
+
try {
|
|
87
|
+
ctx.effect(() => ctx.on('session/event', (session, event) => {
|
|
88
|
+
if (event?.type !== 'user/message') return;
|
|
89
|
+
userMessageSeq += 1;
|
|
90
|
+
// Wake the waiting call so the client sees the new count immediately.
|
|
91
|
+
for (const wake of [...watchWaiters]) {
|
|
92
|
+
try {
|
|
93
|
+
wake();
|
|
94
|
+
} catch {
|
|
95
|
+
// A broken waiter must not affect the others.
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}), 'dsh-enhanced: user message counter');
|
|
99
|
+
} catch {
|
|
100
|
+
// Without the event the line simply clears on the next sync instead.
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const dependencies = (settings) => ({
|
|
104
|
+
paths,
|
|
105
|
+
settings,
|
|
106
|
+
registry: ctx.workspaceRegistry,
|
|
107
|
+
persistence: ctx.sessionPersistence,
|
|
108
|
+
query: ctx.get('sessionQuery'),
|
|
109
|
+
agents: ctx.get('agents'),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
async function dispatch(request, signal) {
|
|
113
|
+
const action = typeof request?.action === 'string' ? request.action : '';
|
|
114
|
+
switch (action) {
|
|
115
|
+
case 'state': {
|
|
116
|
+
const settings = await readSettings(paths);
|
|
117
|
+
let listed = { count: 0, size: 0 };
|
|
118
|
+
try {
|
|
119
|
+
listed = await listTrash(dependencies(settings));
|
|
120
|
+
} catch {
|
|
121
|
+
listed = { count: 0, size: 0 };
|
|
122
|
+
}
|
|
123
|
+
return { settings, count: listed.count, size: listed.size };
|
|
124
|
+
}
|
|
125
|
+
case 'settings.get':
|
|
126
|
+
return { settings: await readSettings(paths) };
|
|
127
|
+
case 'settings.set': {
|
|
128
|
+
const patch = request?.patch !== null && typeof request.patch === 'object' ? request.patch : {};
|
|
129
|
+
return { settings: await writeSettings(paths, patch) };
|
|
130
|
+
}
|
|
131
|
+
case 'session.delete': {
|
|
132
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
133
|
+
const settings = await readSettings(paths);
|
|
134
|
+
return deleteSession(dependencies(settings), sessionId);
|
|
135
|
+
}
|
|
136
|
+
case 'session.move': {
|
|
137
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
138
|
+
const workspaceId = request?.workspaceId;
|
|
139
|
+
if (typeof workspaceId !== 'string' || !/^[A-Za-z0-9._-]+$/u.test(workspaceId)) {
|
|
140
|
+
throw failure('bad-workspace-id', '工作区标识无效。');
|
|
141
|
+
}
|
|
142
|
+
const settings = await readSettings(paths);
|
|
143
|
+
return moveSession(dependencies(settings), sessionId, workspaceId);
|
|
144
|
+
}
|
|
145
|
+
case 'workspace.candidates': {
|
|
146
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
147
|
+
const settings = await readSettings(paths);
|
|
148
|
+
return moveCandidates(dependencies(settings), sessionId);
|
|
149
|
+
}
|
|
150
|
+
case 'locate.event': {
|
|
151
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
152
|
+
const seq = Number(request?.seq);
|
|
153
|
+
if (!Number.isInteger(seq) || seq < 0) throw failure('bad-seq', '事件序号无效。');
|
|
154
|
+
const events = await readAllEvents(ctx.sessionPersistence, sessionId);
|
|
155
|
+
let turn = null;
|
|
156
|
+
for (const event of events) {
|
|
157
|
+
if (event.type === 'turn/start' && typeof event.data?.turn === 'number') turn = event.data.turn;
|
|
158
|
+
if (event.seq === seq) break;
|
|
159
|
+
}
|
|
160
|
+
return { turn };
|
|
161
|
+
}
|
|
162
|
+
case 'sync.state': {
|
|
163
|
+
const settings = await readSettings(paths);
|
|
164
|
+
const target = await inspectSyncTarget({ paths, settings });
|
|
165
|
+
const state = await readSyncState({ paths, settings });
|
|
166
|
+
const live = typeof ctx.get('agents')?.list === 'function'
|
|
167
|
+
? ctx.get('agents').list().filter((agent) => agent?.status === 'running').length
|
|
168
|
+
: 0;
|
|
169
|
+
const history = await readSyncHistory({ paths, settings });
|
|
170
|
+
return { settings: { syncEnabled: settings.syncEnabled, syncDir: settings.syncDir, syncScript: settings.syncScript, syncMachineId: settings.syncMachineId, syncSkipAttachments: settings.syncSkipAttachments }, target, state, history, auto: scheduler.status(), running: live };
|
|
171
|
+
}
|
|
172
|
+
case 'sync.watch': {
|
|
173
|
+
// Resolve as soon as the automatic run starts or stops (or after 25 s),
|
|
174
|
+
// so the client follows the state without a polling timer.
|
|
175
|
+
const current = () => {
|
|
176
|
+
const live = typeof ctx.get('agents')?.list === 'function'
|
|
177
|
+
? ctx.get('agents').list().filter((agent) => agent?.status === 'running').length
|
|
178
|
+
: 0;
|
|
179
|
+
return { auto: scheduler.status(), running: live, userSeq: userMessageSeq };
|
|
180
|
+
};
|
|
181
|
+
return await new Promise((resolve) => {
|
|
182
|
+
let settled = false;
|
|
183
|
+
let unsubscribe = () => {};
|
|
184
|
+
const finish = () => {
|
|
185
|
+
if (settled) return;
|
|
186
|
+
settled = true;
|
|
187
|
+
unsubscribe();
|
|
188
|
+
watchWaiters.delete(finish);
|
|
189
|
+
clearTimeout(timer);
|
|
190
|
+
resolve(current());
|
|
191
|
+
};
|
|
192
|
+
const timer = setTimeout(finish, 25_000);
|
|
193
|
+
unsubscribe = scheduler.subscribe(finish);
|
|
194
|
+
watchWaiters.add(finish);
|
|
195
|
+
signal?.addEventListener?.('abort', finish, { once: true });
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
case 'sync.auto': {
|
|
199
|
+
const live = typeof ctx.get('agents')?.list === 'function'
|
|
200
|
+
? ctx.get('agents').list().filter((agent) => agent?.status === 'running').length
|
|
201
|
+
: 0;
|
|
202
|
+
return { auto: scheduler.status(), running: live };
|
|
203
|
+
}
|
|
204
|
+
case 'sync.probe':
|
|
205
|
+
case 'sync.run': {
|
|
206
|
+
// A running turn is writing session files; syncing then risks reading a
|
|
207
|
+
// half-written log. The launch-time call asks for quiet so it can skip.
|
|
208
|
+
if (action === 'sync.run') {
|
|
209
|
+
const busy = (ctx.get('agents')?.list?.() ?? []).some((agent) => agent?.status === 'running');
|
|
210
|
+
if (busy) {
|
|
211
|
+
if (request?.quiet === true) return { skipped: 'busy' };
|
|
212
|
+
throw failure('sync-task-running', '有会话正在运行,稍后再同步。');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const settings = await readSettings(paths);
|
|
216
|
+
return runSync({ paths, settings, agents: ctx.get('agents'), registry: ctx.workspaceRegistry }, { probe: action === 'sync.probe' });
|
|
217
|
+
}
|
|
218
|
+
case 'sync.history': {
|
|
219
|
+
const settings = await readSettings(paths);
|
|
220
|
+
return { history: await readSyncHistory({ paths, settings }) };
|
|
221
|
+
}
|
|
222
|
+
case 'sync.webdavTest': {
|
|
223
|
+
const settings = await readSettings(paths);
|
|
224
|
+
return testConnection(settings, request?.signal);
|
|
225
|
+
}
|
|
226
|
+
case 'sync.resume': {
|
|
227
|
+
return { auto: scheduler.resume() };
|
|
228
|
+
}
|
|
229
|
+
case 'sync.overwrite': {
|
|
230
|
+
const settings = await readSettings(paths);
|
|
231
|
+
if (settings.syncMode !== 'webdav') throw failure('overwrite-mode', '只有 WebDAV 模式支持覆盖操作。');
|
|
232
|
+
const target = resolveSyncTarget(paths, settings);
|
|
233
|
+
const running = (ctx.get('agents')?.list?.() ?? []).filter((agent) => agent?.status === 'running').length;
|
|
234
|
+
if (running > 0) throw failure('overwrite-busy', '有会话正在运行,停一会儿再覆盖。');
|
|
235
|
+
const deps = {
|
|
236
|
+
paths,
|
|
237
|
+
settings,
|
|
238
|
+
machineId: target.machineId,
|
|
239
|
+
mirrorDir: target.syncDir,
|
|
240
|
+
profile: target.profile,
|
|
241
|
+
};
|
|
242
|
+
const direction = request?.direction;
|
|
243
|
+
if (direction === 'preview') return inspectOverride(deps);
|
|
244
|
+
if (request?.apply !== true) throw failure('overwrite-confirm', '覆盖需要确认后才执行。');
|
|
245
|
+
if (direction !== 'cloud' && direction !== 'local') throw failure('overwrite-direction', '未知的覆盖方向。');
|
|
246
|
+
const startedAt = Date.now();
|
|
247
|
+
const result = direction === 'cloud' ? await overwriteCloud(deps) : await overwriteLocal(deps);
|
|
248
|
+
const log = direction === 'cloud'
|
|
249
|
+
? [`覆盖云端:上传 ${String(result.uploaded ?? 0)} 个文件,删除云端 ${String(result.deleted ?? 0)} 个文件`, `覆盖区域:${String(result.copied ?? 0)} 个`]
|
|
250
|
+
: [`覆盖本机:复制 ${String(result.copied ?? 0)} 个区域`, `本地化会话:${String(result.localized ?? 0)} 个`];
|
|
251
|
+
const record = await recordOverwrite({ paths, settings }, {
|
|
252
|
+
direction,
|
|
253
|
+
ok: result.ok !== false,
|
|
254
|
+
durationMs: Date.now() - startedAt,
|
|
255
|
+
uploaded: result.uploaded,
|
|
256
|
+
localized: result.localized,
|
|
257
|
+
deleted: result.deleted,
|
|
258
|
+
copied: result.copied,
|
|
259
|
+
log: result.warning === undefined ? log : [...log, result.warning],
|
|
260
|
+
});
|
|
261
|
+
return { ...result, record };
|
|
262
|
+
}
|
|
263
|
+
case 'app.restart': {
|
|
264
|
+
const running = (ctx.get('agents')?.list?.() ?? []).filter((agent) => agent?.status === 'running').length;
|
|
265
|
+
if (running > 0) throw failure('restart-busy', '有会话正在运行,稍后再重启。');
|
|
266
|
+
return restartApplication(paths);
|
|
267
|
+
}
|
|
268
|
+
case 'env.check': {
|
|
269
|
+
return runEnvironmentCheck({ paths, ctx });
|
|
270
|
+
}
|
|
271
|
+
case 'env.report': {
|
|
272
|
+
const result = await runEnvironmentCheck({ paths, ctx });
|
|
273
|
+
const written = await writeEnvironmentReport({ paths }, result);
|
|
274
|
+
await writeEnvRecord(paths, { lastReport: written.path, lastCheckAt: result.checkedAt });
|
|
275
|
+
return { ...written, ok: result.ok };
|
|
276
|
+
}
|
|
277
|
+
case 'env.version': {
|
|
278
|
+
const current = await appVersion();
|
|
279
|
+
const record = await readEnvRecord(paths);
|
|
280
|
+
return {
|
|
281
|
+
appVersion: current.version,
|
|
282
|
+
pluginVersion: pluginVersion(),
|
|
283
|
+
lastAppVersion: record.lastAppVersion ?? null,
|
|
284
|
+
changed: current.version !== null && record.lastAppVersion !== undefined && record.lastAppVersion !== current.version,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
case 'env.ack': {
|
|
288
|
+
const current = await appVersion();
|
|
289
|
+
if (current.version === null) return { ok: false, reason: 'version-unknown' };
|
|
290
|
+
await writeEnvRecord(paths, { lastAppVersion: current.version, ackAt: new Date().toISOString() });
|
|
291
|
+
return { ok: true };
|
|
292
|
+
}
|
|
293
|
+
case 'sync.log': {
|
|
294
|
+
const settings = await readSettings(paths);
|
|
295
|
+
const state = await readSyncState({ paths, settings });
|
|
296
|
+
return { log: state?.log ?? [] };
|
|
297
|
+
}
|
|
298
|
+
case 'trash.list': {
|
|
299
|
+
const settings = await readSettings(paths);
|
|
300
|
+
const scope = {
|
|
301
|
+
workspaceId: typeof request?.workspaceId === 'string' ? request.workspaceId : undefined,
|
|
302
|
+
sessionId: typeof request?.sessionId === 'string' && SESSION_ID_PATTERN.test(request.sessionId) ? request.sessionId : undefined,
|
|
303
|
+
};
|
|
304
|
+
return listTrash(dependencies(settings), scope);
|
|
305
|
+
}
|
|
306
|
+
case 'trash.restore': {
|
|
307
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
308
|
+
const settings = await readSettings(paths);
|
|
309
|
+
return restoreSession(dependencies(settings), sessionId);
|
|
310
|
+
}
|
|
311
|
+
case 'trash.purge': {
|
|
312
|
+
const sessionId = requireSessionId(request?.sessionId);
|
|
313
|
+
const settings = await readSettings(paths);
|
|
314
|
+
return purgeSession(dependencies(settings), sessionId);
|
|
315
|
+
}
|
|
316
|
+
case 'trash.clear': {
|
|
317
|
+
const settings = await readSettings(paths);
|
|
318
|
+
const workspaceId = typeof request?.workspaceId === 'string' ? request.workspaceId : undefined;
|
|
319
|
+
if (workspaceId !== undefined && !/^[A-Za-z0-9._-]+$/u.test(workspaceId)) {
|
|
320
|
+
throw failure('bad-workspace-id', '工作区标识无效。');
|
|
321
|
+
}
|
|
322
|
+
return clearTrash(dependencies(settings), { workspaceId });
|
|
323
|
+
}
|
|
324
|
+
case 'search': {
|
|
325
|
+
const settings = await readSettings(paths);
|
|
326
|
+
if (settings.searchEnabled !== true) throw failure('search-disabled', '内容搜索已在设置中关闭。');
|
|
327
|
+
const query = typeof request?.query === 'string' ? request.query : '';
|
|
328
|
+
return search.search(query, settings, signal);
|
|
329
|
+
}
|
|
330
|
+
default:
|
|
331
|
+
throw failure('unknown-action', `未知的请求:${action}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const scheduler = installSyncScheduler(ctx, { paths, agents: ctx.get('agents') });
|
|
336
|
+
ctx.effect(() => () => scheduler.dispose(), 'dsh-enhanced: sync scheduler');
|
|
337
|
+
|
|
338
|
+
// Deleting a workspace drops every recycle-bin record it owned, immediately:
|
|
339
|
+
// the workspace domain write that removes the record is the same commit the
|
|
340
|
+
// sidebar sees. The lazy check in `listTrash` stays as a fallback for
|
|
341
|
+
// deletions that happened while this plugin was unloaded.
|
|
342
|
+
ctx.on('domain/changed', (change) => {
|
|
343
|
+
if (change === null || typeof change !== 'object') return;
|
|
344
|
+
if (change.domain !== 'workspace' || change.table !== 'workspaces' || change.operation !== 'deleted') return;
|
|
345
|
+
purgeWorkspace(paths, change.key).catch((error) => {
|
|
346
|
+
const message = `dsh-enhanced: purging the recycle bin of workspace ${String(change.key)} failed: ${error?.stack ?? String(error)}`;
|
|
347
|
+
if (typeof ctx.logger?.warn === 'function') ctx.logger.warn(message);
|
|
348
|
+
else console.warn(message);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
ctx.connection.fetch.register({
|
|
353
|
+
path: ROUTE_PATH,
|
|
354
|
+
methods: ['POST'],
|
|
355
|
+
fetch: async (request) => {
|
|
356
|
+
let body;
|
|
357
|
+
try {
|
|
358
|
+
body = await request.json();
|
|
359
|
+
} catch {
|
|
360
|
+
return jsonResponse({ ok: false, error: { code: 'bad-body', message: '请求体不是合法的 JSON。' } });
|
|
361
|
+
}
|
|
362
|
+
try {
|
|
363
|
+
const data = await dispatch(body, request.signal);
|
|
364
|
+
return jsonResponse({ ok: true, data });
|
|
365
|
+
} catch (error) {
|
|
366
|
+
const code = typeof error?.code === 'string' ? error.code : 'internal';
|
|
367
|
+
if (code === 'internal' || code === 'workspace-detach-failed' || code === 'session-move-failed') {
|
|
368
|
+
const message = `dsh-enhanced: ${String(request?.action)} failed: ${error?.stack ?? String(error)}`;
|
|
369
|
+
if (typeof ctx.logger?.warn === 'function') ctx.logger.warn(message);
|
|
370
|
+
else console.warn(message);
|
|
371
|
+
}
|
|
372
|
+
return jsonResponse({ ok: false, error: { code, message: error?.message ?? String(error), details: error?.details } });
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "DSH Enhanced",
|
|
4
|
+
"description": "Two-way session sync across devices over WebDAV or a shared folder, covering sessions, workspaces, attachments and config — plus session delete and recovery, cross-workspace move, and full-corpus search."
|
|
5
|
+
},
|
|
6
|
+
"nav.title": "DSH Enhanced",
|
|
7
|
+
"section.title": "DSH Enhanced",
|
|
8
|
+
"section.desc": "Session sync, session management and full-corpus search. Syncing uploads sessions, workspaces, attachments and config to the cloud folder you configure.",
|
|
9
|
+
"switch.delete": "Delete sessions",
|
|
10
|
+
"switch.delete.desc": "Adds \"Delete session\" to the session menu. A running session cannot be deleted.",
|
|
11
|
+
"switch.move": "Move between workspaces",
|
|
12
|
+
"switch.move.desc": "Adds \"Move to workspace\" to the session menu. The session itself stays the same; only its working directory and grouping change.",
|
|
13
|
+
"switch.trash": "Session recovery",
|
|
14
|
+
"switch.trash.desc": "Shows the recovery entry in the session menu and on this page. Deleted sessions stay in the local recycle bin.",
|
|
15
|
+
"switch.search": "Ctrl+F content search",
|
|
16
|
+
"switch.search.desc": "Opens the search panel over any screen and matches session titles and message text.",
|
|
17
|
+
"switch.quote": "Quote selected text",
|
|
18
|
+
"switch.quote.desc": "Right-clicking a selection replaces the browser menu with Copy and Quote; quoting inserts the text into the composer.",
|
|
19
|
+
"switch.matchTitle": "Match session titles",
|
|
20
|
+
"switch.matchBody": "Match user and assistant messages",
|
|
21
|
+
"switch.matchTools": "Match tool output",
|
|
22
|
+
"field.maxMatches": "Match lines per session",
|
|
23
|
+
"field.retention": "Keep deleted sessions for (days)",
|
|
24
|
+
"field.retention.hint": "0 keeps them until you remove them by hand.",
|
|
25
|
+
"trash.usage": "{count} sessions, {size}",
|
|
26
|
+
"trash.clear": "Empty recycle bin",
|
|
27
|
+
"trash.cleared": "Recycle bin emptied.",
|
|
28
|
+
"delete.label": "Delete session",
|
|
29
|
+
"delete.running": "Delete session (running)",
|
|
30
|
+
"delete.title": "Delete this session?",
|
|
31
|
+
"delete.desc": "The local session directory, its projection cache shard, and its workspace reference are removed. The session stays recoverable in the recycle bin until it expires.",
|
|
32
|
+
"delete.confirm": "Delete",
|
|
33
|
+
"delete.done": "\"{title}\" was deleted. You can recover it from Session recovery.",
|
|
34
|
+
"delete.blocked": "A running session cannot be deleted. Stop it first.",
|
|
35
|
+
"move.label": "Move to workspace…",
|
|
36
|
+
"move.title": "Move to workspace",
|
|
37
|
+
"move.desc": "Moves the session into the target workspace in place: the session itself is unchanged, only its working directory becomes the target. The app restarts afterwards to apply the new grouping.",
|
|
38
|
+
"move.empty": "No other workspace is available.",
|
|
39
|
+
"move.confirm": "Move",
|
|
40
|
+
"move.done": "Moved to \"{title}\".",
|
|
41
|
+
"quote.copy": "Copy",
|
|
42
|
+
"quote.label": "Quote",
|
|
43
|
+
"quote.copied": "Copied.",
|
|
44
|
+
"quote.empty": "Nothing is selected.",
|
|
45
|
+
"quote.noInput": "The composer is not ready yet.",
|
|
46
|
+
"quote.failed": "Quote failed.",
|
|
47
|
+
"trash.title": "Session deletions",
|
|
48
|
+
"trash.desc": "Sessions deleted in this workspace. Restore one, or remove it permanently.",
|
|
49
|
+
"trash.empty": "No deleted sessions.",
|
|
50
|
+
"trash.restore": "Restore",
|
|
51
|
+
"trash.purge": "Delete permanently",
|
|
52
|
+
"trash.restored": "\"{title}\" was restored.",
|
|
53
|
+
"trash.purged": "\"{title}\" was deleted permanently.",
|
|
54
|
+
"trash.workspaceGone": "The workspace is gone; records for it were removed.",
|
|
55
|
+
"search.placeholder": "Search session titles and content",
|
|
56
|
+
"search.empty": "No matches.",
|
|
57
|
+
"search.hint": "Type to search every session. Enter opens the highlighted result.",
|
|
58
|
+
"search.loading": "Searching…",
|
|
59
|
+
"search.error": "Search failed: {message}",
|
|
60
|
+
"search.meta": "{count} sessions, {matches} matches",
|
|
61
|
+
"search.titleMatch": "Title",
|
|
62
|
+
"search.cancelled": "Search cancelled.",
|
|
63
|
+
"search.close": "Close search",
|
|
64
|
+
"common.close": "Close",
|
|
65
|
+
"common.cancel": "Cancel",
|
|
66
|
+
"common.confirm": "Confirm",
|
|
67
|
+
"common.retry": "Retry"
|
|
68
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "DSH增强",
|
|
4
|
+
"description": "多设备会话同步(WebDAV / 共享目录):会话、工作区、附件与配置双向流转;并提供会话删除与找回、跨工作区移动、全库内容搜索。"
|
|
5
|
+
},
|
|
6
|
+
"nav.title": "DSH增强",
|
|
7
|
+
"section.title": "DSH增强",
|
|
8
|
+
"section.desc": "会话同步、会话管理与全库搜索。同步会把会话、工作区、附件与配置上传到你指定的云端目录。",
|
|
9
|
+
"switch.delete": "会话删除",
|
|
10
|
+
"switch.delete.desc": "在会话菜单中加入“删除会话”。运行中的会话不可删除。",
|
|
11
|
+
"switch.move": "会话移动",
|
|
12
|
+
"switch.move.desc": "在会话菜单中加入“移动到工作区”。会话本身保持不变,只改写工作目录并重新归组。",
|
|
13
|
+
"switch.quote": "文字引用",
|
|
14
|
+
"switch.quote.desc": "选中文字后右键,用“复制、引用”菜单替换浏览器菜单;引用会把文字插入输入框。",
|
|
15
|
+
"switch.trash": "会话找回",
|
|
16
|
+
"switch.trash.desc": "在会话菜单和本页显示会话找回入口,已删除会话保留在本机回收站。",
|
|
17
|
+
"switch.search": "Ctrl+F 内容搜索",
|
|
18
|
+
"switch.search.desc": "在任意界面按 Ctrl+F 打开搜索面板,匹配会话标题与消息正文。",
|
|
19
|
+
"switch.matchTitle": "匹配会话标题",
|
|
20
|
+
"switch.matchBody": "匹配用户与助手消息",
|
|
21
|
+
"switch.matchTools": "匹配工具输出",
|
|
22
|
+
"field.maxMatches": "每会话匹配行数",
|
|
23
|
+
"field.retention": "已删除会话保留天数",
|
|
24
|
+
"field.retention.hint": "填0表示一直保留,直到手动永久删除。",
|
|
25
|
+
"trash.usage": "{count}个会话,占用{size}",
|
|
26
|
+
"trash.clear": "清空回收站",
|
|
27
|
+
"trash.cleared": "回收站已清空。",
|
|
28
|
+
"delete.label": "删除会话",
|
|
29
|
+
"delete.running": "删除会话(运行中)",
|
|
30
|
+
"delete.title": "删除这个会话?",
|
|
31
|
+
"delete.desc": "将同时删除本机会话目录、会话缓存分片,以及工作区中的引用。会话会保留在回收站中,直到超过保留期。",
|
|
32
|
+
"delete.confirm": "删除",
|
|
33
|
+
"delete.done": "“{title}”已删除,可在会话找回中恢复。",
|
|
34
|
+
"delete.blocked": "运行中的会话不可删除,请先停止运行。",
|
|
35
|
+
"move.label": "移动到工作区…",
|
|
36
|
+
"move.title": "移动到工作区",
|
|
37
|
+
"move.desc": "将该会话整体移入目标工作区:会话本身不变,只是工作目录改到目标目录。移动完成后会自动重启以应用新的分组。",
|
|
38
|
+
"move.empty": "没有其他工作区可移动。",
|
|
39
|
+
"move.confirm": "移动",
|
|
40
|
+
"move.done": "已移动到“{title}”。",
|
|
41
|
+
"quote.copy": "复制",
|
|
42
|
+
"quote.label": "引用",
|
|
43
|
+
"quote.copied": "已复制。",
|
|
44
|
+
"quote.empty": "没有选中内容。",
|
|
45
|
+
"quote.noInput": "输入框尚未就绪。",
|
|
46
|
+
"quote.failed": "引用失败。",
|
|
47
|
+
"trash.title": "删除会话管理",
|
|
48
|
+
"trash.desc": "本工作区中已删除的会话,可恢复或永久删除。",
|
|
49
|
+
"trash.empty": "暂无已删除的会话。",
|
|
50
|
+
"trash.restore": "恢复",
|
|
51
|
+
"trash.purge": "永久删除",
|
|
52
|
+
"trash.restored": "“{title}”已恢复。",
|
|
53
|
+
"trash.purged": "“{title}”已永久删除。",
|
|
54
|
+
"trash.workspaceGone": "原工作区已不存在,相关删除记录已清理。",
|
|
55
|
+
"search.placeholder": "搜索会话标题与内容",
|
|
56
|
+
"search.empty": "没有匹配结果。",
|
|
57
|
+
"search.hint": "输入关键词搜索全部会话。回车打开选中的结果。",
|
|
58
|
+
"search.loading": "正在搜索…",
|
|
59
|
+
"search.error": "搜索失败:{message}",
|
|
60
|
+
"search.meta": "{count}个会话,{matches}处匹配",
|
|
61
|
+
"search.titleMatch": "标题",
|
|
62
|
+
"search.cancelled": "搜索已取消。",
|
|
63
|
+
"search.close": "关闭搜索",
|
|
64
|
+
"common.close": "关闭",
|
|
65
|
+
"common.cancel": "取消",
|
|
66
|
+
"common.confirm": "确定",
|
|
67
|
+
"common.retry": "重试"
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsok/dsh-enhanced",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.2-10",
|
|
4
|
+
"description": "DeepSeek Harness 增强插件:会话删除与找回、跨工作区移动、全库内容搜索、自动加载历史,以及多设备同步(本地目录 / WebDAV)。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "xsok",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/xs-ok/dsh-enhanced.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/xs-ok/dsh-enhanced#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xs-ok/dsh-enhanced/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"plugin",
|
|
20
|
+
"session",
|
|
21
|
+
"sync",
|
|
22
|
+
"webdav",
|
|
23
|
+
"search"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"dsh": ">=0.2.2-rc.1"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./index.js",
|
|
30
|
+
"./client": "./client.js",
|
|
31
|
+
"./locale/*.json": "./locale/*.json",
|
|
32
|
+
"./icon": "./icon.svg"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"index.js",
|
|
36
|
+
"host/trash.js",
|
|
37
|
+
"host/search.js",
|
|
38
|
+
"host/move.js",
|
|
39
|
+
"host/sync.js",
|
|
40
|
+
"host/schedule.js",
|
|
41
|
+
"host/restart.js",
|
|
42
|
+
"host/overwrite.js",
|
|
43
|
+
"host/trashsync.js",
|
|
44
|
+
"host/webdav.js",
|
|
45
|
+
"host/mirror.js",
|
|
46
|
+
"client.js",
|
|
47
|
+
"cordis.patch.yml",
|
|
48
|
+
"locale/en.json",
|
|
49
|
+
"locale/zh.json",
|
|
50
|
+
"icon.svg",
|
|
51
|
+
"host/engine/index.js",
|
|
52
|
+
"host/engine/scan.js",
|
|
53
|
+
"host/engine/zstd.js",
|
|
54
|
+
"host/engine/session.js",
|
|
55
|
+
"host/engine/paths.js",
|
|
56
|
+
"host/engine/sessions.js",
|
|
57
|
+
"host/engine/workspace.js",
|
|
58
|
+
"host/engine/archive.js",
|
|
59
|
+
"host/engine/projcache.js",
|
|
60
|
+
"host/engine/config.js",
|
|
61
|
+
"host/engine/pluginlist.js",
|
|
62
|
+
"host/engine/attachments.js",
|
|
63
|
+
"host/engine/prune.js",
|
|
64
|
+
"host/engine/atomic.js",
|
|
65
|
+
"host/engine/ledger.js",
|
|
66
|
+
"host/envcheck.js",
|
|
67
|
+
"CHANGELOG.md"
|
|
68
|
+
],
|
|
69
|
+
"dsh": {
|
|
70
|
+
"bundle": {
|
|
71
|
+
"patch": "./cordis.patch.yml"
|
|
72
|
+
},
|
|
73
|
+
"client": {
|
|
74
|
+
"platform": "web",
|
|
75
|
+
"immediately": false,
|
|
76
|
+
"inject": [
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|