dsh-session-manager 0.7.3 → 0.7.5
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 +20 -0
- package/README.md +6 -5
- package/README.zh.md +5 -4
- package/lib/client.js +225 -27
- package/lib/compat/dsh-adapter.js +36 -2
- package/lib/index.js +584 -53
- package/package.json +1 -1
|
@@ -9,10 +9,36 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
-
import {
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { join, resolve } from "node:path";
|
|
13
14
|
|
|
14
15
|
const require = createRequire(import.meta.url);
|
|
15
16
|
|
|
17
|
+
/** Expand a leading `~` / `~/` / `~\` against the OS home, matching
|
|
18
|
+
* `@deepseek-ai/dsh-home-paths` `expandHomePath`. */
|
|
19
|
+
function expandHomePath(path) {
|
|
20
|
+
if (path === "~") return homedir();
|
|
21
|
+
if (path.startsWith("~/") || path.startsWith("~\\")) return join(homedir(), path.slice(2));
|
|
22
|
+
return path;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the DSH home without the `dshHomePath` service. DSH 0.2.x resolves
|
|
27
|
+
* the harness home exclusively through `resolveDshHome()`: `$DSH_HOME` when
|
|
28
|
+
* set and non-blank, otherwise `~/.dsh`; the value is tilde-expanded and
|
|
29
|
+
* resolved to an absolute path. Mirror that order so a plugin scope that
|
|
30
|
+
* cannot see the root-context service still lands on the same directory.
|
|
31
|
+
*/
|
|
32
|
+
function fallbackDshHome() {
|
|
33
|
+
const raw = typeof process.env.DSH_HOME === "string" ? process.env.DSH_HOME.trim() : "";
|
|
34
|
+
const selected = raw.length > 0 ? expandHomePath(raw) : join(homedir(), ".dsh");
|
|
35
|
+
return resolve(selected);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Same calling convention as the official `dshHomePath(...segments)`. */
|
|
39
|
+
function fallbackHomePath(...segments) {
|
|
40
|
+
return join(fallbackDshHome(), ...segments);
|
|
41
|
+
}
|
|
16
42
|
/** Pull one service out of the Cordis ctx, tolerating direct property fallbacks. */
|
|
17
43
|
export function getService(ctx, name) {
|
|
18
44
|
try {
|
|
@@ -157,7 +183,15 @@ export function createDshAdapter(ctx) {
|
|
|
157
183
|
get persistence() { return getService(ctx, "sessionPersistence"); },
|
|
158
184
|
get agentPresets() { return getService(ctx, "agentPresets"); },
|
|
159
185
|
get projectionCache() { return getService(ctx, "sessionProjectionCache"); },
|
|
160
|
-
get homePath() {
|
|
186
|
+
get homePath() {
|
|
187
|
+
// DSH 0.2.x provides `dshHomePath` on the root context (app-boot), but a
|
|
188
|
+
// plugin scope may not resolve it; without a fallback every disk-backed
|
|
189
|
+
// path (sessions scan, annotation store, workspace archive store) is
|
|
190
|
+
// lost. Fall back to the official home resolution instead.
|
|
191
|
+
const served = getService(ctx, "dshHomePath");
|
|
192
|
+
if (typeof served === "function") return served;
|
|
193
|
+
return fallbackHomePath;
|
|
194
|
+
},
|
|
161
195
|
get pluginManager() { return getService(ctx, "pluginManager"); },
|
|
162
196
|
|
|
163
197
|
getSession(id) {
|