@alexpeng/dsh-custom-plugin 0.7.0 → 0.7.1
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 +88 -0
- package/lib/client.js +140 -138
- package/lib/client.js.map +1 -1
- package/lib/index.js +327 -20
- package/lib/types/client/palette.d.ts +3 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/host-service.d.ts +2 -0
- package/lib/types/state.d.ts +27 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import { dirname, isAbsolute, join } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
|
-
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
//#region src/dsh-home.ts
|
|
8
8
|
/**
|
|
@@ -312,20 +312,170 @@ function mergeState(target, raw) {
|
|
|
312
312
|
if (typeof src.apiKey === "string") target.apiKey = src.apiKey;
|
|
313
313
|
if (src.usage !== null && typeof src.usage === "object" && !Array.isArray(src.usage)) target.usage = src.usage;
|
|
314
314
|
}
|
|
315
|
-
/**
|
|
316
|
-
|
|
315
|
+
/** Rejection caps for browser-supplied documents. A shape beyond them is
|
|
316
|
+
* rejected outright — never truncated — because the client owns the whole
|
|
317
|
+
* document and a partial accept would silently drop the rest. The depth cap
|
|
318
|
+
* is what keeps a hostile edit from making `JSON.stringify` throw
|
|
319
|
+
* `RangeError` on every later save. */
|
|
320
|
+
const MAX_FOLDER_DEPTH = 32;
|
|
321
|
+
const MAX_FOLDER_NODES = 2e3;
|
|
322
|
+
const MAX_STAR_ENTRIES = 1e4;
|
|
323
|
+
function safeKeyPart(value) {
|
|
324
|
+
return value !== "__proto__" && value !== "constructor" && value !== "prototype";
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Validate a folder tree from the browser against the persisted shape:
|
|
328
|
+
* unique non-empty ids, string name, and string-only id lists, bounded in
|
|
329
|
+
* depth and node count. Null on any violation — the caller rejects the edit.
|
|
330
|
+
*/
|
|
331
|
+
function normalizeFolders(raw) {
|
|
332
|
+
if (!Array.isArray(raw)) return null;
|
|
333
|
+
const seen = /* @__PURE__ */ new Set();
|
|
334
|
+
let count = 0;
|
|
335
|
+
const walk = (node, depth) => {
|
|
336
|
+
if (node === null || typeof node !== "object") return null;
|
|
337
|
+
const src = node;
|
|
338
|
+
if (typeof src.id !== "string" || src.id === "" || seen.has(src.id)) return null;
|
|
339
|
+
if (typeof src.name !== "string") return null;
|
|
340
|
+
if (!Array.isArray(src.children) || !Array.isArray(src.sessionIds) || !Array.isArray(src.workspaceIds) || !Array.isArray(src.prompts)) return null;
|
|
341
|
+
const strings = (value) => value.every((item) => typeof item === "string") ? [...new Set(value)] : null;
|
|
342
|
+
const sessionIds = strings(src.sessionIds);
|
|
343
|
+
const workspaceIds = strings(src.workspaceIds);
|
|
344
|
+
const prompts = strings(src.prompts);
|
|
345
|
+
if (sessionIds === null || workspaceIds === null || prompts === null) return null;
|
|
346
|
+
if (depth >= MAX_FOLDER_DEPTH) return null;
|
|
347
|
+
if (++count > MAX_FOLDER_NODES) return null;
|
|
348
|
+
seen.add(src.id);
|
|
349
|
+
const children = [];
|
|
350
|
+
for (const child of src.children) {
|
|
351
|
+
const parsed = walk(child, depth + 1);
|
|
352
|
+
if (parsed === null) return null;
|
|
353
|
+
children.push(parsed);
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
id: src.id,
|
|
357
|
+
name: src.name,
|
|
358
|
+
children,
|
|
359
|
+
sessionIds,
|
|
360
|
+
workspaceIds,
|
|
361
|
+
prompts
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
const out = [];
|
|
365
|
+
for (const node of raw) {
|
|
366
|
+
const parsed = walk(node, 0);
|
|
367
|
+
if (parsed === null) return null;
|
|
368
|
+
out.push(parsed);
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Validate a star map from the browser: session ids as safe object keys,
|
|
374
|
+
* digit-string sequence keys, `true` values only, bounded total. Null on any
|
|
375
|
+
* violation.
|
|
376
|
+
*/
|
|
377
|
+
function normalizeStars(raw) {
|
|
378
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
379
|
+
const out = {};
|
|
380
|
+
let total = 0;
|
|
381
|
+
for (const [sessionId, entries] of Object.entries(raw)) {
|
|
382
|
+
if (!safeKeyPart(sessionId)) return null;
|
|
383
|
+
if (entries === null || typeof entries !== "object" || Array.isArray(entries)) return null;
|
|
384
|
+
const clean = {};
|
|
385
|
+
for (const [seq, value] of Object.entries(entries)) {
|
|
386
|
+
if (value !== true || !/^\d+$/.test(seq)) return null;
|
|
387
|
+
if (++total > MAX_STAR_ENTRIES) return null;
|
|
388
|
+
clean[seq] = true;
|
|
389
|
+
}
|
|
390
|
+
out[sessionId] = clean;
|
|
391
|
+
}
|
|
392
|
+
return out;
|
|
393
|
+
}
|
|
394
|
+
/** Retry ladder for a transiently unreadable state file (AV scan, sync
|
|
395
|
+
* client, a sharing violation racing the Desktop host's rename). Same
|
|
396
|
+
* cadence as the browser half's load retries, so a slow-locking file heals
|
|
397
|
+
* inside the window the client is still retrying its first read. */
|
|
398
|
+
const LOAD_RETRY_DELAYS = [
|
|
399
|
+
1500,
|
|
400
|
+
3e3,
|
|
401
|
+
6e3
|
|
402
|
+
];
|
|
403
|
+
/**
|
|
404
|
+
* Load and merge the persisted document into `state`.
|
|
405
|
+
*
|
|
406
|
+
* A missing file (ENOENT) is a fresh install and resolves with defaults. A
|
|
407
|
+
* corrupt or permanently unreadable file is renamed aside before defaults
|
|
408
|
+
* are adopted, so the caller's immediate save cannot destroy the previous
|
|
409
|
+
* bytes. Only when the file is unreadable AND cannot be moved aside does
|
|
410
|
+
* this reject — the caller must then suppress saves, because persisting
|
|
411
|
+
* never-loaded defaults would clobber a document that may be intact.
|
|
412
|
+
*/
|
|
413
|
+
async function loadStateFile(state, home = dshHome(), retryDelays = LOAD_RETRY_DELAYS) {
|
|
317
414
|
const statePath = join(home, STATE_FILE);
|
|
318
|
-
let
|
|
415
|
+
let text;
|
|
416
|
+
let mtimeMs = 0;
|
|
417
|
+
let size = 0;
|
|
418
|
+
for (let attempt = 0;; attempt++) try {
|
|
419
|
+
const handle = await open(statePath, "r");
|
|
420
|
+
try {
|
|
421
|
+
const st = await handle.stat();
|
|
422
|
+
text = await handle.readFile("utf8");
|
|
423
|
+
mtimeMs = st.mtimeMs;
|
|
424
|
+
size = st.size;
|
|
425
|
+
} finally {
|
|
426
|
+
await handle.close();
|
|
427
|
+
}
|
|
428
|
+
break;
|
|
429
|
+
} catch (error) {
|
|
430
|
+
if (error?.code === "ENOENT") {
|
|
431
|
+
syncBaselines.set(statePath, null);
|
|
432
|
+
return statePath;
|
|
433
|
+
}
|
|
434
|
+
if (attempt < retryDelays.length) {
|
|
435
|
+
await new Promise((resolve) => {
|
|
436
|
+
setTimeout(resolve, retryDelays[attempt]);
|
|
437
|
+
});
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
await quarantineStateFile(statePath, error);
|
|
441
|
+
syncBaselines.set(statePath, null);
|
|
442
|
+
return statePath;
|
|
443
|
+
}
|
|
444
|
+
let raw;
|
|
319
445
|
try {
|
|
320
|
-
const text = await readFile(statePath, "utf8");
|
|
321
446
|
raw = JSON.parse(text);
|
|
322
|
-
} catch {
|
|
447
|
+
} catch (error) {
|
|
448
|
+
await quarantineStateFile(statePath, error);
|
|
449
|
+
syncBaselines.set(statePath, null);
|
|
323
450
|
raw = null;
|
|
324
451
|
}
|
|
325
|
-
if (raw !== null)
|
|
452
|
+
if (raw !== null) {
|
|
453
|
+
mergeState(state, raw);
|
|
454
|
+
syncBaselines.set(statePath, {
|
|
455
|
+
mtimeMs,
|
|
456
|
+
size,
|
|
457
|
+
doc: text
|
|
458
|
+
});
|
|
459
|
+
}
|
|
326
460
|
pruneUsage(state.usage);
|
|
327
461
|
return statePath;
|
|
328
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* Rename an unusable state document aside, pid-qualified like the atomic
|
|
465
|
+
* save temp: `$DSH_HOME` is shared by every host under it, so two hosts
|
|
466
|
+
* quarantining must not fight over one recovery name. A file that vanished
|
|
467
|
+
* between the failed read and this rename needs no recovery copy; any other
|
|
468
|
+
* rename failure propagates so the caller knows not to save defaults over a
|
|
469
|
+
* document it could neither read nor preserve.
|
|
470
|
+
*/
|
|
471
|
+
async function quarantineStateFile(statePath, cause) {
|
|
472
|
+
try {
|
|
473
|
+
await rename(statePath, `${statePath}.corrupt-${process.pid}`);
|
|
474
|
+
} catch (error) {
|
|
475
|
+
if (error?.code === "ENOENT") return;
|
|
476
|
+
throw new Error(`state file unreadable and could not be quarantined (read: ${String(cause?.message ?? cause)}; rename: ${String(error?.message ?? error)})`, { cause: error });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
329
479
|
/** In-flight save per state path: concurrent saves queue instead of racing on
|
|
330
480
|
* the rename order. Two writers renaming one temp file is the Windows
|
|
331
481
|
* EPERM/EBUSY source; queuing also coalesces naturally, because each turn
|
|
@@ -344,25 +494,136 @@ function tempPathFor(target, pid = process.pid) {
|
|
|
344
494
|
}
|
|
345
495
|
/** Atomically persist the state document. Saves to the same path are
|
|
346
496
|
* serialized: a caller awaits its own turn's completion, a failed turn never
|
|
347
|
-
* poisons the queue behind it.
|
|
497
|
+
* poisons the queue behind it. Before writing, another host's changes since
|
|
498
|
+
* this process last loaded or saved the file are merged back in (see
|
|
499
|
+
* `mergeExternalChanges`). */
|
|
348
500
|
function saveStateFile(state, home = dshHome()) {
|
|
349
501
|
const statePath = join(home, STATE_FILE);
|
|
350
502
|
const turn = (saveQueues.get(statePath) ?? Promise.resolve()).catch(() => {}).then(async () => {
|
|
503
|
+
await mergeExternalChanges(state, statePath);
|
|
351
504
|
await mkdir(dirname(statePath), { recursive: true });
|
|
505
|
+
const doc = JSON.stringify(state);
|
|
352
506
|
const tmpPath = tempPathFor(statePath);
|
|
353
507
|
try {
|
|
354
|
-
await writeFile(tmpPath,
|
|
508
|
+
await writeFile(tmpPath, doc, "utf8");
|
|
355
509
|
await rename(tmpPath, statePath);
|
|
356
510
|
} catch (error) {
|
|
357
511
|
await rm(tmpPath, { force: true }).catch(() => {});
|
|
358
512
|
throw error;
|
|
359
513
|
}
|
|
514
|
+
const st = await stat(statePath).catch(() => null);
|
|
515
|
+
syncBaselines.set(statePath, st !== null ? {
|
|
516
|
+
mtimeMs: st.mtimeMs,
|
|
517
|
+
size: st.size,
|
|
518
|
+
doc
|
|
519
|
+
} : null);
|
|
360
520
|
});
|
|
361
521
|
saveQueues.set(statePath, turn);
|
|
362
522
|
return turn.finally(() => {
|
|
363
523
|
if (saveQueues.get(statePath) === turn) saveQueues.delete(statePath);
|
|
364
524
|
});
|
|
365
525
|
}
|
|
526
|
+
/** Per-path view of the on-disk document this process last saw: its stat
|
|
527
|
+
* identity and its serialized bytes. `$DSH_HOME` is shared by every dsh host
|
|
528
|
+
* under it (Web + Desktop), so a save must first notice whether another host
|
|
529
|
+
* wrote the file since. `null` marks "believed absent"; no entry at all marks
|
|
530
|
+
* "never loaded through this module", where a direct save keeps the plain
|
|
531
|
+
* last-writer-wins behavior. */
|
|
532
|
+
const syncBaselines = /* @__PURE__ */ new Map();
|
|
533
|
+
/**
|
|
534
|
+
* Fold another host's writes back in before this process saves over them.
|
|
535
|
+
*
|
|
536
|
+
* Each host holds the whole document in memory, so an unchecked save is
|
|
537
|
+
* last-writer-wins and silently discards the other host's usage folds and
|
|
538
|
+
* config edits. When the file's stat identity no longer matches what this
|
|
539
|
+
* process last wrote or loaded, the current bytes are re-read and three-way
|
|
540
|
+
* merged against the last-saved snapshot: sections this process has not
|
|
541
|
+
* touched adopt the external version, the usage ledger unions arithmetically
|
|
542
|
+
* (`theirs + ours − base` per counter — exact for two hosts that both
|
|
543
|
+
* started from `base`), and locally-dirty sections keep the local version.
|
|
544
|
+
*
|
|
545
|
+
* The stat fast path misses only a same-instant, same-length rewrite by
|
|
546
|
+
* another host. An unreadable or undecodable external document falls back to
|
|
547
|
+
* the plain overwrite — the boot-time quarantine remains the backstop for
|
|
548
|
+
* the destructive case.
|
|
549
|
+
*/
|
|
550
|
+
async function mergeExternalChanges(state, statePath) {
|
|
551
|
+
const baseline = syncBaselines.get(statePath);
|
|
552
|
+
if (baseline === void 0) return;
|
|
553
|
+
const st = await stat(statePath).catch(() => null);
|
|
554
|
+
if (st === null) return;
|
|
555
|
+
if (baseline !== null && st.mtimeMs === baseline.mtimeMs && st.size === baseline.size) return;
|
|
556
|
+
const text = await readFile(statePath, "utf8").catch(() => null);
|
|
557
|
+
if (text === null) return;
|
|
558
|
+
let theirs;
|
|
559
|
+
try {
|
|
560
|
+
theirs = JSON.parse(text);
|
|
561
|
+
} catch {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (theirs === null || typeof theirs !== "object") return;
|
|
565
|
+
mergeThreeWay(state, baseline !== null ? safeParse(baseline.doc) : null, theirs);
|
|
566
|
+
}
|
|
567
|
+
function safeParse(text) {
|
|
568
|
+
try {
|
|
569
|
+
return JSON.parse(text);
|
|
570
|
+
} catch {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function sameJson(a, b) {
|
|
575
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
576
|
+
}
|
|
577
|
+
function mergeThreeWay(state, base, theirs) {
|
|
578
|
+
const t = theirs;
|
|
579
|
+
const b = base ?? {};
|
|
580
|
+
if (sameJson(state.cfg, b.cfg)) state.cfg = normalizeCfg(t.cfg);
|
|
581
|
+
if (sameJson(state.folders, b.folders) && Array.isArray(t.folders)) state.folders = t.folders;
|
|
582
|
+
if (sameJson(state.prompts, b.prompts) && Array.isArray(t.prompts)) state.prompts = t.prompts.map(normalizePrompt).filter((item) => item !== null);
|
|
583
|
+
if (sameJson(state.stars, b.stars) && t.stars !== null && typeof t.stars === "object" && !Array.isArray(t.stars)) state.stars = t.stars;
|
|
584
|
+
if (sameJson(state.apiKey, b.apiKey) && typeof t.apiKey === "string") state.apiKey = t.apiKey;
|
|
585
|
+
state.usage = mergeUsageThreeWay(state.usage, base?.usage ?? {}, t.usage);
|
|
586
|
+
}
|
|
587
|
+
const USAGE_COUNTER_KEYS = [
|
|
588
|
+
"in",
|
|
589
|
+
"out",
|
|
590
|
+
"cacheIn",
|
|
591
|
+
"cacheW",
|
|
592
|
+
"reason",
|
|
593
|
+
"calls",
|
|
594
|
+
"peakIn",
|
|
595
|
+
"peakCacheIn",
|
|
596
|
+
"peakCacheW",
|
|
597
|
+
"peakOut"
|
|
598
|
+
];
|
|
599
|
+
function counterOf(row, key) {
|
|
600
|
+
const value = row?.[key];
|
|
601
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
602
|
+
}
|
|
603
|
+
/** Union two hosts' ledgers given the snapshot both last saved. For every
|
|
604
|
+
* counter `theirs + ours − base` is exactly the combined progress when both
|
|
605
|
+
* hosts started from `base` (their session streams are disjoint: separate
|
|
606
|
+
* dsh profiles under one `$DSH_HOME`); clamped at zero so a tampered base
|
|
607
|
+
* cannot drive a row negative. */
|
|
608
|
+
function mergeUsageThreeWay(ours, base, theirsRaw) {
|
|
609
|
+
const theirs = theirsRaw !== null && typeof theirsRaw === "object" && !Array.isArray(theirsRaw) ? theirsRaw : {};
|
|
610
|
+
const merged = {};
|
|
611
|
+
for (const day of /* @__PURE__ */ new Set([...Object.keys(ours), ...Object.keys(theirs)])) {
|
|
612
|
+
const mergedDay = {};
|
|
613
|
+
for (const model of /* @__PURE__ */ new Set([...Object.keys(ours[day] ?? {}), ...Object.keys(theirs[day] ?? {})])) {
|
|
614
|
+
const om = ours[day]?.[model];
|
|
615
|
+
const tm = theirs[day]?.[model];
|
|
616
|
+
if (om === void 0 && tm === void 0) continue;
|
|
617
|
+
const row = createUsageRow();
|
|
618
|
+
for (const key of USAGE_COUNTER_KEYS) row[key] = Math.max(0, counterOf(tm, key) + counterOf(om, key) - counterOf(base[day]?.[model], key));
|
|
619
|
+
row.peakSplitKnown = !(om?.peakSplitKnown === false || tm?.peakSplitKnown === false);
|
|
620
|
+
mergedDay[model] = row;
|
|
621
|
+
}
|
|
622
|
+
if (Object.keys(mergedDay).length > 0) merged[day] = mergedDay;
|
|
623
|
+
}
|
|
624
|
+
pruneUsage(merged);
|
|
625
|
+
return merged;
|
|
626
|
+
}
|
|
366
627
|
//#endregion
|
|
367
628
|
//#region src/extract.ts
|
|
368
629
|
/** Base64 encode bytes without relying on Buffer (browser-host parity). */
|
|
@@ -1043,7 +1304,7 @@ async function mapConcurrent(items, limit, worker) {
|
|
|
1043
1304
|
return results;
|
|
1044
1305
|
}
|
|
1045
1306
|
/** Host capabilities behind the routes and the agent tool. */
|
|
1046
|
-
var CustomPluginHost = class {
|
|
1307
|
+
var CustomPluginHost = class CustomPluginHost {
|
|
1047
1308
|
sessionQuery;
|
|
1048
1309
|
state;
|
|
1049
1310
|
statePath;
|
|
@@ -1065,6 +1326,8 @@ var CustomPluginHost = class {
|
|
|
1065
1326
|
mermaidSource = "";
|
|
1066
1327
|
localMermaidPath;
|
|
1067
1328
|
readCredential;
|
|
1329
|
+
credentialCache = null;
|
|
1330
|
+
static CREDENTIAL_CACHE_TTL_MS = 5e3;
|
|
1068
1331
|
constructor(options) {
|
|
1069
1332
|
this.sessionQuery = options.sessionQuery;
|
|
1070
1333
|
this.state = options.state;
|
|
@@ -1186,6 +1449,7 @@ var CustomPluginHost = class {
|
|
|
1186
1449
|
}
|
|
1187
1450
|
/** Apply a browser-side state edit (config, folders, prompts, stars, api key). */
|
|
1188
1451
|
async applyEdit(edit) {
|
|
1452
|
+
this.credentialCache = null;
|
|
1189
1453
|
await this.runStateOperation(async () => {
|
|
1190
1454
|
const previous = JSON.parse(JSON.stringify(this.state));
|
|
1191
1455
|
try {
|
|
@@ -1201,9 +1465,17 @@ var CustomPluginHost = class {
|
|
|
1201
1465
|
...this.state.cfg,
|
|
1202
1466
|
...edit.cfg
|
|
1203
1467
|
});
|
|
1204
|
-
if (Array.isArray(edit.folders))
|
|
1468
|
+
if (Array.isArray(edit.folders)) {
|
|
1469
|
+
const folders = normalizeFolders(edit.folders);
|
|
1470
|
+
if (folders === null) throw new Error("文件夹数据无效");
|
|
1471
|
+
this.state.folders = folders;
|
|
1472
|
+
}
|
|
1205
1473
|
if (Array.isArray(edit.prompts)) this.state.prompts = edit.prompts.map(normalizePrompt).filter((item) => item !== null);
|
|
1206
|
-
if (edit.stars !== void 0 && edit.stars !== null && typeof edit.stars === "object")
|
|
1474
|
+
if (edit.stars !== void 0 && edit.stars !== null && typeof edit.stars === "object") {
|
|
1475
|
+
const stars = normalizeStars(edit.stars);
|
|
1476
|
+
if (stars === null) throw new Error("星标数据无效");
|
|
1477
|
+
this.state.stars = stars;
|
|
1478
|
+
}
|
|
1207
1479
|
if (typeof edit.apiKey === "string") {
|
|
1208
1480
|
const key = edit.apiKey.trim();
|
|
1209
1481
|
if (key === "") {
|
|
@@ -1260,6 +1532,7 @@ var CustomPluginHost = class {
|
|
|
1260
1532
|
}
|
|
1261
1533
|
/** Move a legacy plaintext state key into the OS store when available. */
|
|
1262
1534
|
async migrateLegacyApiKey() {
|
|
1535
|
+
this.credentialCache = null;
|
|
1263
1536
|
const key = (this.state.apiKey ?? "").trim();
|
|
1264
1537
|
if (!/^sk-/.test(key) || !this.credentialStore.available) return false;
|
|
1265
1538
|
let existing = "";
|
|
@@ -1534,11 +1807,18 @@ var CustomPluginHost = class {
|
|
|
1534
1807
|
}
|
|
1535
1808
|
/** Browser-safe credential status used by state and save responses. */
|
|
1536
1809
|
async credentialStatus() {
|
|
1810
|
+
const now = Date.now();
|
|
1811
|
+
if (this.credentialCache !== null && now - this.credentialCache.at < CustomPluginHost.CREDENTIAL_CACHE_TTL_MS) return this.credentialCache.status;
|
|
1537
1812
|
const resolved = await this.resolveApiKeyWithSource();
|
|
1538
|
-
|
|
1813
|
+
const status = {
|
|
1539
1814
|
apiKeyConfigured: resolved.key !== "",
|
|
1540
1815
|
credentialStorage: resolved.source
|
|
1541
1816
|
};
|
|
1817
|
+
this.credentialCache = {
|
|
1818
|
+
at: now,
|
|
1819
|
+
status
|
|
1820
|
+
};
|
|
1821
|
+
return status;
|
|
1542
1822
|
}
|
|
1543
1823
|
/** Query the DeepSeek balance endpoint (15s timeout). */
|
|
1544
1824
|
async balanceGet() {
|
|
@@ -1616,6 +1896,11 @@ var CustomPluginHost = class {
|
|
|
1616
1896
|
const agg = {};
|
|
1617
1897
|
let scanned = 0;
|
|
1618
1898
|
const entries = await mapConcurrent(records, USAGE_SCAN_CONCURRENCY, async (record) => {
|
|
1899
|
+
if (this.usageRevision !== revisionAtStart) return {
|
|
1900
|
+
readable: false,
|
|
1901
|
+
stale: true,
|
|
1902
|
+
usage: {}
|
|
1903
|
+
};
|
|
1619
1904
|
try {
|
|
1620
1905
|
return {
|
|
1621
1906
|
readable: true,
|
|
@@ -1630,6 +1915,7 @@ var CustomPluginHost = class {
|
|
|
1630
1915
|
});
|
|
1631
1916
|
let failedSessions = 0;
|
|
1632
1917
|
for (const entry of entries) {
|
|
1918
|
+
if (entry.stale === true) continue;
|
|
1633
1919
|
if (!entry.readable) {
|
|
1634
1920
|
failedSessions++;
|
|
1635
1921
|
continue;
|
|
@@ -1707,8 +1993,12 @@ var CustomPluginHost = class {
|
|
|
1707
1993
|
for (const url of urls) try {
|
|
1708
1994
|
const result = await this.httpText(url);
|
|
1709
1995
|
if (result.ok) {
|
|
1710
|
-
|
|
1711
|
-
|
|
1996
|
+
if (looksLikeMermaidBundle(result.text)) {
|
|
1997
|
+
text = result.text;
|
|
1998
|
+
break;
|
|
1999
|
+
}
|
|
2000
|
+
lastError = `镜像返回了非脚本内容 (${result.text.length} bytes)`;
|
|
2001
|
+
continue;
|
|
1712
2002
|
}
|
|
1713
2003
|
lastError = result.error ?? "";
|
|
1714
2004
|
} catch (error) {
|
|
@@ -1835,6 +2125,14 @@ function readableFetchError(error) {
|
|
|
1835
2125
|
const message = String(cause?.message ?? error?.message ?? error);
|
|
1836
2126
|
return message === "fetch failed" ? "网络请求失败:请检查本机网络与代理配置" : message;
|
|
1837
2127
|
}
|
|
2128
|
+
/** A 200 from a mirror is not proof of the engine: captive portals and
|
|
2129
|
+
* misconfigured mirrors happily serve an HTML interstitial with status 200.
|
|
2130
|
+
* The real bundle is a multi-megabyte script that never starts with a
|
|
2131
|
+
* document tag; anything else must not poison the host-lifetime cache. */
|
|
2132
|
+
function looksLikeMermaidBundle(text) {
|
|
2133
|
+
const head = text.slice(0, 64).replace(/^\uFEFF/, "").trimStart();
|
|
2134
|
+
return text.length >= 1e3 && !head.startsWith("<");
|
|
2135
|
+
}
|
|
1838
2136
|
/** Resolve `mermaid/dist/mermaid.min.js` from the package's own dependency
|
|
1839
2137
|
* tree (works for `link:` checkouts and registry installs alike); null when
|
|
1840
2138
|
* the dependency is absent, which falls mermaidFetch back to the CDN. */
|
|
@@ -2243,6 +2541,7 @@ function applyImpl(ctx) {
|
|
|
2243
2541
|
const state = defaultState();
|
|
2244
2542
|
let statePath = join(dshHome(), STATE_FILE);
|
|
2245
2543
|
let stateLoaded = false;
|
|
2544
|
+
let stateWritable = true;
|
|
2246
2545
|
const sessionModels = /* @__PURE__ */ new Map();
|
|
2247
2546
|
const pendingUsage = [];
|
|
2248
2547
|
const diagReports = [];
|
|
@@ -2253,6 +2552,7 @@ function applyImpl(ctx) {
|
|
|
2253
2552
|
const saveSoon = (() => {
|
|
2254
2553
|
let timer;
|
|
2255
2554
|
return () => {
|
|
2555
|
+
if (!stateWritable) return;
|
|
2256
2556
|
if (timer !== void 0) clearTimeout(timer);
|
|
2257
2557
|
timer = setTimeout(() => {
|
|
2258
2558
|
timer = void 0;
|
|
@@ -2266,7 +2566,7 @@ function applyImpl(ctx) {
|
|
|
2266
2566
|
sessionQuery: ctx.sessionQuery,
|
|
2267
2567
|
state,
|
|
2268
2568
|
statePath: () => statePath,
|
|
2269
|
-
saveNow: () => saveStateFile(state),
|
|
2569
|
+
saveNow: () => stateWritable ? saveStateFile(state) : Promise.resolve(),
|
|
2270
2570
|
reportDiag,
|
|
2271
2571
|
diagReports,
|
|
2272
2572
|
attachments: ctx.get("attachments")
|
|
@@ -2275,12 +2575,17 @@ function applyImpl(ctx) {
|
|
|
2275
2575
|
statePath = path;
|
|
2276
2576
|
if (await host.migrateLegacyApiKey()) reportDiag("legacy API key migrated to system credentials");
|
|
2277
2577
|
stateLoaded = true;
|
|
2278
|
-
for (const item of pendingUsage.splice(0)) host.foldUsage(item.sessionId, item.usage, item.time, item.model);
|
|
2279
|
-
|
|
2578
|
+
for (const item of pendingUsage.splice(0)) host.foldUsage(item.sessionId, item.usage, item.time, item.model ?? void 0);
|
|
2579
|
+
try {
|
|
2580
|
+
await saveStateFile(state);
|
|
2581
|
+
} catch (error) {
|
|
2582
|
+
reportDiag(`state save failed: ${String(error?.message ?? error)}`);
|
|
2583
|
+
}
|
|
2280
2584
|
}).catch((error) => {
|
|
2281
|
-
reportDiag(`state
|
|
2585
|
+
reportDiag(`state file unreadable, running read-only: ${String(error?.message ?? error)}`);
|
|
2586
|
+
stateWritable = false;
|
|
2282
2587
|
stateLoaded = true;
|
|
2283
|
-
for (const item of pendingUsage.splice(0)) host.foldUsage(item.sessionId, item.usage, item.time, item.model);
|
|
2588
|
+
for (const item of pendingUsage.splice(0)) host.foldUsage(item.sessionId, item.usage, item.time, item.model ?? void 0);
|
|
2284
2589
|
});
|
|
2285
2590
|
ctx.on("session/event", (session, event) => {
|
|
2286
2591
|
try {
|
|
@@ -2313,6 +2618,8 @@ function applyImpl(ctx) {
|
|
|
2313
2618
|
for (const route of makeCustomPluginRoutes(host, stateReady)) routeDisposers.push(ctx.webServer.register(route));
|
|
2314
2619
|
host.mermaidFetch().then((result) => {
|
|
2315
2620
|
reportDiag(result.ok ? `mermaid engine ready (${result.bytes} bytes, ${host.mermaidLoadedSource()})` : `mermaid engine failed: ${result.error}`);
|
|
2621
|
+
}).catch((error) => {
|
|
2622
|
+
reportDiag(`mermaid preheat failed: ${String(error?.message ?? error)}`);
|
|
2316
2623
|
});
|
|
2317
2624
|
const disposeTool = ctx.tools.register(defineTool({
|
|
2318
2625
|
name: "custom_plugin_status",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* 天青灰 leads the list: it is the install default and renders first among
|
|
14
14
|
* the palette swatches, right after 无颜色. */
|
|
15
15
|
export declare const PALETTE: Array<[string, string, string]>;
|
|
16
|
+
/** Parse a #rrggbb (or bare rrggbb) hex color; malformed input yields the
|
|
17
|
+
* palette's neutral gray rather than throwing. */
|
|
18
|
+
export declare function hexToRgb(hex: string): [number, number, number];
|
|
16
19
|
/**
|
|
17
20
|
* Map a palette color onto the dark ramp: hue is kept, saturation is
|
|
18
21
|
* compressed by {@link DARK_SATURATION_SCALE}, and lightness is clamped to
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* vx- and must not be scoped by CSS Modules.
|
|
5
5
|
* @module @alexpeng/dsh-custom-plugin/client/styles
|
|
6
6
|
*/
|
|
7
|
-
export declare const STATIC_CSS = "/* dsh-custom-plugin static styles. Every rule is global by design: the UI\n * mounts into product slots and overlays, so class names are prefixed vx-\n * and must not be scoped by CSS Modules. Dynamic rules (body background,\n * global-glass blur) are managed at runtime by a style\n * element in custom.tsx and do not live here. */\n.vx-root {\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 2147483000;\n font-family: ui-sans-serif, system-ui, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;\n }\n .vx-fx {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n .vx-anchor {\n display: inline-block;\n width: 0;\n height: 1px;\n vertical-align: bottom;\n }\n .vx-turn-actions {\n display: inline-flex;\n gap: 4px;\n margin-left: 10px;\n vertical-align: middle;\n align-items: center;\n }\n .vx-chip {\n pointer-events: auto;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 8px;\n padding: 2px 8px;\n font-size: 11px;\n cursor: pointer;\n backdrop-filter: blur(6px);\n text-decoration: none;\n display: inline-flex;\n align-items: center;\n gap: 3px;\n }\n .vx-chip:hover {\n background: rgba(255, 255, 255, .28);\n }\n .vx-link {\n text-decoration: none;\n }\n .vx-glass {\n border-radius: 16px;\n background: rgba(255, 255, 255, .64);\n -webkit-backdrop-filter: blur(9px) saturate(1.22);\n backdrop-filter: blur(9px) saturate(1.22);\n box-shadow: 0 0 1px 1px rgba(17, 17, 26, .07) inset, 0 1px 2px rgba(17, 17, 26, .05) inset, 0px 4px 16px rgba(17, 17, 26, .05), 0px 8px 24px rgba(17, 17, 26, .05), 0px 16px 56px rgba(17, 17, 26, .05);\n }\n @media (prefers-color-scheme: dark) {\n .vx-glass {\n background: rgba(13, 17, 25, .62);\n color: #eef1f7;\n }\n }\n /* Liquid glass: the SVG displacement filter bends the backdrop at the\n surface's edges; the chained blur+saturate keeps text over the middle of\n large panels readable (pure displacement leaves the mid-area untouched,\n which read as \"nothing happened\"). Chromium runs this chain; engines\n without SVG-referencing backdrop filters fall back to frost below. */\n .vx-liquid .vx-glass {\n background: rgba(255, 255, 255, .1);\n backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);\n -webkit-backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);\n }\n @media (prefers-color-scheme: dark) {\n .vx-liquid .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n }\n /* The GUI theme classes are mirrored onto <html> by the client, so the\n liquid fill has to out-rank the theme frost fills *inside* .vx-root as\n well. The previous \".vx-root.* .vx-liquid .vx-glass\" rules never matched\n anything \u2014 vx-liquid lives on <html>, an ANCESTOR of .vx-root, not a\n descendant \u2014 which left the big panels at the 64% frost fill while the\n balance hover (mounted outside .vx-root) sat at 10%: the \"panel is not\n liquid, the balance card is\" report, verbatim. */\n :root.vx-liquid.vx-dark .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n :root.vx-liquid.vx-light .vx-glass {\n background: rgba(255, 255, 255, .1);\n }\n :root.vx-liquid .vx-root.vx-dark .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n :root.vx-liquid .vx-root.vx-light .vx-glass {\n background: rgba(255, 255, 255, .1);\n }\n @supports not (backdrop-filter: url(#vx-lg)) {\n .vx-liquid .vx-glass {\n background: rgba(255, 255, 255, .64);\n backdrop-filter: blur(9px) saturate(1.22);\n -webkit-backdrop-filter: blur(9px) saturate(1.22);\n }\n @media (prefers-color-scheme: dark) {\n .vx-liquid .vx-glass {\n background: rgba(13, 17, 25, .62);\n }\n }\n }\n .vx-balance-wrap {\n display: inline-flex;\n align-items: center;\n position: relative;\n }\n .vx-balance-text {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: 8px;\n font-size: 12.5px;\n color: inherit;\n background: rgba(127, 164, 224, .16);\n border: 1px solid rgba(127, 164, 224, .4);\n cursor: default;\n white-space: nowrap;\n }\n .vx-balance-text:hover {\n background: rgba(127, 164, 224, .28);\n }\n .vx-balance-text.vx-balance-open {\n background: rgba(127, 164, 224, .36);\n border-color: rgba(127, 164, 224, .8);\n }\n .vx-balance-today {\n opacity: .75;\n font-size: 11.5px;\n }\n .vx-balance-hover {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n z-index: 70;\n width: 360px;\n max-height: 480px;\n overflow: auto;\n padding: 12px;\n color: #20242e;\n font-size: 12px;\n pointer-events: auto;\n }\n @media (prefers-color-scheme: dark) {\n .vx-balance-hover {\n color: #e8ebf2;\n }\n }\n .vx-balance-lines {\n font-size: 13px;\n margin: 6px 0;\n }\n .vx-header-btn {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 10px;\n border-radius: 8px;\n font-size: 12.5px;\n color: inherit;\n background: rgba(127, 164, 224, .16);\n border: 1px solid rgba(127, 164, 224, .4);\n cursor: pointer;\n white-space: nowrap;\n }\n .vx-header-btn:hover {\n background: rgba(127, 164, 224, .3);\n }\n .vx-quote-btn {\n position: absolute;\n transform: translate(-50%, -100%);\n pointer-events: auto;\n background: rgba(40, 48, 64, .96);\n color: #eef1f7;\n border: 1px solid rgba(255, 255, 255, .25);\n padding: 5px 12px;\n border-radius: 9px;\n font-size: 12px;\n cursor: pointer;\n box-shadow: 0 6px 18px rgba(0, 0, 0, .28);\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .vx-panel {\n position: absolute;\n width: 430px;\n max-width: calc(100vw - 40px);\n height: min(660px, calc(100vh - 110px));\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n }\n @media (prefers-color-scheme: dark) {\n .vx-panel, .vx-modal, .vx-folders {\n color: #e8ebf2;\n }\n }\n .vx-panel-head {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 14px;\n cursor: move;\n user-select: none;\n border-bottom: 1px solid rgba(150, 160, 180, .25);\n position: relative;\n z-index: 1;\n }\n .vx-panel-title {\n font-weight: 600;\n font-size: 13px;\n }\n .vx-panel-sub {\n font-size: 11px;\n opacity: .62;\n white-space: nowrap;\n }\n .vx-tabs {\n display: flex;\n flex-wrap: wrap;\n gap: 2px;\n padding: 8px 10px 4px;\n border-bottom: 1px solid rgba(150, 160, 180, .2);\n position: relative;\n z-index: 1;\n }\n .vx-tab {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .75;\n font-size: 12px;\n padding: 5px 9px;\n border-radius: 8px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n }\n .vx-tab.on {\n opacity: 1;\n background: rgba(255, 255, 255, .28);\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);\n }\n .vx-panel-body {\n flex: 1;\n overflow: auto;\n padding: 12px 14px;\n position: relative;\n z-index: 1;\n }\n .vx-col {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .vx-row {\n display: flex;\n gap: 8px;\n align-items: center;\n }\n .vx-row.wrap {\n flex-wrap: wrap;\n }\n .vx-flex1 {\n flex: 1;\n }\n .vx-section-title {\n font-weight: 600;\n font-size: 12.5px;\n margin-top: 4px;\n opacity: .9;\n }\n .vx-swatches {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n gap: 6px;\n }\n .vx-swatch {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 3px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n padding: 0;\n }\n .vx-swatch-box {\n width: 34px;\n height: 26px;\n border-radius: 8px;\n border: 2px solid rgba(120, 130, 150, .4);\n box-sizing: border-box;\n }\n .vx-swatch.on .vx-swatch-box {\n border-color: #7fa4e0;\n box-shadow: 0 0 0 2px rgba(127, 164, 224, .35);\n }\n .vx-swatch:disabled {\n opacity: .35;\n cursor: not-allowed;\n }\n .vx-swatch-label {\n font-size: 10px;\n opacity: .85;\n }\n .vx-btn {\n pointer-events: auto;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 9px;\n padding: 6px 12px;\n font-size: 12px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .vx-btn:hover {\n background: rgba(255, 255, 255, .28);\n }\n .vx-btn.on {\n background: rgba(127, 164, 224, .35);\n border-color: rgba(127, 164, 224, .8);\n }\n .vx-btn:disabled {\n opacity: .5;\n cursor: default;\n }\n .vx-btn-sm {\n padding: 2px 8px;\n font-size: 11px;\n }\n .vx-btn-danger {\n background: rgba(214, 88, 88, .22);\n border-color: rgba(214, 88, 88, .55);\n }\n .vx-btn.big {\n padding: 10px 16px;\n font-size: 13px;\n }\n .vx-input {\n flex: 1;\n min-width: 0;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 9px;\n padding: 6px 10px;\n font-size: 12px;\n }\n .vx-textarea {\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 9px;\n padding: 6px 10px;\n font-size: 12px;\n resize: vertical;\n font-family: inherit;\n }\n .vx-toggle-row {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 12.5px;\n }\n .vx-muted {\n color: rgba(120, 128, 148, .95);\n font-size: 11.5px;\n }\n .vx-error {\n color: #d85858;\n font-size: 12px;\n }\n .vx-pad {\n padding: 12px;\n }\n .vx-pad-sm {\n padding: 6px 2px;\n }\n .vx-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n max-height: 300px;\n overflow: auto;\n }\n .vx-list-item {\n text-align: left;\n border: none;\n background: rgba(255, 255, 255, .1);\n color: inherit;\n border-radius: 8px;\n padding: 6px 10px;\n font-size: 12px;\n cursor: pointer;\n }\n .vx-list-item:hover {\n background: rgba(255, 255, 255, .22);\n }\n .vx-list-item.on {\n background: rgba(127, 164, 224, .28);\n box-shadow: inset 0 0 0 1px rgba(127, 164, 224, .45);\n }\n .vx-list-item:disabled {\n opacity: .55;\n cursor: not-allowed;\n }\n .vx-check-row {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 12.5px;\n padding: 4px 2px;\n }\n .vx-check-title {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .vx-badge {\n background: rgba(127, 164, 224, .3);\n border-radius: 8px;\n padding: 0 6px;\n font-size: 10px;\n }\n .vx-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11.5px;\n }\n .vx-table th, .vx-table td {\n border: 1px solid rgba(128, 140, 160, .3);\n padding: 4px 6px;\n text-align: right;\n }\n .vx-table th:first-child, .vx-table td:first-child {\n text-align: left;\n }\n .vx-folder {\n display: flex;\n flex-direction: column;\n }\n .vx-folder-head {\n display: flex;\n gap: 5px;\n align-items: center;\n padding: 5px 4px;\n border-radius: 9px;\n cursor: grab;\n }\n .vx-folder-head:hover {\n background: rgba(255, 255, 255, .14);\n }\n .vx-folder-head.drop-inside {\n background: rgba(127, 164, 224, .3);\n outline: 1px dashed rgba(127, 164, 224, .8);\n }\n .vx-folder-head.drop-before {\n box-shadow: 0 -2px 0 0 rgba(127, 164, 224, .9);\n }\n .vx-folder-head.drop-after {\n box-shadow: 0 2px 0 0 rgba(127, 164, 224, .9);\n }\n .vx-folder-name {\n font-size: 12.5px;\n font-weight: 600;\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .vx-folder-body {\n border-left: 1px dashed rgba(128, 140, 160, .35);\n margin-left: 14px;\n padding-left: 6px;\n display: flex;\n flex-direction: column;\n gap: 2px;\n }\n .vx-item-row {\n display: flex;\n gap: 5px;\n align-items: center;\n padding: 3px 4px;\n border-radius: 8px;\n }\n .vx-item-row:hover {\n background: rgba(255, 255, 255, .12);\n }\n .vx-item-name {\n flex: 1;\n text-align: left;\n border: none;\n background: transparent;\n color: inherit;\n font-size: 12px;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0;\n }\n .vx-mini {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .75;\n cursor: pointer;\n padding: 2px;\n border-radius: 6px;\n display: inline-flex;\n align-items: center;\n }\n .vx-mini:hover {\n opacity: 1;\n background: rgba(255, 255, 255, .2);\n }\n .vx-form {\n display: flex;\n flex-direction: column;\n gap: 6px;\n border: 1px dashed rgba(128, 140, 160, .4);\n border-radius: 10px;\n padding: 8px;\n }\n .vx-prompt-card {\n border: 1px solid rgba(128, 140, 160, .3);\n background: rgba(255, 255, 255, .1);\n border-radius: 10px;\n padding: 8px 10px;\n }\n .vx-prompt-title {\n font-weight: 600;\n font-size: 12.5px;\n }\n .vx-prompt-body {\n margin-top: 4px;\n font-size: 11.5px;\n opacity: .85;\n white-space: pre-wrap;\n word-break: break-word;\n max-height: 72px;\n overflow: hidden;\n }\n .vx-modal-mask {\n position: absolute;\n inset: 0;\n pointer-events: auto;\n background: rgba(8, 10, 16, .4);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 60;\n }\n .vx-modal {\n position: relative;\n width: min(760px, 92vw);\n max-height: 82vh;\n overflow: auto;\n padding: 16px;\n color: #20242e;\n pointer-events: auto;\n }\n .vx-pop-head {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-bottom: 8px;\n font-weight: 600;\n font-size: 13px;\n }\n .vx-svgbox {\n overflow: auto;\n background: rgba(12, 14, 20, .6);\n border-radius: 12px;\n padding: 14px;\n }\n .vx-svgbox svg {\n max-width: 100%;\n height: auto;\n }\n .vx-pre {\n white-space: pre-wrap;\n word-break: break-all;\n font-size: 10.5px;\n opacity: .85;\n }\n .vx-toasts {\n position: absolute;\n left: 50%;\n bottom: 26px;\n transform: translateX(-50%);\n display: flex;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n pointer-events: auto;\n z-index: 80;\n }\n .vx-toast {\n display: flex;\n gap: 10px;\n align-items: center;\n color: #f2f4f8;\n background: rgba(26, 32, 44, .92);\n border: 1px solid rgba(255, 255, 255, .12);\n padding: 8px 14px;\n border-radius: 12px;\n font-size: 12.5px;\n box-shadow: 0 10px 30px rgba(0, 0, 0, .3);\n max-width: 560px;\n backdrop-filter: blur(9px);\n -webkit-backdrop-filter: blur(9px);\n }\n @media (prefers-color-scheme: dark) {\n .vx-toast {\n background: rgba(18, 22, 30, .94);\n }\n }\n .vx-foot-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 1px solid rgba(127, 164, 224, .4);\n background: rgba(127, 164, 224, .14);\n color: inherit;\n cursor: pointer;\n padding: 4px 10px;\n border-radius: 10px;\n margin: 2px;\n }\n .vx-foot-btn:hover {\n background: rgba(127, 164, 224, .3);\n }\n .vx-foot-label {\n font-size: 12px;\n }\n .vx-folders {\n position: fixed;\n left: 12px;\n bottom: 60px;\n width: 272px;\n max-height: min(560px, calc(100vh - 220px));\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n z-index: 55;\n }\n /* \u5934\u90E8\u884C\uFF08\u56FE\u6807 + \u6807\u9898 + \u6309\u94AE\uFF09\u4E0B\u79FB\u5E76\u62C9\u5F00\u4E0E\u5BB9\u5668\u8FB9\u7F18\u7684\u95F4\u8DDD */\n .vx-folders .vx-pop-head {\n padding: 14px 14px 0;\n }\n .vx-folders-body {\n flex: 1;\n overflow: auto;\n padding: 4px 14px 12px;\n position: relative;\n z-index: 1;\n }\n .vx-prompt-pop {\n position: fixed;\n width: 320px;\n max-height: 420px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n z-index: 65;\n padding: 10px 12px;\n }\n .vx-settings-page {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 720px;\n }\n .vx-mmd-wrap {\n position: relative;\n margin: 6px 0;\n border: 1px solid rgba(127, 164, 224, .35);\n border-radius: 12px;\n overflow: hidden;\n background: rgba(127, 164, 224, .05);\n }\n .vx-mmd-bar {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 4px 6px;\n border-bottom: 1px solid rgba(127, 164, 224, .25);\n background: rgba(127, 164, 224, .08);\n }\n .vx-mmd-btn {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .65;\n font-size: 12px;\n padding: 3px 10px;\n border-radius: 8px;\n cursor: pointer;\n }\n .vx-mmd-btn:hover {\n opacity: 1;\n background: rgba(127, 164, 224, .18);\n }\n .vx-mmd-btn.active {\n opacity: 1;\n background: rgba(127, 164, 224, .28);\n font-weight: 600;\n }\n .vx-mmd-live {\n margin-left: auto;\n font-size: 11px;\n opacity: .6;\n color: inherit;\n text-decoration: none;\n padding: 3px 8px;\n }\n .vx-mmd-live:hover {\n opacity: 1;\n }\n .vx-mmd-stage {\n padding: 16px 12px;\n overflow-x: auto;\n text-align: center;\n }\n .vx-mmd-stage svg {\n max-width: 100%;\n height: auto;\n }\n\n /* DSH can select a theme independently of the operating system. The root\n classes are applied from the resolved GUI theme and intentionally win\n over the media-query fallback above. */\n .vx-root.vx-dark .vx-glass {\n background: rgba(13, 17, 25, .62);\n color: #eef1f7;\n }\n .vx-root.vx-dark .vx-balance-hover,\n .vx-root.vx-dark .vx-panel,\n .vx-root.vx-dark .vx-modal,\n .vx-root.vx-dark .vx-folders {\n color: #e8ebf2;\n }\n .vx-root.vx-dark .vx-toast {\n background: rgba(18, 22, 30, .94);\n }\n\n .vx-root.vx-light .vx-glass {\n background: rgba(255, 255, 255, .64);\n color: #20242e;\n }\n .vx-root.vx-light .vx-balance-hover,\n .vx-root.vx-light .vx-panel,\n .vx-root.vx-light .vx-modal,\n .vx-root.vx-light .vx-folders {\n color: #20242e;\n }\n .vx-root.vx-light .vx-toast {\n background: rgba(26, 32, 44, .92);\n }\n}";
|
|
7
|
+
export declare const STATIC_CSS = "/* dsh-custom-plugin static styles. Every rule is global by design: the UI\n * mounts into product slots and overlays, so class names are prefixed vx-\n * and must not be scoped by CSS Modules. Dynamic rules (body background,\n * global-glass blur) are managed at runtime by a style\n * element in custom.tsx and do not live here. */\n.vx-root {\n position: fixed;\n inset: 0;\n pointer-events: none;\n z-index: 2147483000;\n font-family: ui-sans-serif, system-ui, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;\n }\n .vx-fx {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n .vx-anchor {\n display: inline-block;\n width: 0;\n height: 1px;\n vertical-align: bottom;\n }\n .vx-turn-actions {\n display: inline-flex;\n gap: 4px;\n margin-left: 10px;\n vertical-align: middle;\n align-items: center;\n }\n .vx-chip {\n pointer-events: auto;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 8px;\n padding: 2px 8px;\n font-size: 11px;\n cursor: pointer;\n backdrop-filter: blur(6px);\n text-decoration: none;\n display: inline-flex;\n align-items: center;\n gap: 3px;\n }\n .vx-chip:hover {\n background: rgba(255, 255, 255, .28);\n }\n .vx-link {\n text-decoration: none;\n }\n .vx-glass {\n border-radius: 16px;\n background: rgba(255, 255, 255, .64);\n -webkit-backdrop-filter: blur(9px) saturate(1.22);\n backdrop-filter: blur(9px) saturate(1.22);\n box-shadow: 0 0 1px 1px rgba(17, 17, 26, .07) inset, 0 1px 2px rgba(17, 17, 26, .05) inset, 0px 4px 16px rgba(17, 17, 26, .05), 0px 8px 24px rgba(17, 17, 26, .05), 0px 16px 56px rgba(17, 17, 26, .05);\n }\n @media (prefers-color-scheme: dark) {\n .vx-glass {\n background: rgba(13, 17, 25, .62);\n color: #eef1f7;\n }\n }\n /* The GUI theme can disagree with the OS scheme (dsh selects light/dark\n independently \u2014 dark GUI on a light OS left these surfaces frosted\n light), so the frost fills and panel text colors key on the mirrored\n root classes, not the OS alone. The media queries above remain the\n pre-boot fallback, before the client has applied the classes; the liquid\n rules below out-rank these by specificity, not by order. */\n :root.vx-light .vx-glass {\n background: rgba(255, 255, 255, .64);\n color: inherit;\n }\n :root.vx-dark .vx-glass {\n background: rgba(13, 17, 25, .62);\n color: #eef1f7;\n }\n :root.vx-light .vx-panel,\n :root.vx-light .vx-modal,\n :root.vx-light .vx-folders {\n color: #20242e;\n }\n :root.vx-dark .vx-panel,\n :root.vx-dark .vx-modal,\n :root.vx-dark .vx-folders {\n color: #e8ebf2;\n }\n :root.vx-light .vx-balance-hover {\n color: #20242e;\n }\n :root.vx-dark .vx-balance-hover {\n color: #e8ebf2;\n }\n /* Liquid glass: the SVG displacement filter bends the backdrop at the\n surface's edges; the chained blur+saturate keeps text over the middle of\n large panels readable (pure displacement leaves the mid-area untouched,\n which read as \"nothing happened\"). Chromium runs this chain; engines\n without SVG-referencing backdrop filters fall back to frost below. */\n .vx-liquid .vx-glass {\n background: rgba(255, 255, 255, .1);\n backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);\n -webkit-backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);\n }\n @media (prefers-color-scheme: dark) {\n .vx-liquid .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n }\n /* The GUI theme classes are mirrored onto <html> by the client, so the\n liquid fill has to out-rank the theme frost fills *inside* .vx-root as\n well. The previous \".vx-root.* .vx-liquid .vx-glass\" rules never matched\n anything \u2014 vx-liquid lives on <html>, an ANCESTOR of .vx-root, not a\n descendant \u2014 which left the big panels at the 64% frost fill while the\n balance hover (mounted outside .vx-root) sat at 10%: the \"panel is not\n liquid, the balance card is\" report, verbatim. */\n :root.vx-liquid.vx-dark .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n :root.vx-liquid.vx-light .vx-glass {\n background: rgba(255, 255, 255, .1);\n }\n :root.vx-liquid .vx-root.vx-dark .vx-glass {\n background: rgba(0, 0, 0, .1);\n }\n :root.vx-liquid .vx-root.vx-light .vx-glass {\n background: rgba(255, 255, 255, .1);\n }\n @supports not (backdrop-filter: url(#vx-lg)) {\n .vx-liquid .vx-glass {\n background: rgba(255, 255, 255, .64);\n backdrop-filter: blur(9px) saturate(1.22);\n -webkit-backdrop-filter: blur(9px) saturate(1.22);\n }\n @media (prefers-color-scheme: dark) {\n .vx-liquid .vx-glass {\n background: rgba(13, 17, 25, .62);\n }\n }\n }\n .vx-balance-wrap {\n display: inline-flex;\n align-items: center;\n position: relative;\n }\n .vx-balance-text {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 3px 10px;\n border-radius: 8px;\n font-size: 12.5px;\n color: inherit;\n background: rgba(127, 164, 224, .16);\n border: 1px solid rgba(127, 164, 224, .4);\n cursor: default;\n white-space: nowrap;\n }\n .vx-balance-text:hover {\n background: rgba(127, 164, 224, .28);\n }\n .vx-balance-text.vx-balance-open {\n background: rgba(127, 164, 224, .36);\n border-color: rgba(127, 164, 224, .8);\n }\n .vx-balance-today {\n opacity: .75;\n font-size: 11.5px;\n }\n .vx-balance-hover {\n position: absolute;\n top: calc(100% + 8px);\n right: 0;\n z-index: 70;\n width: 360px;\n max-height: 480px;\n overflow: auto;\n padding: 12px;\n color: #20242e;\n font-size: 12px;\n pointer-events: auto;\n }\n @media (prefers-color-scheme: dark) {\n .vx-balance-hover {\n color: #e8ebf2;\n }\n }\n .vx-balance-lines {\n font-size: 13px;\n margin: 6px 0;\n }\n .vx-header-btn {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 10px;\n border-radius: 8px;\n font-size: 12.5px;\n color: inherit;\n background: rgba(127, 164, 224, .16);\n border: 1px solid rgba(127, 164, 224, .4);\n cursor: pointer;\n white-space: nowrap;\n }\n .vx-header-btn:hover {\n background: rgba(127, 164, 224, .3);\n }\n .vx-quote-btn {\n position: absolute;\n transform: translate(-50%, -100%);\n pointer-events: auto;\n background: rgba(40, 48, 64, .96);\n color: #eef1f7;\n border: 1px solid rgba(255, 255, 255, .25);\n padding: 5px 12px;\n border-radius: 9px;\n font-size: 12px;\n cursor: pointer;\n box-shadow: 0 6px 18px rgba(0, 0, 0, .28);\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .vx-panel {\n position: absolute;\n width: 430px;\n max-width: calc(100vw - 40px);\n height: min(660px, calc(100vh - 110px));\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n }\n @media (prefers-color-scheme: dark) {\n .vx-panel, .vx-modal, .vx-folders {\n color: #e8ebf2;\n }\n }\n .vx-panel-head {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 14px;\n cursor: move;\n user-select: none;\n border-bottom: 1px solid rgba(150, 160, 180, .25);\n position: relative;\n z-index: 1;\n }\n .vx-panel-title {\n font-weight: 600;\n font-size: 13px;\n }\n .vx-panel-sub {\n font-size: 11px;\n opacity: .62;\n white-space: nowrap;\n }\n .vx-tabs {\n display: flex;\n flex-wrap: wrap;\n gap: 2px;\n padding: 8px 10px 4px;\n border-bottom: 1px solid rgba(150, 160, 180, .2);\n position: relative;\n z-index: 1;\n }\n .vx-tab {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .75;\n font-size: 12px;\n padding: 5px 9px;\n border-radius: 8px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n }\n .vx-tab.on {\n opacity: 1;\n background: rgba(255, 255, 255, .28);\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);\n }\n .vx-panel-body {\n flex: 1;\n overflow: auto;\n padding: 12px 14px;\n position: relative;\n z-index: 1;\n }\n .vx-col {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .vx-row {\n display: flex;\n gap: 8px;\n align-items: center;\n }\n .vx-row.wrap {\n flex-wrap: wrap;\n }\n .vx-flex1 {\n flex: 1;\n }\n .vx-section-title {\n font-weight: 600;\n font-size: 12.5px;\n margin-top: 4px;\n opacity: .9;\n }\n .vx-swatches {\n display: grid;\n grid-template-columns: repeat(5, 1fr);\n gap: 6px;\n }\n .vx-swatch {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 3px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n padding: 0;\n }\n .vx-swatch-box {\n width: 34px;\n height: 26px;\n border-radius: 8px;\n border: 2px solid rgba(120, 130, 150, .4);\n box-sizing: border-box;\n }\n .vx-swatch.on .vx-swatch-box {\n border-color: #7fa4e0;\n box-shadow: 0 0 0 2px rgba(127, 164, 224, .35);\n }\n .vx-swatch-label {\n font-size: 10px;\n opacity: .85;\n }\n .vx-btn {\n pointer-events: auto;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 9px;\n padding: 6px 12px;\n font-size: 12px;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n }\n .vx-btn:hover {\n background: rgba(255, 255, 255, .28);\n }\n .vx-btn.on {\n background: rgba(127, 164, 224, .35);\n border-color: rgba(127, 164, 224, .8);\n }\n .vx-btn:disabled {\n opacity: .5;\n cursor: default;\n }\n .vx-btn-sm {\n padding: 2px 8px;\n font-size: 11px;\n }\n .vx-btn-danger {\n background: rgba(214, 88, 88, .22);\n border-color: rgba(214, 88, 88, .55);\n }\n .vx-btn.big {\n padding: 10px 16px;\n font-size: 13px;\n }\n .vx-input {\n flex: 1;\n min-width: 0;\n border: 1px solid rgba(128, 140, 160, .4);\n background: rgba(255, 255, 255, .16);\n color: inherit;\n border-radius: 9px;\n padding: 6px 10px;\n font-size: 12px;\n }\n .vx-toggle-row {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 12.5px;\n }\n .vx-muted {\n color: rgba(120, 128, 148, .95);\n font-size: 11.5px;\n }\n .vx-error {\n color: #d85858;\n font-size: 12px;\n }\n .vx-pad {\n padding: 12px;\n }\n .vx-pad-sm {\n padding: 6px 2px;\n }\n .vx-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n max-height: 300px;\n overflow: auto;\n }\n .vx-list-item {\n text-align: left;\n border: none;\n background: rgba(255, 255, 255, .1);\n color: inherit;\n border-radius: 8px;\n padding: 6px 10px;\n font-size: 12px;\n cursor: pointer;\n }\n .vx-list-item:hover {\n background: rgba(255, 255, 255, .22);\n }\n .vx-list-item.on {\n background: rgba(127, 164, 224, .28);\n box-shadow: inset 0 0 0 1px rgba(127, 164, 224, .45);\n }\n .vx-list-item:disabled {\n opacity: .55;\n cursor: not-allowed;\n }\n .vx-check-row {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 12.5px;\n padding: 4px 2px;\n }\n .vx-check-title {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .vx-badge {\n background: rgba(127, 164, 224, .3);\n border-radius: 8px;\n padding: 0 6px;\n font-size: 10px;\n }\n .vx-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11.5px;\n }\n .vx-table th, .vx-table td {\n border: 1px solid rgba(128, 140, 160, .3);\n padding: 4px 6px;\n text-align: right;\n }\n .vx-table th:first-child, .vx-table td:first-child {\n text-align: left;\n }\n .vx-folder {\n display: flex;\n flex-direction: column;\n }\n .vx-folder-head {\n display: flex;\n gap: 5px;\n align-items: center;\n padding: 5px 4px;\n border-radius: 9px;\n cursor: grab;\n }\n .vx-folder-head:hover {\n background: rgba(255, 255, 255, .14);\n }\n .vx-folder-head.drop-inside {\n background: rgba(127, 164, 224, .3);\n outline: 1px dashed rgba(127, 164, 224, .8);\n }\n .vx-folder-head.drop-before {\n box-shadow: 0 -2px 0 0 rgba(127, 164, 224, .9);\n }\n .vx-folder-head.drop-after {\n box-shadow: 0 2px 0 0 rgba(127, 164, 224, .9);\n }\n .vx-folder-name {\n font-size: 12.5px;\n font-weight: 600;\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .vx-folder-body {\n border-left: 1px dashed rgba(128, 140, 160, .35);\n margin-left: 14px;\n padding-left: 6px;\n display: flex;\n flex-direction: column;\n gap: 2px;\n }\n .vx-item-row {\n display: flex;\n gap: 5px;\n align-items: center;\n padding: 3px 4px;\n border-radius: 8px;\n }\n .vx-item-row:hover {\n background: rgba(255, 255, 255, .12);\n }\n .vx-item-name {\n flex: 1;\n text-align: left;\n border: none;\n background: transparent;\n color: inherit;\n font-size: 12px;\n cursor: pointer;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0;\n }\n .vx-mini {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .75;\n cursor: pointer;\n padding: 2px;\n border-radius: 6px;\n display: inline-flex;\n align-items: center;\n }\n .vx-mini:hover {\n opacity: 1;\n background: rgba(255, 255, 255, .2);\n }\n .vx-form {\n display: flex;\n flex-direction: column;\n gap: 6px;\n border: 1px dashed rgba(128, 140, 160, .4);\n border-radius: 10px;\n padding: 8px;\n }\n .vx-prompt-card {\n border: 1px solid rgba(128, 140, 160, .3);\n background: rgba(255, 255, 255, .1);\n border-radius: 10px;\n padding: 8px 10px;\n }\n .vx-prompt-title {\n font-weight: 600;\n font-size: 12.5px;\n }\n .vx-prompt-body {\n margin-top: 4px;\n font-size: 11.5px;\n opacity: .85;\n white-space: pre-wrap;\n word-break: break-word;\n max-height: 72px;\n overflow: hidden;\n }\n .vx-modal-mask {\n position: absolute;\n inset: 0;\n pointer-events: auto;\n background: rgba(8, 10, 16, .4);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 60;\n }\n .vx-modal {\n position: relative;\n width: min(760px, 92vw);\n max-height: 82vh;\n overflow: auto;\n padding: 16px;\n color: #20242e;\n pointer-events: auto;\n }\n .vx-pop-head {\n display: flex;\n gap: 8px;\n align-items: center;\n margin-bottom: 8px;\n font-weight: 600;\n font-size: 13px;\n }\n .vx-svgbox {\n overflow: auto;\n background: rgba(12, 14, 20, .6);\n border-radius: 12px;\n padding: 14px;\n }\n .vx-svgbox svg {\n max-width: 100%;\n height: auto;\n }\n .vx-pre {\n white-space: pre-wrap;\n word-break: break-all;\n font-size: 10.5px;\n opacity: .85;\n }\n .vx-toasts {\n position: absolute;\n left: 50%;\n bottom: 26px;\n transform: translateX(-50%);\n display: flex;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n pointer-events: auto;\n z-index: 80;\n }\n .vx-toast {\n display: flex;\n gap: 10px;\n align-items: center;\n color: #f2f4f8;\n background: rgba(26, 32, 44, .92);\n border: 1px solid rgba(255, 255, 255, .12);\n padding: 8px 14px;\n border-radius: 12px;\n font-size: 12.5px;\n box-shadow: 0 10px 30px rgba(0, 0, 0, .3);\n max-width: 560px;\n backdrop-filter: blur(9px);\n -webkit-backdrop-filter: blur(9px);\n }\n @media (prefers-color-scheme: dark) {\n .vx-toast {\n background: rgba(18, 22, 30, .94);\n }\n }\n .vx-foot-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 1px solid rgba(127, 164, 224, .4);\n background: rgba(127, 164, 224, .14);\n color: inherit;\n cursor: pointer;\n padding: 4px 10px;\n border-radius: 10px;\n margin: 2px;\n }\n .vx-foot-btn:hover {\n background: rgba(127, 164, 224, .3);\n }\n .vx-foot-label {\n font-size: 12px;\n }\n .vx-folders {\n position: fixed;\n left: 12px;\n bottom: 60px;\n width: 272px;\n max-height: min(560px, calc(100vh - 220px));\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n z-index: 55;\n }\n /* \u5934\u90E8\u884C\uFF08\u56FE\u6807 + \u6807\u9898 + \u6309\u94AE\uFF09\u4E0B\u79FB\u5E76\u62C9\u5F00\u4E0E\u5BB9\u5668\u8FB9\u7F18\u7684\u95F4\u8DDD */\n .vx-folders .vx-pop-head {\n padding: 14px 14px 0;\n }\n .vx-folders-body {\n flex: 1;\n overflow: auto;\n padding: 4px 14px 12px;\n position: relative;\n z-index: 1;\n }\n .vx-prompt-pop {\n position: fixed;\n width: 320px;\n max-height: 420px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n pointer-events: auto;\n color: #20242e;\n z-index: 65;\n padding: 10px 12px;\n }\n .vx-settings-page {\n display: flex;\n flex-direction: column;\n gap: 14px;\n max-width: 720px;\n }\n .vx-mmd-wrap {\n position: relative;\n margin: 6px 0;\n border: 1px solid rgba(127, 164, 224, .35);\n border-radius: 12px;\n overflow: hidden;\n background: rgba(127, 164, 224, .05);\n }\n .vx-mmd-bar {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 4px 6px;\n border-bottom: 1px solid rgba(127, 164, 224, .25);\n background: rgba(127, 164, 224, .08);\n }\n .vx-mmd-btn {\n border: none;\n background: transparent;\n color: inherit;\n opacity: .65;\n font-size: 12px;\n padding: 3px 10px;\n border-radius: 8px;\n cursor: pointer;\n }\n .vx-mmd-btn:hover {\n opacity: 1;\n background: rgba(127, 164, 224, .18);\n }\n .vx-mmd-btn.active {\n opacity: 1;\n background: rgba(127, 164, 224, .28);\n font-weight: 600;\n }\n .vx-mmd-live {\n margin-left: auto;\n font-size: 11px;\n opacity: .6;\n color: inherit;\n text-decoration: none;\n padding: 3px 8px;\n }\n .vx-mmd-live:hover {\n opacity: 1;\n }\n .vx-mmd-stage {\n padding: 16px 12px;\n overflow-x: auto;\n text-align: center;\n }\n .vx-mmd-stage svg {\n max-width: 100%;\n height: auto;\n }\n\n /* DSH can select a theme independently of the operating system. The root\n classes are applied from the resolved GUI theme and intentionally win\n over the media-query fallback above. */\n .vx-root.vx-dark .vx-glass {\n background: rgba(13, 17, 25, .62);\n color: #eef1f7;\n }\n .vx-root.vx-dark .vx-balance-hover,\n .vx-root.vx-dark .vx-panel,\n .vx-root.vx-dark .vx-modal,\n .vx-root.vx-dark .vx-folders {\n color: #e8ebf2;\n }\n .vx-root.vx-dark .vx-toast {\n background: rgba(18, 22, 30, .94);\n }\n\n .vx-root.vx-light .vx-glass {\n background: rgba(255, 255, 255, .64);\n color: #20242e;\n }\n .vx-root.vx-light .vx-balance-hover,\n .vx-root.vx-light .vx-panel,\n .vx-root.vx-light .vx-modal,\n .vx-root.vx-light .vx-folders {\n color: #20242e;\n }\n .vx-root.vx-light .vx-toast {\n background: rgba(26, 32, 44, .92);\n }\n";
|
|
@@ -71,6 +71,8 @@ export declare class CustomPluginHost {
|
|
|
71
71
|
private mermaidSource;
|
|
72
72
|
private localMermaidPath;
|
|
73
73
|
private readCredential;
|
|
74
|
+
private credentialCache;
|
|
75
|
+
private static readonly CREDENTIAL_CACHE_TTL_MS;
|
|
74
76
|
constructor(options: CustomPluginHostOptions);
|
|
75
77
|
/** Persisted state document (debounced by the loader entry). */
|
|
76
78
|
persist(): Promise<void>;
|
package/lib/types/state.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* on the temp file.
|
|
10
10
|
* @module @alexpeng/dsh-custom-plugin/state
|
|
11
11
|
*/
|
|
12
|
-
import { type CustomPluginConfig, type CustomPluginState, type PromptItem } from './protocol.ts';
|
|
12
|
+
import { type CustomPluginConfig, type CustomPluginState, type FolderNode, type PromptItem, type StarsMap } from './protocol.ts';
|
|
13
13
|
/** State file name of this plugin. */
|
|
14
14
|
export declare const STATE_FILE = "custom-plugin-state.json";
|
|
15
15
|
/** Default state document. */
|
|
@@ -20,8 +20,29 @@ export declare function normalizeCfg(raw: unknown): CustomPluginConfig;
|
|
|
20
20
|
export declare function normalizePrompt(raw: unknown): PromptItem | null;
|
|
21
21
|
/** Merge a persisted document into the default state, ignoring unknown shapes. */
|
|
22
22
|
export declare function mergeState(target: CustomPluginState, raw: unknown): void;
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Validate a folder tree from the browser against the persisted shape:
|
|
25
|
+
* unique non-empty ids, string name, and string-only id lists, bounded in
|
|
26
|
+
* depth and node count. Null on any violation — the caller rejects the edit.
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeFolders(raw: unknown): FolderNode[] | null;
|
|
29
|
+
/**
|
|
30
|
+
* Validate a star map from the browser: session ids as safe object keys,
|
|
31
|
+
* digit-string sequence keys, `true` values only, bounded total. Null on any
|
|
32
|
+
* violation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeStars(raw: unknown): StarsMap | null;
|
|
35
|
+
/**
|
|
36
|
+
* Load and merge the persisted document into `state`.
|
|
37
|
+
*
|
|
38
|
+
* A missing file (ENOENT) is a fresh install and resolves with defaults. A
|
|
39
|
+
* corrupt or permanently unreadable file is renamed aside before defaults
|
|
40
|
+
* are adopted, so the caller's immediate save cannot destroy the previous
|
|
41
|
+
* bytes. Only when the file is unreadable AND cannot be moved aside does
|
|
42
|
+
* this reject — the caller must then suppress saves, because persisting
|
|
43
|
+
* never-loaded defaults would clobber a document that may be intact.
|
|
44
|
+
*/
|
|
45
|
+
export declare function loadStateFile(state: CustomPluginState, home?: string, retryDelays?: readonly number[]): Promise<string>;
|
|
25
46
|
/**
|
|
26
47
|
* Temp name for an atomic replace, qualified by the writing process.
|
|
27
48
|
*
|
|
@@ -33,5 +54,7 @@ export declare function loadStateFile(state: CustomPluginState, home?: string):
|
|
|
33
54
|
export declare function tempPathFor(target: string, pid?: number): string;
|
|
34
55
|
/** Atomically persist the state document. Saves to the same path are
|
|
35
56
|
* serialized: a caller awaits its own turn's completion, a failed turn never
|
|
36
|
-
* poisons the queue behind it.
|
|
57
|
+
* poisons the queue behind it. Before writing, another host's changes since
|
|
58
|
+
* this process last loaded or saved the file are merged back in (see
|
|
59
|
+
* `mergeExternalChanges`). */
|
|
37
60
|
export declare function saveStateFile(state: CustomPluginState, home?: string): Promise<void>;
|