@ddtcorex/dsh-maestro-core 0.13.0 → 0.15.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/README.md +3 -3
- package/lib/client.js +4 -125
- package/lib/debug-agent.d.ts +7 -0
- package/lib/debug-agent.js +15 -5
- package/lib/dsh-launch.d.ts +26 -0
- package/lib/dsh-launch.js +27 -0
- package/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +17 -4
- package/lib/restart-tool.d.ts +3 -1
- package/lib/restart-tool.js +8 -4
- package/lib/restart-web.d.ts +3 -0
- package/lib/restart-web.js +7 -3
- package/lib/resume.js +9 -1
- package/lib/sync/backup-service.d.ts +13 -0
- package/lib/sync/backup-service.js +60 -14
- package/lib/sync/hashing.d.ts +13 -0
- package/lib/sync/hashing.js +30 -0
- package/lib/sync/merge.d.ts +1 -1
- package/lib/sync/merge.js +1 -1
- package/lib/sync/remote-agent.js +12 -1
- package/lib/sync/remote-cache.js +1 -1
- package/lib/sync/remote-manifest.d.ts +25 -0
- package/lib/sync/remote-manifest.js +49 -2
- package/lib/sync/store-root.d.ts +44 -0
- package/lib/sync/store-root.js +67 -0
- package/lib/sync/sync-service.d.ts +25 -1
- package/lib/sync/sync-service.js +117 -12
- package/lib/sync/sync-types.d.ts +1 -1
- package/lib/sync/validation.d.ts +2 -0
- package/lib/sync/validation.js +15 -2
- package/lib/types/client/config/components/BrandMark.d.ts +1 -1
- package/lib/types/client/config/components/BrandMark.d.ts.map +1 -1
- package/lib/types/client/config/index.d.ts +0 -1
- package/lib/types/client/config/index.d.ts.map +1 -1
- package/lib/types/client/config/maestro-mark.d.ts +6 -16
- package/lib/types/client/config/maestro-mark.d.ts.map +1 -1
- package/lib/types/client/sync/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/dsh-safe-restart/SKILL.md +4 -3
- package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +20 -36
- package/src/client/config/components/BrandMark.tsx +0 -1
- package/src/client/config/index.tsx +5 -44
- package/src/client/config/maestro-mark.ts +6 -23
- package/src/client/sync/index.tsx +0 -50
- package/src/client/sync/ui.tsx +4 -4
- package/src/host/debug-agent.ts +17 -8
- package/src/host/dsh-launch.ts +48 -0
- package/src/host/plugin.ts +19 -5
- package/src/host/restart-tool.ts +8 -4
- package/src/host/restart-web.ts +8 -6
- package/src/host/resume.ts +10 -1
- package/src/host/sync/backup-service.ts +67 -14
- package/src/host/sync/hashing.ts +34 -1
- package/src/host/sync/merge.ts +1 -1
- package/src/host/sync/remote-agent.ts +12 -1
- package/src/host/sync/remote-cache.ts +1 -1
- package/src/host/sync/remote-manifest.ts +49 -2
- package/src/host/sync/store-root.ts +83 -0
- package/src/host/sync/sync-service.ts +131 -12
- package/src/host/sync/sync-types.ts +1 -1
- package/src/host/sync/validation.ts +15 -2
- package/systemd/dsh-web-supervisor.service.template +2 -0
- package/systemd/dsh-web.service.template +8 -2
- package/lib/types/client/config/settings-nav-icon.d.ts +0 -21
- package/lib/types/client/config/settings-nav-icon.d.ts.map +0 -1
- package/src/client/config/settings-nav-icon.ts +0 -68
package/lib/sync/sync-service.js
CHANGED
|
@@ -18,9 +18,15 @@ import * as path from 'node:path';
|
|
|
18
18
|
import * as os from 'node:os';
|
|
19
19
|
import { randomBytes } from 'node:crypto';
|
|
20
20
|
import { mergeDelimited } from './merge.js';
|
|
21
|
+
/**
|
|
22
|
+
* Hash a mixed list of wire paths, each group against the root it lives under.
|
|
23
|
+
* Before the store moved, one root covered everything; it no longer does, and hashing
|
|
24
|
+
* `maestro-memory/...` under the DSH home fails with ENOENT on the first memory file.
|
|
25
|
+
*/
|
|
26
|
+
import { localPathForWirePath, resolveStoreRoot } from './store-root.js';
|
|
21
27
|
import { mergeSessionBuffers } from './session-plan.js';
|
|
22
28
|
import { kindForPath } from './snapshot.js';
|
|
23
|
-
import {
|
|
29
|
+
import { hashWirePaths } from './hashing.js';
|
|
24
30
|
import { loadIndex, saveIndex, probeIndex, matchesStat, statFingerprint } from './fingerprint.js';
|
|
25
31
|
import { buildPlan, buildPreview, getPreview, getPreviewDirection, deletePreview, storePreview } from './sync-plan.js';
|
|
26
32
|
import { normalizeEligiblePath, validateRemoteTarget, validateHost } from './validation.js';
|
|
@@ -31,6 +37,7 @@ function syncFailure(phase, code, detail, path) {
|
|
|
31
37
|
}
|
|
32
38
|
export class SyncService {
|
|
33
39
|
localDsh;
|
|
40
|
+
storeRoot;
|
|
34
41
|
remote;
|
|
35
42
|
remoteDsh;
|
|
36
43
|
previewDir;
|
|
@@ -40,6 +47,14 @@ export class SyncService {
|
|
|
40
47
|
transport;
|
|
41
48
|
constructor(opts = {}) {
|
|
42
49
|
this.localDsh = opts.localDsh || process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
|
|
50
|
+
// The store can live outside the DSH home. Wire paths stay `maestro-memory/...`,
|
|
51
|
+
// so every site that touches disk maps through this root, never through localDsh.
|
|
52
|
+
// A caller that pins `localDsh` pins the whole machine state, so the store is
|
|
53
|
+
// resolved against it: a temp home is isolated by construction, and production's
|
|
54
|
+
// own home is not, which is exactly the plugin's rule.
|
|
55
|
+
this.storeRoot =
|
|
56
|
+
opts.storeRoot ??
|
|
57
|
+
resolveStoreRoot({ env: { ...process.env, DSH_HOME: opts.localDsh ?? process.env.DSH_HOME } }).root;
|
|
43
58
|
this.remote = opts.remote || process.env.REMOTE_HOST || process.env.REMOTE || 'kai@ssh.ddtcorex.com';
|
|
44
59
|
this.remoteDsh = opts.remoteDsh || process.env.REMOTE_DSH_PATH || '~/.dsh';
|
|
45
60
|
// Sidecar preview store shared by every CLI process (preview -> separate apply run).
|
|
@@ -99,12 +114,24 @@ export class SyncService {
|
|
|
99
114
|
return connection;
|
|
100
115
|
}
|
|
101
116
|
/**
|
|
102
|
-
* Local eligible files (
|
|
117
|
+
* Local eligible files (maestro-memory/*.md, maestro-memory/SUGGESTIONS.jsonl,
|
|
103
118
|
* sessions/<cwd-hash>/<id>/session.jsonl.zstd) as relative paths, sorted.
|
|
104
119
|
* Only content that matches the eligible contract is ever read or hashed.
|
|
105
120
|
*/
|
|
121
|
+
/** The two roots a wire path can resolve to. */
|
|
122
|
+
hashRoots() {
|
|
123
|
+
return { storeRoot: this.storeRoot, localDsh: this.localDsh };
|
|
124
|
+
}
|
|
125
|
+
/** Map a wire path to its local file, through the resolved store root. */
|
|
126
|
+
localPathForWirePath(wirePath) {
|
|
127
|
+
return localPathForWirePath(wirePath, { storeRoot: this.storeRoot, localDsh: this.localDsh });
|
|
128
|
+
}
|
|
106
129
|
listLocalFiles() {
|
|
107
130
|
const root = this.localDsh;
|
|
131
|
+
// The store may live outside the DSH home, so its files are collected from the
|
|
132
|
+
// resolved root and labelled with the wire prefix. Sessions stay under the DSH
|
|
133
|
+
// home; they are harness data by definition.
|
|
134
|
+
const storeRootDiffers = this.storeRoot !== path.join(this.localDsh, 'maestro-memory');
|
|
108
135
|
const result = [];
|
|
109
136
|
const fsMod = this.fs;
|
|
110
137
|
const walk = (dir, base) => {
|
|
@@ -152,7 +179,26 @@ export class SyncService {
|
|
|
152
179
|
catch {
|
|
153
180
|
return [];
|
|
154
181
|
}
|
|
155
|
-
|
|
182
|
+
if (!storeRootDiffers) {
|
|
183
|
+
// Store inside the DSH home: one walk covers everything, exactly as before.
|
|
184
|
+
walk(root, '');
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// Store elsewhere: walk the DSH home for sessions and harness state, skipping the
|
|
188
|
+
// path the store would occupy, then walk the store itself under its wire prefix.
|
|
189
|
+
const harnessOwned = [];
|
|
190
|
+
const push = result.push.bind(result);
|
|
191
|
+
result.push = (...items) => harnessOwned.push(...items);
|
|
192
|
+
walk(root, '');
|
|
193
|
+
result.push = push;
|
|
194
|
+
for (const wire of harnessOwned) {
|
|
195
|
+
const normalised = wire.split(path.sep).join('/');
|
|
196
|
+
if (normalised === 'maestro-memory' || normalised.startsWith('maestro-memory/'))
|
|
197
|
+
continue;
|
|
198
|
+
result.push(wire);
|
|
199
|
+
}
|
|
200
|
+
walk(this.storeRoot, 'maestro-memory');
|
|
201
|
+
}
|
|
156
202
|
return [...new Set(result
|
|
157
203
|
.map((p) => p.split(path.sep).join('/'))
|
|
158
204
|
.filter((p) => {
|
|
@@ -178,7 +224,65 @@ export class SyncService {
|
|
|
178
224
|
* re-hashed at write time (see apply), so a stale cache can never publish a
|
|
179
225
|
* wrong mutation target.
|
|
180
226
|
*/
|
|
227
|
+
/**
|
|
228
|
+
* The 4.0 rename moved the store root. A machine still on the old root would
|
|
229
|
+
* inventory zero memory files, which reads exactly like "nothing to sync".
|
|
230
|
+
* Refuse instead: the marker is written by the plugin's boot migration.
|
|
231
|
+
*/
|
|
232
|
+
assertLocalStoreMigrated() {
|
|
233
|
+
const probe = this.fs?.existsSync;
|
|
234
|
+
if (typeof probe !== 'function')
|
|
235
|
+
return;
|
|
236
|
+
const current = this.storeRoot;
|
|
237
|
+
const legacy = path.join(this.localDsh, 'dsh-maestro-memory');
|
|
238
|
+
const v4 = path.join(this.localDsh, 'maestro-memory');
|
|
239
|
+
let currentExists = false;
|
|
240
|
+
let legacyExists = false;
|
|
241
|
+
try {
|
|
242
|
+
currentExists = probe.call(this.fs, current);
|
|
243
|
+
legacyExists = probe.call(this.fs, legacy);
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// Only the half-migrated shape is refused: the old root is still there and
|
|
249
|
+
// the new one is absent. A fresh DSH_HOME has neither, and a migrated one
|
|
250
|
+
// has the new root, so both stay usable.
|
|
251
|
+
// A store still at a legacy root would inventory zero files through the new root,
|
|
252
|
+
// which reads exactly like "nothing to sync". Refuse instead.
|
|
253
|
+
let v4Exists = false;
|
|
254
|
+
try {
|
|
255
|
+
v4Exists = current !== v4 && probe.call(this.fs, v4);
|
|
256
|
+
}
|
|
257
|
+
catch { }
|
|
258
|
+
if (!currentExists && legacyExists) {
|
|
259
|
+
throw syncFailure('snapshot', 'STORE_NOT_MIGRATED', `local store is still at ${legacy}; run the current build on this machine (its boot migration moves it) before syncing`);
|
|
260
|
+
}
|
|
261
|
+
if (!currentExists && v4Exists) {
|
|
262
|
+
throw syncFailure('snapshot', 'STORE_NOT_MIGRATED', `local store is still at ${v4}; install the current build (its boot migration moves it to ${current}) before syncing`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Refuse a peer that still keeps its store inside the DSH home.
|
|
267
|
+
*
|
|
268
|
+
* The wire paths are the same on both sides, so a mixed pair writes into a directory
|
|
269
|
+
* the upgraded machine no longer reads: the transfer succeeds and the memories are
|
|
270
|
+
* invisible. The marker is the only signal available before the transfer starts.
|
|
271
|
+
*/
|
|
272
|
+
assertPeerMoved(remotePaths) {
|
|
273
|
+
// Only meaningful once this machine has moved: while our own store still sits inside
|
|
274
|
+
// the DSH home, the peer's layout is the one that matches and there is nothing to
|
|
275
|
+
// protect against.
|
|
276
|
+
if (this.storeRoot === path.join(this.localDsh, 'maestro-memory'))
|
|
277
|
+
return;
|
|
278
|
+
const hasMemory = remotePaths.some((p) => p.startsWith('maestro-memory/'));
|
|
279
|
+
const hasMarker = remotePaths.includes('maestro-memory/.maestro-memory/migrated-v5.json');
|
|
280
|
+
if (hasMemory && !hasMarker) {
|
|
281
|
+
throw syncFailure('snapshot', 'PEER_NOT_MOVED', `the peer ${this.remote ?? 'unknown'} still keeps its store inside its DSH home (memory files present, no migrated-v5.json marker); upgrade maestro-memory on that machine and restart it before syncing`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
181
284
|
async snapshotBoth(opts = {}) {
|
|
285
|
+
this.assertLocalStoreMigrated();
|
|
182
286
|
const progress = (phase, current, total, file) => opts.onProgress?.({ phase, current, total, file });
|
|
183
287
|
const stop = () => {
|
|
184
288
|
if (opts.shouldStop?.())
|
|
@@ -188,11 +292,12 @@ export class SyncService {
|
|
|
188
292
|
const fsMod = this.fs;
|
|
189
293
|
const target = await this.requireTarget();
|
|
190
294
|
stop();
|
|
191
|
-
// Scope filter: 'memory' covers
|
|
295
|
+
// Scope filter: 'memory' covers maestro-memory only and skips the
|
|
192
296
|
// live session logs; undefined/'all' preserves the legacy full inventory.
|
|
193
297
|
const inScope = (p) => opts.scope !== 'memory' || !p.startsWith('sessions/');
|
|
194
298
|
const localPaths = this.listLocalFiles().filter(inScope);
|
|
195
299
|
const remoteManifest = (await this.transport.manifest(target)).filter((e) => inScope(e.path));
|
|
300
|
+
this.assertPeerMoved(remoteManifest.map((e) => e.path));
|
|
196
301
|
stop();
|
|
197
302
|
const remoteSnapshots = remoteManifest.map((e) => ({ path: e.path, sha256: e.sha256, size: e.size, kind: kindForPath(e.path) }));
|
|
198
303
|
const remoteSet = new Set(remoteManifest.map((e) => e.path));
|
|
@@ -204,7 +309,7 @@ export class SyncService {
|
|
|
204
309
|
const entry = probeIndex(p, index);
|
|
205
310
|
let st = null;
|
|
206
311
|
try {
|
|
207
|
-
st = typeof fsMod.statSync === 'function' ? fsMod.statSync(
|
|
312
|
+
st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(p), { bigint: true }) : null;
|
|
208
313
|
}
|
|
209
314
|
catch {
|
|
210
315
|
st = null;
|
|
@@ -217,7 +322,7 @@ export class SyncService {
|
|
|
217
322
|
}
|
|
218
323
|
}
|
|
219
324
|
let hashedCount = 0;
|
|
220
|
-
const staleHashes = await
|
|
325
|
+
const staleHashes = await hashWirePaths(fsMod, this.hashRoots(), stale, {
|
|
221
326
|
onFile: (h) => {
|
|
222
327
|
hashedCount++;
|
|
223
328
|
progress('hashing', hashedCount, stale.length, h.path);
|
|
@@ -227,7 +332,7 @@ export class SyncService {
|
|
|
227
332
|
for (const h of staleHashes) {
|
|
228
333
|
localSnapshots.push({ path: h.path, sha256: h.sha256, size: h.size, kind: kindForPath(h.path) });
|
|
229
334
|
try {
|
|
230
|
-
const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(
|
|
335
|
+
const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(h.path), { bigint: true }) : null;
|
|
231
336
|
if (st)
|
|
232
337
|
index.entries[h.path] = { ...statFingerprint(st), sha256: h.sha256 };
|
|
233
338
|
}
|
|
@@ -256,7 +361,7 @@ export class SyncService {
|
|
|
256
361
|
if (localContents.has(rel))
|
|
257
362
|
return localContents.get(rel);
|
|
258
363
|
try {
|
|
259
|
-
const d = fsMod.readFileSync(
|
|
364
|
+
const d = fsMod.readFileSync(this.localPathForWirePath(rel));
|
|
260
365
|
const buf = Buffer.isBuffer(d) ? Buffer.from(d) : Buffer.from(String(d), 'utf-8');
|
|
261
366
|
localContents.set(rel, buf);
|
|
262
367
|
return buf;
|
|
@@ -568,7 +673,7 @@ export class SyncService {
|
|
|
568
673
|
else {
|
|
569
674
|
buf = this.mergeBuffer(act, localContents, remoteContents, 'pull');
|
|
570
675
|
}
|
|
571
|
-
await this.atomicWriteWithBackup(
|
|
676
|
+
await this.atomicWriteWithBackup(this.localPathForWirePath(act.path), buf);
|
|
572
677
|
committed.push(act.path);
|
|
573
678
|
}
|
|
574
679
|
catch (e) {
|
|
@@ -702,7 +807,7 @@ export class SyncService {
|
|
|
702
807
|
const entry = probeIndex(p, index);
|
|
703
808
|
let st = null;
|
|
704
809
|
try {
|
|
705
|
-
st = typeof fsMod.statSync === 'function' ? fsMod.statSync(
|
|
810
|
+
st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(p), { bigint: true }) : null;
|
|
706
811
|
}
|
|
707
812
|
catch {
|
|
708
813
|
st = null;
|
|
@@ -714,7 +819,7 @@ export class SyncService {
|
|
|
714
819
|
}
|
|
715
820
|
if (stale.length > 0) {
|
|
716
821
|
let i = 0;
|
|
717
|
-
const hashed = await
|
|
822
|
+
const hashed = await hashWirePaths(fsMod, this.hashRoots(), stale, {
|
|
718
823
|
onFile: (h) => {
|
|
719
824
|
i++;
|
|
720
825
|
onProgress?.(i, stale.length, h.path);
|
|
@@ -723,7 +828,7 @@ export class SyncService {
|
|
|
723
828
|
for (const h of hashed) {
|
|
724
829
|
out.set(h.path, h.sha256);
|
|
725
830
|
try {
|
|
726
|
-
const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(
|
|
831
|
+
const st = typeof fsMod.statSync === 'function' ? fsMod.statSync(this.localPathForWirePath(h.path), { bigint: true }) : null;
|
|
727
832
|
if (st)
|
|
728
833
|
index.entries[h.path] = { ...statFingerprint(st), sha256: h.sha256 };
|
|
729
834
|
}
|
package/lib/sync/sync-types.d.ts
CHANGED
|
@@ -83,5 +83,5 @@ export interface ApplyRequest {
|
|
|
83
83
|
direction: SyncDirection;
|
|
84
84
|
confirm: true;
|
|
85
85
|
}
|
|
86
|
-
/** Inventory scope: 'memory' covers
|
|
86
|
+
/** Inventory scope: 'memory' covers maestro-memory only, 'all' adds sessions/. */
|
|
87
87
|
export type SyncScope = 'memory' | 'all';
|
package/lib/sync/validation.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { RemoteTarget } from './sync-types.js';
|
|
|
2
2
|
export declare const HOST_RE: RegExp;
|
|
3
3
|
export declare const ABSOLUTE_RE: RegExp;
|
|
4
4
|
export declare const ELIGIBLE_RE: RegExp;
|
|
5
|
+
/** True when a wire path is eligible, without throwing at the caller. */
|
|
6
|
+
export declare function isEligiblePath(value: string): boolean;
|
|
5
7
|
export declare const HOST: RegExp;
|
|
6
8
|
export declare const ABSOLUTE: RegExp;
|
|
7
9
|
export declare const ELIGIBLE: RegExp;
|
package/lib/sync/validation.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export const HOST_RE = /^(?!-)[A-Za-z0-9._@:-]+$/;
|
|
2
2
|
export const ABSOLUTE_RE = /^\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+$/;
|
|
3
|
-
|
|
3
|
+
// `migrated-v5.json` is the store-move marker: a peer that carries it has moved its
|
|
4
|
+
// store out of the DSH home. Sync needs to see it to refuse a half-upgraded pair instead
|
|
5
|
+
// of publishing into a directory the peer no longer reads.
|
|
6
|
+
export const ELIGIBLE_RE = /^(?:maestro-memory\/(?!.*\.bak\.)[A-Za-z0-9._\/-]+\.md|maestro-memory\/SUGGESTIONS\.jsonl|maestro-memory\/\.maestro-memory\/migrated-v5\.json|sessions\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/session\.jsonl\.zstd|sessions\/[A-Za-z0-9._\/-]+\.jsonl\.zstd)$/;
|
|
7
|
+
/** True when a wire path is eligible, without throwing at the caller. */
|
|
8
|
+
export function isEligiblePath(value) {
|
|
9
|
+
try {
|
|
10
|
+
normalizeEligiblePath(value);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
// Backwards-compatible aliases required by spec
|
|
5
18
|
export const HOST = HOST_RE;
|
|
6
19
|
export const ABSOLUTE = ABSOLUTE_RE;
|
|
@@ -65,7 +78,7 @@ export function normalizeEligiblePath(value) {
|
|
|
65
78
|
throw new Error(`ineligible path: contains control characters: ${JSON.stringify(value)}`);
|
|
66
79
|
}
|
|
67
80
|
if (value.includes('..')) {
|
|
68
|
-
// traversal not allowed at all; eligible paths are strictly under
|
|
81
|
+
// traversal not allowed at all; eligible paths are strictly under maestro-memory/ or sessions/
|
|
69
82
|
// The ELIGIBLE regex would reject it anyway, but be explicit
|
|
70
83
|
throw new Error(`ineligible path: traversal: ${JSON.stringify(value)}`);
|
|
71
84
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* (`bg-base #fff`) and dark (`bg-base #121212`) — a token-only
|
|
28
28
|
* background can resolve to near-white on some dark tokens.
|
|
29
29
|
*/
|
|
30
|
-
export { MAESTRO_BRAND_TILE, MAESTRO_MARK_PATH, MAESTRO_MARK_STROKE_WIDTH, MAESTRO_MARK_VIEWBOX,
|
|
30
|
+
export { MAESTRO_BRAND_TILE, MAESTRO_MARK_PATH, MAESTRO_MARK_STROKE_WIDTH, MAESTRO_MARK_VIEWBOX, } from '../maestro-mark.js';
|
|
31
31
|
/**
|
|
32
32
|
* Keys a call site may override on the badge. POSITIONING ONLY — the tile's
|
|
33
33
|
* colour, border, shadow, radius and size are the brand and are not negotiable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrandMark.d.ts","sourceRoot":"","sources":["../../../../../src/client/config/components/BrandMark.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAcH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"BrandMark.d.ts","sourceRoot":"","sources":["../../../../../src/client/config/components/BrandMark.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAcH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,4FAE1B,CAAA;AAEV,KAAK,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;AAWzF,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,mCAKnD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,eAAe,CAAA;CAAE,8DAa5G"}
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
export declare const MAESTRO_SETTINGS_ORDER = 26;
|
|
13
13
|
interface ClientCtx {
|
|
14
14
|
get?(name: string): unknown;
|
|
15
|
-
effect(fn: () => () => void, label?: string): unknown;
|
|
16
15
|
}
|
|
17
16
|
export declare const inject: readonly ["slots", "connection"];
|
|
18
17
|
export declare function apply(ctx: ClientCtx): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/config/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/config/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAsBxC,UAAU,SAAS;IACjB,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAC5B;AAED,eAAO,MAAM,MAAM,kCAAmC,CAAA;AAEtD,wBAAgB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CA8B1C"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maestro M logo — the react-free half of the reference implementation.
|
|
3
3
|
*
|
|
4
|
-
* Split out from `components/BrandMark.tsx` so the glyph declaration
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `tests/brand-mark.spec.ts` can assert the exact URI bytes.
|
|
4
|
+
* Split out from `components/BrandMark.tsx` so the glyph declaration is
|
|
5
|
+
* importable from a test: `BrandMark.tsx` imports react, which the client
|
|
6
|
+
* bundler treats as an EXTERNAL with no entry in this package's `package.json`,
|
|
7
|
+
* so it cannot be imported from vitest at all. This module has no react import,
|
|
8
|
+
* so `tests/brand-mark.spec.ts` can still read the declarations a caller builds
|
|
9
|
+
* its glyph from.
|
|
11
10
|
*
|
|
12
11
|
* The path itself is duplicated in other Maestro packages and that duplication
|
|
13
12
|
* is structural — see the header in `components/BrandMark.tsx`.
|
|
@@ -17,13 +16,4 @@ export declare const MAESTRO_MARK_VIEWBOX = "0 0 16 16";
|
|
|
17
16
|
export declare const MAESTRO_MARK_STROKE_WIDTH = 1.6;
|
|
18
17
|
/** Badge tile colour — part of the house pattern documented in AGENTS.md. */
|
|
19
18
|
export declare const MAESTRO_BRAND_TILE = "#0A84FF";
|
|
20
|
-
/**
|
|
21
|
-
* The exact data-URI the settings-nav row paints as a `currentColor` mask.
|
|
22
|
-
*
|
|
23
|
-
* Only `<` and `>` are encoded. `encodeURIComponent` would additionally escape
|
|
24
|
-
* quotes, slashes and spaces, producing a different URI than the literal this
|
|
25
|
-
* replaces — and the row renders through `mask`, so a subtly different URI can
|
|
26
|
-
* leave the glyph blank. `tests/brand-mark.spec.ts` pins the bytes.
|
|
27
|
-
*/
|
|
28
|
-
export declare function maestroMarkMaskUri(): string;
|
|
29
19
|
//# sourceMappingURL=maestro-mark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maestro-mark.d.ts","sourceRoot":"","sources":["../../../../src/client/config/maestro-mark.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"maestro-mark.d.ts","sourceRoot":"","sources":["../../../../src/client/config/maestro-mark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,iBAAiB,iCAAiC,CAAA;AAC/D,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAC/C,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAE5C,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/sync/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,eAAO,MAAM,MAAM,kCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/sync/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,eAAO,MAAM,MAAM,kCAAmC,CAAA;AA0PtD,iBAAS,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAmB7B;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;;;;;AAE3B,wBAAgC"}
|
package/package.json
CHANGED
|
@@ -77,15 +77,16 @@ path from documentation.
|
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
79
|
# Safe inspection only: resolves the serving tree but changes nothing.
|
|
80
|
-
bash <skill-resource-base>/scripts/restart-dsh-web.sh
|
|
81
|
-
--repo /path/to/deepseek-harness --dry-run
|
|
80
|
+
bash <skill-resource-base>/scripts/restart-dsh-web.sh --dry-run
|
|
82
81
|
```
|
|
83
82
|
|
|
84
83
|
Run the `dsh_web_restart` tool instead of executing the helper — the helper is
|
|
85
84
|
for external agents and humans. In-session agents must never run it from their
|
|
86
85
|
own turn (see "Never do these" below).
|
|
87
86
|
|
|
88
|
-
|
|
87
|
+
A systemd-managed `dsh-web.service` needs no checkout. Without systemd the
|
|
88
|
+
helper launches `DSH_BIN` (the packaged `@deepseek-ai/dsh` bin) and only falls
|
|
89
|
+
back to `--repo` / `DSH_REPO` for a source launch. `--log` or `DSH_RESTART_LOG` changes
|
|
89
90
|
the append-only log destination. The helper refuses a real swap without
|
|
90
91
|
`--confirm`, dynamically resolves listeners rather than trusting saved PIDs,
|
|
91
92
|
and refuses to launch if ports are still occupied. `--dry-run` never runs
|
|
@@ -31,42 +31,18 @@ auto_mode=false
|
|
|
31
31
|
check_supervisor=false
|
|
32
32
|
reload_supervisor=false
|
|
33
33
|
|
|
34
|
-
dry_boot_and_verify() {
|
|
35
|
-
local dsh_repo="$1"
|
|
36
|
-
local port="${2:-0}"
|
|
37
|
-
local marker="${3:-}"
|
|
38
|
-
local dsh_home
|
|
39
|
-
dsh_home="$(mktemp -d)"
|
|
40
|
-
local log_tmp
|
|
41
|
-
log_tmp="$(mktemp)"
|
|
42
|
-
# ephemeral boot with isolated DSH_HOME
|
|
43
|
-
DSH_HOME="$dsh_home" pnpm --dir "$dsh_repo" exec dsh web --port "$port" --no-open >"$log_tmp" 2>&1 &
|
|
44
|
-
local pid=$!
|
|
45
|
-
local ok=false
|
|
46
|
-
for _ in $(seq 1 15); do
|
|
47
|
-
if curl -s "http://127.0.0.1:$port/" 2>/dev/null | grep -q "${marker:-}"; then
|
|
48
|
-
ok=true
|
|
49
|
-
break
|
|
50
|
-
fi
|
|
51
|
-
if ! kill -0 "$pid" 2>/dev/null; then break; fi
|
|
52
|
-
sleep 1
|
|
53
|
-
done
|
|
54
|
-
kill -TERM "$pid" 2>/dev/null || true
|
|
55
|
-
wait "$pid" 2>/dev/null || true
|
|
56
|
-
rm -rf "$dsh_home" "$log_tmp"
|
|
57
|
-
[[ "$ok" == true ]]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
34
|
usage() {
|
|
61
35
|
cat <<'EOF'
|
|
62
|
-
Usage: restart-dsh-web.sh --repo <deepseek-harness> [--log <path>] [--confirm|--auto] [--dry-run]
|
|
36
|
+
Usage: restart-dsh-web.sh [--repo <deepseek-harness>] [--log <path>] [--confirm|--auto] [--dry-run]
|
|
63
37
|
restart-dsh-web.sh --check-supervisor
|
|
64
38
|
restart-dsh-web.sh --reload-supervisor
|
|
65
39
|
|
|
66
40
|
Safely hand over the DSH Web process that owns ports 3000, 3080, 3081 and 3082.
|
|
67
41
|
|
|
68
42
|
Options:
|
|
69
|
-
--repo <path> DeepSeek Harness checkout (or set DSH_REPO).
|
|
43
|
+
--repo <path> DeepSeek Harness checkout (or set DSH_REPO). Only needed for a
|
|
44
|
+
source launch without systemd; DSH_BIN (the packaged
|
|
45
|
+
runtime's bin) takes precedence.
|
|
70
46
|
--log <path> Append-only launch log (or set DSH_RESTART_LOG).
|
|
71
47
|
--confirm Permit a real process handover (human-gated). Required unless --dry-run.
|
|
72
48
|
--auto Permit auto handover (supervisor, no consent prompt). Alias for --confirm with auto log prefix.
|
|
@@ -256,8 +232,9 @@ if [[ "$reload_supervisor" == true ]]; then
|
|
|
256
232
|
exit 0
|
|
257
233
|
fi
|
|
258
234
|
|
|
259
|
-
[[ -n "$repo" ]]
|
|
260
|
-
[[ -f "$repo/package.json" ]] || fail "repo has no package.json: $repo" 64
|
|
235
|
+
if [[ -n "$repo" ]]; then
|
|
236
|
+
[[ -f "$repo/package.json" ]] || fail "repo has no package.json: $repo" 64
|
|
237
|
+
fi
|
|
261
238
|
if [[ "$dry_run" != true && "$confirmed" != true ]]; then
|
|
262
239
|
fail 'refusing live restart without --confirm' 64
|
|
263
240
|
fi
|
|
@@ -438,13 +415,20 @@ if [[ "$systemd_managed" == true ]]; then
|
|
|
438
415
|
systemctl --user start dsh-web.service 2>>"$log" || fail 'systemctl --user start dsh-web.service failed'
|
|
439
416
|
else
|
|
440
417
|
command -v setsid >/dev/null 2>&1 || fail 'required command is unavailable: setsid'
|
|
441
|
-
command -v pnpm >/dev/null 2>&1 || fail 'required command is unavailable: pnpm'
|
|
442
418
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
setsid nohup "$(command -v
|
|
447
|
-
|
|
419
|
+
if [[ -n "${DSH_BIN:-}" ]]; then
|
|
420
|
+
[[ -f "$DSH_BIN" ]] || fail "DSH_BIN does not exist: $DSH_BIN" 64
|
|
421
|
+
printf '[restart] launching DSH Web from %s\n' "$DSH_BIN" >> "$log"
|
|
422
|
+
setsid nohup "$(command -v node)" "$DSH_BIN" web --no-open </dev/null >> "$log" 2>&1 &
|
|
423
|
+
else
|
|
424
|
+
[[ -n "$repo" ]] || fail 'no systemd unit: provide DSH_BIN, --repo or DSH_REPO' 64
|
|
425
|
+
command -v pnpm >/dev/null 2>&1 || fail 'required command is unavailable: pnpm'
|
|
426
|
+
printf '[restart] launching DSH Web from %s\n' "$repo" >> "$log"
|
|
427
|
+
(
|
|
428
|
+
cd "$repo"
|
|
429
|
+
setsid nohup "$(command -v pnpm)" dsh web --no-open </dev/null >> "$log" 2>&1 &
|
|
430
|
+
)
|
|
431
|
+
fi
|
|
448
432
|
fi
|
|
449
433
|
|
|
450
434
|
for _ in $(seq 1 90); do
|
|
@@ -13,37 +13,14 @@ export const MAESTRO_SETTINGS_ORDER = 26
|
|
|
13
13
|
|
|
14
14
|
// DSH-native redesign — reuses DSH tokens & primitive geometry maximally (see MaestroSettings.tsx).
|
|
15
15
|
import { MaestroSettingsTab } from './MaestroSettings.js'
|
|
16
|
-
import { registerSettingsNavIcon, SETTINGS_NAV_MARKER } from './settings-nav-icon.js'
|
|
17
|
-
import { maestroMarkMaskUri } from './components/BrandMark.js'
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
|
-
* DSH 0.
|
|
21
|
-
*
|
|
22
|
-
* the marker
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* declared once in components/BrandMark.tsx — the workspace reference
|
|
26
|
-
* implementation.
|
|
18
|
+
* The nav row keeps the shell's default gear. DSH 0.2.x paints a section row
|
|
19
|
+
* through the settings.section.icon slot: the glyph sits inside a wrapping
|
|
20
|
+
* span, so the 0.1.x marker + `::before` mask this plugin used to carry hid
|
|
21
|
+
* nothing and painted a second glyph beside the gear. A custom row icon is a
|
|
22
|
+
* slot registration, not a DOM rewrite, and no Maestro section asks for one.
|
|
27
23
|
*/
|
|
28
|
-
const SETTINGS_NAV_CSS = `
|
|
29
|
-
|
|
30
|
-
/* maestro: replace the settings-nav fallback gear with the Maestro M-logo glyph — same mark as components/BrandMark.tsx */
|
|
31
|
-
[${SETTINGS_NAV_MARKER}] > svg:first-child,
|
|
32
|
-
[${SETTINGS_NAV_MARKER}] > svg.zWKi1a_navIcon {
|
|
33
|
-
display: none !important;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
[${SETTINGS_NAV_MARKER}]::before {
|
|
37
|
-
content: '';
|
|
38
|
-
flex: none;
|
|
39
|
-
width: 16px;
|
|
40
|
-
height: 16px;
|
|
41
|
-
display: inline-block;
|
|
42
|
-
background: currentColor;
|
|
43
|
-
-webkit-mask: url("${maestroMarkMaskUri()}") center / contain no-repeat;
|
|
44
|
-
mask: url("${maestroMarkMaskUri()}") center / contain no-repeat;
|
|
45
|
-
}
|
|
46
|
-
`
|
|
47
24
|
|
|
48
25
|
type SlotsApi = {
|
|
49
26
|
inject(name: string, factory: () => unknown): void
|
|
@@ -56,22 +33,10 @@ type RpcCall = (endpoint: string, payload?: unknown, signal?: AbortSignal) => Pr
|
|
|
56
33
|
|
|
57
34
|
interface ClientCtx {
|
|
58
35
|
get?(name: string): unknown
|
|
59
|
-
effect(fn: () => () => void, label?: string): unknown
|
|
60
36
|
}
|
|
61
37
|
|
|
62
38
|
export const inject = ['slots', 'connection'] as const
|
|
63
39
|
|
|
64
|
-
function installNavIconStyle(): () => void {
|
|
65
|
-
const tag = document.createElement('style')
|
|
66
|
-
tag.dataset.plugin = '@ddtcorex/dsh-maestro-config'
|
|
67
|
-
tag.dataset.pluginCss = 'maestro/settings-nav.css'
|
|
68
|
-
tag.textContent = SETTINGS_NAV_CSS
|
|
69
|
-
document.head.appendChild(tag)
|
|
70
|
-
return () => {
|
|
71
|
-
document.querySelector('style[data-plugin-css="maestro/settings-nav.css"]')?.remove()
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
40
|
export function apply(ctx: ClientCtx): void {
|
|
76
41
|
const slots = ctx.get?.('slots') as SlotsApi | undefined
|
|
77
42
|
if (slots === undefined) return
|
|
@@ -96,10 +61,6 @@ export function apply(ctx: ClientCtx): void {
|
|
|
96
61
|
return connection.rpc.call('/dsh-maestro-supervisor-resume', endpoint, payload, signal)
|
|
97
62
|
}
|
|
98
63
|
|
|
99
|
-
// Reversible effects: nav-row marker observer + owned style tag.
|
|
100
|
-
ctx.effect(() => registerSettingsNavIcon(() => 'Maestro'), 'maestro: settings nav icon')
|
|
101
|
-
ctx.effect(installNavIconStyle, 'maestro: settings nav css')
|
|
102
|
-
|
|
103
64
|
slots.inject('settings.section', () =>
|
|
104
65
|
slots.register(
|
|
105
66
|
{ name: 'settings.section', id: 'maestro', order: MAESTRO_SETTINGS_ORDER, label: () => 'Maestro', inject: () => ({ configRpcCall, supervisorRpcCall }) },
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maestro M logo — the react-free half of the reference implementation.
|
|
3
3
|
*
|
|
4
|
-
* Split out from `components/BrandMark.tsx` so the glyph declaration
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `tests/brand-mark.spec.ts` can assert the exact URI bytes.
|
|
4
|
+
* Split out from `components/BrandMark.tsx` so the glyph declaration is
|
|
5
|
+
* importable from a test: `BrandMark.tsx` imports react, which the client
|
|
6
|
+
* bundler treats as an EXTERNAL with no entry in this package's `package.json`,
|
|
7
|
+
* so it cannot be imported from vitest at all. This module has no react import,
|
|
8
|
+
* so `tests/brand-mark.spec.ts` can still read the declarations a caller builds
|
|
9
|
+
* its glyph from.
|
|
11
10
|
*
|
|
12
11
|
* The path itself is duplicated in other Maestro packages and that duplication
|
|
13
12
|
* is structural — see the header in `components/BrandMark.tsx`.
|
|
@@ -19,19 +18,3 @@ export const MAESTRO_MARK_STROKE_WIDTH = 1.6
|
|
|
19
18
|
|
|
20
19
|
/** Badge tile colour — part of the house pattern documented in AGENTS.md. */
|
|
21
20
|
export const MAESTRO_BRAND_TILE = '#0A84FF'
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The exact data-URI the settings-nav row paints as a `currentColor` mask.
|
|
25
|
-
*
|
|
26
|
-
* Only `<` and `>` are encoded. `encodeURIComponent` would additionally escape
|
|
27
|
-
* quotes, slashes and spaces, producing a different URI than the literal this
|
|
28
|
-
* replaces — and the row renders through `mask`, so a subtly different URI can
|
|
29
|
-
* leave the glyph blank. `tests/brand-mark.spec.ts` pins the bytes.
|
|
30
|
-
*/
|
|
31
|
-
export function maestroMarkMaskUri(): string {
|
|
32
|
-
const svg =
|
|
33
|
-
`<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='${MAESTRO_MARK_VIEWBOX}' ` +
|
|
34
|
-
`fill='none' stroke='black' stroke-width='${MAESTRO_MARK_STROKE_WIDTH}' ` +
|
|
35
|
-
`stroke-linecap='round' stroke-linejoin='round'><path d='${MAESTRO_MARK_PATH}'/></svg>`
|
|
36
|
-
return `data:image/svg+xml,${svg.replace(/</g, '%3C').replace(/>/g, '%3E')}`
|
|
37
|
-
}
|