dsh-plugin-standalone-session 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +238 -2
- package/cordis.patch.yml +6 -0
- package/icon.svg +5 -0
- package/lib/client.js +1969 -0
- package/lib/index.js +545 -0
- package/lib/types/client/actions.d.ts +40 -0
- package/lib/types/client/adapters.d.ts +9 -0
- package/lib/types/client/components.d.ts +55 -0
- package/lib/types/client/create.d.ts +33 -0
- package/lib/types/client/dsh.d.ts +167 -0
- package/lib/types/client/format.d.ts +10 -0
- package/lib/types/client/hooks.d.ts +31 -0
- package/lib/types/client/index.d.ts +18 -0
- package/lib/types/client/launcher.d.ts +39 -0
- package/lib/types/client/locales.d.ts +9 -0
- package/lib/types/client/notice.d.ts +23 -0
- package/lib/types/client/panels.d.ts +3 -0
- package/lib/types/client/styles.d.ts +10 -0
- package/lib/types/host/registry.d.ts +124 -0
- package/lib/types/index.d.ts +37 -0
- package/lib/types/shared/standalone.d.ts +184 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +83 -4
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, platform-neutral rules shared by the host half, the browser half and
|
|
3
|
+
* the tests. Nothing here touches `node:fs`, the DSH runtime or the DOM.
|
|
4
|
+
*
|
|
5
|
+
* The durable standalone marker is the session's own working directory: the
|
|
6
|
+
* host and the browser both mint and recognize
|
|
7
|
+
* `<DSH_HOME>/dsh-standalone-sessions/<sessionId>`. A host-owned JSON registry
|
|
8
|
+
* records richer lifecycle facts (first user message, cleanup state), but the
|
|
9
|
+
* browser never depends on reading that file: the session's durable `cwd`
|
|
10
|
+
* already carries the marker across restarts.
|
|
11
|
+
*/
|
|
12
|
+
/** Directory under the DSH home that owns every standalone session cwd. */
|
|
13
|
+
export declare const STANDALONE_DIR_NAME = "dsh-standalone-sessions";
|
|
14
|
+
/** Prefix for every session identity this plugin mints. */
|
|
15
|
+
export declare const SESSION_ID_PREFIX = "session-";
|
|
16
|
+
/** Schema version of the host-owned registry file. */
|
|
17
|
+
export declare const REGISTRY_VERSION: 1;
|
|
18
|
+
/** Name of the host-owned registry file inside the standalone root. */
|
|
19
|
+
export declare const REGISTRY_FILE_NAME = "registry.json";
|
|
20
|
+
/** One durable standalone-session record. */
|
|
21
|
+
export interface StandaloneEntry {
|
|
22
|
+
readonly sessionId: string;
|
|
23
|
+
readonly cwd: string;
|
|
24
|
+
/** Durable marker; never inferred from a missing workspace id. */
|
|
25
|
+
readonly standalone: true;
|
|
26
|
+
readonly createdAt: number;
|
|
27
|
+
/** Whether a user-authored durable message was ever observed. */
|
|
28
|
+
readonly hadMessage: boolean;
|
|
29
|
+
/** Set once the session is archived (the native delete gesture). */
|
|
30
|
+
readonly archived?: boolean;
|
|
31
|
+
/** Set when the host could not remove the session directory. */
|
|
32
|
+
readonly cleanupFailed?: boolean;
|
|
33
|
+
readonly cleanupError?: string;
|
|
34
|
+
readonly cleanedAt?: number;
|
|
35
|
+
}
|
|
36
|
+
/** The complete registry payload written to disk. */
|
|
37
|
+
export interface StandaloneRegistryData {
|
|
38
|
+
readonly version: typeof REGISTRY_VERSION;
|
|
39
|
+
readonly sessions: Readonly<Record<string, StandaloneEntry>>;
|
|
40
|
+
}
|
|
41
|
+
/** A cleanup decision derived from a record and the directory's live state. */
|
|
42
|
+
export type CleanupPlan = {
|
|
43
|
+
readonly action: 'remove-entry';
|
|
44
|
+
readonly reason: 'missing';
|
|
45
|
+
} | {
|
|
46
|
+
readonly action: 'remove-tree';
|
|
47
|
+
readonly reason: 'never-used';
|
|
48
|
+
} | {
|
|
49
|
+
readonly action: 'keep';
|
|
50
|
+
readonly reason: 'used' | 'not-empty';
|
|
51
|
+
};
|
|
52
|
+
/** Injectable random UUID source used by tests. */
|
|
53
|
+
export type UuidSource = () => string;
|
|
54
|
+
/** An empty registry payload. */
|
|
55
|
+
export declare function emptyRegistry(): StandaloneRegistryData;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a session cwd carries this plugin's standalone marker segment with a
|
|
58
|
+
* session child below it. The comparison is case-insensitive so a shared home
|
|
59
|
+
* path mounted with different casing still classifies correctly.
|
|
60
|
+
* @param cwd - session working directory, if any.
|
|
61
|
+
* @returns whether the cwd lives below a `dsh-standalone-sessions` directory.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isStandaloneCwd(cwd: string | undefined | null): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The final path segment of a standalone cwd, when the cwd is one.
|
|
66
|
+
* @param cwd - session working directory.
|
|
67
|
+
* @returns the segment below the standalone root, or undefined.
|
|
68
|
+
*/
|
|
69
|
+
export declare function standaloneSessionIdFromCwd(cwd: string | undefined | null): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Join path segments with the separator family the base path already uses.
|
|
72
|
+
* Kept browser-safe: no `node:path` import.
|
|
73
|
+
* @param base - absolute base path.
|
|
74
|
+
* @param segments - child names; traversal segments are rejected.
|
|
75
|
+
* @returns the joined path.
|
|
76
|
+
*/
|
|
77
|
+
export declare function joinPath(base: string, ...segments: string[]): string;
|
|
78
|
+
/**
|
|
79
|
+
* Default root for standalone session directories under an OS home.
|
|
80
|
+
* @param home - host user home directory.
|
|
81
|
+
* @returns `<home>/.dsh/dsh-standalone-sessions`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function defaultStandaloneRoot(home: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Mint one standalone session cwd.
|
|
86
|
+
* @param home - host user home directory.
|
|
87
|
+
* @param sessionId - the pre-minted session identity.
|
|
88
|
+
* @returns the session directory below the default standalone root.
|
|
89
|
+
*/
|
|
90
|
+
export declare function makeStandaloneCwd(home: string, sessionId: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Reject ids that could escape the standalone root when used as a directory.
|
|
93
|
+
* @param sessionId - candidate identity.
|
|
94
|
+
* @returns the identity, typed as a plain string.
|
|
95
|
+
*/
|
|
96
|
+
export declare function assertSessionId(sessionId: unknown): string;
|
|
97
|
+
/**
|
|
98
|
+
* One RFC 4122 version-4 UUID, with a non-cryptographic fallback for hosts
|
|
99
|
+
* without `crypto.randomUUID` (the identity is a directory name, not a secret).
|
|
100
|
+
* @returns a lowercase UUID string.
|
|
101
|
+
*/
|
|
102
|
+
export declare function randomUuid(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Mint a DSH-shaped session identity.
|
|
105
|
+
* @param uuidSource - UUID source, injectable for deterministic tests.
|
|
106
|
+
* @returns `session-<uuid>`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mintSessionId(uuidSource?: UuidSource): string;
|
|
109
|
+
/**
|
|
110
|
+
* Validate and normalize an unknown on-disk registry payload. Malformed entries
|
|
111
|
+
* are dropped rather than repaired into a wrong directory.
|
|
112
|
+
* @param value - parsed JSON value.
|
|
113
|
+
* @returns a complete registry payload.
|
|
114
|
+
*/
|
|
115
|
+
export declare function normalizeRegistry(value: unknown): StandaloneRegistryData;
|
|
116
|
+
/**
|
|
117
|
+
* Insert or refresh one session record. An existing record keeps the original
|
|
118
|
+
* creation time and its first-message fact; the cwd always follows the observed
|
|
119
|
+
* session header so a moved home cannot leave a stale cleanup target.
|
|
120
|
+
* @param data - current registry.
|
|
121
|
+
* @param entry - observed standalone session.
|
|
122
|
+
* @returns the next registry (a new object).
|
|
123
|
+
*/
|
|
124
|
+
export declare function upsertEntry(data: StandaloneRegistryData, entry: StandaloneEntry): StandaloneRegistryData;
|
|
125
|
+
/**
|
|
126
|
+
* Mark one record as having observed a user-authored durable message.
|
|
127
|
+
* @param data - current registry.
|
|
128
|
+
* @param sessionId - session identity.
|
|
129
|
+
* @returns the next registry, or the same reference when nothing changed.
|
|
130
|
+
*/
|
|
131
|
+
export declare function markHadMessage(data: StandaloneRegistryData, sessionId: string): StandaloneRegistryData;
|
|
132
|
+
/**
|
|
133
|
+
* Record an archive observation without losing the cleanup target.
|
|
134
|
+
* @param data - current registry.
|
|
135
|
+
* @param sessionId - session identity.
|
|
136
|
+
* @returns the next registry, or the same reference when nothing changed.
|
|
137
|
+
*/
|
|
138
|
+
export declare function markArchived(data: StandaloneRegistryData, sessionId: string): StandaloneRegistryData;
|
|
139
|
+
/**
|
|
140
|
+
* Drop one record after its directory cleanup succeeded.
|
|
141
|
+
* @param data - current registry.
|
|
142
|
+
* @param sessionId - session identity.
|
|
143
|
+
* @returns the next registry, or the same reference when absent.
|
|
144
|
+
*/
|
|
145
|
+
export declare function removeEntry(data: StandaloneRegistryData, sessionId: string): StandaloneRegistryData;
|
|
146
|
+
/**
|
|
147
|
+
* Record a failed cleanup so a later sweep can retry and operators can see why.
|
|
148
|
+
* @param data - current registry.
|
|
149
|
+
* @param sessionId - session identity.
|
|
150
|
+
* @param message - diagnostic text.
|
|
151
|
+
* @returns the next registry.
|
|
152
|
+
*/
|
|
153
|
+
export declare function markCleanupFailed(data: StandaloneRegistryData, sessionId: string, message: string): StandaloneRegistryData;
|
|
154
|
+
/** All records in stable id order. */
|
|
155
|
+
export declare function listEntries(data: StandaloneRegistryData): StandaloneEntry[];
|
|
156
|
+
/**
|
|
157
|
+
* Decide what a deletion may remove. A session that never carried a user
|
|
158
|
+
* message owns its directory completely; one that did keeps its directory so
|
|
159
|
+
* an unarchive can still resume in the recorded cwd.
|
|
160
|
+
* @param entry - registry record.
|
|
161
|
+
* @param directoryState - live directory facts.
|
|
162
|
+
* @returns the cleanup plan.
|
|
163
|
+
*/
|
|
164
|
+
export declare function cleanupPlan(entry: StandaloneEntry, directoryState: {
|
|
165
|
+
readonly exists: boolean;
|
|
166
|
+
readonly empty: boolean;
|
|
167
|
+
}): CleanupPlan;
|
|
168
|
+
/**
|
|
169
|
+
* Whether a composer render should be unlocked for one standalone session.
|
|
170
|
+
* The native InputBar disables itself when a session has no workspace; this
|
|
171
|
+
* plugin's standalone sessions are exactly that state.
|
|
172
|
+
* @param sessionId - rendered session (undefined on the New Session page).
|
|
173
|
+
* @param cwd - that session's durable working directory.
|
|
174
|
+
* @param disabled - the native composer's inert flag.
|
|
175
|
+
* @returns whether the override applies.
|
|
176
|
+
*/
|
|
177
|
+
export declare function shouldUnlockComposer(sessionId: string | undefined, cwd: string | undefined, disabled: boolean): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Stable, human-readable relative time for panel rows.
|
|
180
|
+
* @param timestamp - epoch milliseconds; non-finite values return an empty string.
|
|
181
|
+
* @param now - comparison instant.
|
|
182
|
+
* @returns a short relative label.
|
|
183
|
+
*/
|
|
184
|
+
export declare function relativeTime(timestamp: number, now?: number): string;
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-standalone-session",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"displayName": "Standalone Session",
|
|
5
|
+
"description": "Create and manage standalone DSH sessions that are not attached to any workspace.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./lib/types/client/index.d.ts",
|
|
15
|
+
"default": "./lib/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
18
|
+
"./locale/*.json": "./locale/*.json",
|
|
19
|
+
"./icon": "./icon.svg",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib",
|
|
24
|
+
"locale",
|
|
25
|
+
"cordis.patch.yml",
|
|
26
|
+
"icon.svg",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"icon": "./icon.svg",
|
|
31
|
+
"dsh": {
|
|
32
|
+
"bundle": {
|
|
33
|
+
"patch": "./cordis.patch.yml"
|
|
34
|
+
},
|
|
35
|
+
"client": {
|
|
36
|
+
"platform": "web",
|
|
37
|
+
"immediately": true,
|
|
38
|
+
"inject": [
|
|
39
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
40
|
+
"@deepseek-ai/dsh-api-workspace-controller",
|
|
41
|
+
"@deepseek-ai/dsh-client-locale",
|
|
42
|
+
"@deepseek-ai/dsh-client-ui-commands",
|
|
43
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
44
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"dsh": ">=0.2.1-rc.2 <0.3.0-0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "node scripts/build.mjs && tsc -p tsconfig.build.json",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"check": "npm run typecheck && npm run build && npm run test",
|
|
58
|
+
"prepack": "npm run build"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"dsh",
|
|
62
|
+
"dsh-plugin",
|
|
63
|
+
"deepseek-harness",
|
|
64
|
+
"cordis-plugin",
|
|
65
|
+
"standalone-session",
|
|
66
|
+
"no-workspace"
|
|
67
|
+
],
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/node": "^22.15.0",
|
|
71
|
+
"@types/react": "^18.3.18",
|
|
72
|
+
"esbuild": "^0.28.2",
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"typescript": "~5.9.3",
|
|
75
|
+
"vitest": "^3.2.4"
|
|
76
|
+
},
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "git+https://github.com/LRainner/dsh-plugin-standalone-session.git"
|
|
80
|
+
},
|
|
81
|
+
"homepage": "https://github.com/LRainner/dsh-plugin-standalone-session#readme",
|
|
82
|
+
"bugs": {
|
|
83
|
+
"url": "https://github.com/LRainner/dsh-plugin-standalone-session/issues"
|
|
84
|
+
}
|
|
85
|
+
}
|