@alexpeng/dsh-custom-plugin 0.4.2 → 0.6.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/CHANGELOG.md +282 -0
- package/README.i18n.yaml +2 -2
- package/README.md +93 -6
- package/README.zh.md +75 -6
- package/icon.svg +29 -0
- package/lib/client.js +159 -74
- package/lib/client.js.map +1 -1
- package/lib/index.js +154 -46
- package/lib/types/client/custom.d.ts +44 -7
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/extract.d.ts +16 -0
- package/lib/types/host-service.d.ts +7 -1
- package/lib/types/protocol.d.ts +2 -0
- package/lib/types/state.d.ts +9 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +27 -17
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, writeFile } from "node:fs/promises";
|
|
5
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
//#region src/dsh-home.ts
|
|
8
8
|
/**
|
|
@@ -328,11 +328,22 @@ async function loadStateFile(state, home = dshHome()) {
|
|
|
328
328
|
pruneUsage(state.usage);
|
|
329
329
|
return statePath;
|
|
330
330
|
}
|
|
331
|
-
/** In-flight save per state path: concurrent saves queue instead of racing
|
|
332
|
-
*
|
|
331
|
+
/** In-flight save per state path: concurrent saves queue instead of racing on
|
|
332
|
+
* the rename order. Two writers renaming one temp file is the Windows
|
|
333
333
|
* EPERM/EBUSY source; queuing also coalesces naturally, because each turn
|
|
334
334
|
* serializes the live document when it runs, not when it was requested. */
|
|
335
335
|
const saveQueues = /* @__PURE__ */ new Map();
|
|
336
|
+
/**
|
|
337
|
+
* Temp name for an atomic replace, qualified by the writing process.
|
|
338
|
+
*
|
|
339
|
+
* The queue above is per-process, but `$DSH_HOME` is not: dsh Web and dsh
|
|
340
|
+
* Desktop both run hosts against one home (separate profiles, one `$DSH_HOME`),
|
|
341
|
+
* so a fixed temp name would let the two hosts write and rename the same file
|
|
342
|
+
* and hand each other a partially written document.
|
|
343
|
+
*/
|
|
344
|
+
function tempPathFor(target, pid = process.pid) {
|
|
345
|
+
return `${target}.${pid}.tmp`;
|
|
346
|
+
}
|
|
336
347
|
/** Atomically persist the state document. Saves to the same path are
|
|
337
348
|
* serialized: a caller awaits its own turn's completion, a failed turn never
|
|
338
349
|
* poisons the queue behind it. */
|
|
@@ -340,9 +351,14 @@ function saveStateFile(state, home = dshHome()) {
|
|
|
340
351
|
const statePath = join(home, STATE_FILE);
|
|
341
352
|
const turn = (saveQueues.get(statePath) ?? Promise.resolve()).catch(() => {}).then(async () => {
|
|
342
353
|
await mkdir(dirname(statePath), { recursive: true });
|
|
343
|
-
const tmpPath = statePath
|
|
344
|
-
|
|
345
|
-
|
|
354
|
+
const tmpPath = tempPathFor(statePath);
|
|
355
|
+
try {
|
|
356
|
+
await writeFile(tmpPath, JSON.stringify(state), "utf8");
|
|
357
|
+
await rename(tmpPath, statePath);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
await rm(tmpPath, { force: true }).catch(() => {});
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
346
362
|
});
|
|
347
363
|
saveQueues.set(statePath, turn);
|
|
348
364
|
return turn.finally(() => {
|
|
@@ -376,14 +392,17 @@ function blockText(block) {
|
|
|
376
392
|
switch (block.type) {
|
|
377
393
|
case "text":
|
|
378
394
|
case "reasoning": return String(block.text ?? "");
|
|
379
|
-
case "image": return "[图片]";
|
|
395
|
+
case "image": return block.offloaded === true ? "[图片(已折叠)]" : "[图片]";
|
|
396
|
+
case "file": return `[文件 ${block.attachment?.name ?? ""}]`;
|
|
380
397
|
case "tool-call": return `[调用工具 ${block.name ?? ""}]`;
|
|
381
|
-
case "tool-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
398
|
+
case "tool-addition": return `[启用工具 ${block.toolName ?? ""}]`;
|
|
399
|
+
case "tool-removal": return `[移除工具 ${block.toolName ?? ""}]`;
|
|
400
|
+
default: {
|
|
401
|
+
const raw = block;
|
|
402
|
+
if (!Array.isArray(raw.content)) return "";
|
|
403
|
+
const inner = raw.content.map((item) => blockText(item)).join("");
|
|
404
|
+
return raw.toolCallId !== void 0 ? `[工具结果] ${inner.slice(0, 240)}` : inner;
|
|
385
405
|
}
|
|
386
|
-
default: return "";
|
|
387
406
|
}
|
|
388
407
|
}
|
|
389
408
|
/** Flatten a message content array into plain display text. */
|
|
@@ -401,6 +420,43 @@ function flagsOf(text) {
|
|
|
401
420
|
hasMermaid: text.includes("```mermaid")
|
|
402
421
|
};
|
|
403
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* Searchable text of one event, flattened the same way the export does it.
|
|
425
|
+
* The session-query index is opt-in on current dsh deployments, so the search
|
|
426
|
+
* route falls back to scanning this text over the log it already read.
|
|
427
|
+
*/
|
|
428
|
+
function eventSearchText(event) {
|
|
429
|
+
switch (event.type) {
|
|
430
|
+
case "user/message": return messageText(event.data.content);
|
|
431
|
+
case "assistant/message":
|
|
432
|
+
case "system/message":
|
|
433
|
+
case "developer/message": return messageText(event.data.message.content);
|
|
434
|
+
case "tool/call": return `${event.data.name ?? ""} ${event.data.arguments ?? ""}`;
|
|
435
|
+
case "tool/result": return messageText(event.data.message?.content);
|
|
436
|
+
default: return "";
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/** Which conversation role a search hit belongs to, or null when it is not one. */
|
|
440
|
+
function searchKindOf(type) {
|
|
441
|
+
if (type === "user/message") return "user";
|
|
442
|
+
if (type === "assistant/message") return "assistant";
|
|
443
|
+
if (type.startsWith("tool/")) return "tool";
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Excerpt centered on the match, with the window extended so the whole match
|
|
448
|
+
* fits. The centering already covers ordinary queries (the match starts 1/3 of
|
|
449
|
+
* the window in, so it fits while the query is shorter than the remaining 2/3);
|
|
450
|
+
* the extension only binds for a pasted query longer than that, which would
|
|
451
|
+
* otherwise be cut off and leave a highlighted-but-invisible result row.
|
|
452
|
+
*/
|
|
453
|
+
function snippetAround(text, at, needleLength, max) {
|
|
454
|
+
const start = Math.max(0, at - Math.floor(max / 3));
|
|
455
|
+
const end = Math.min(text.length, Math.max(start + max, at + needleLength));
|
|
456
|
+
const lead = start > 0 ? "…" : "";
|
|
457
|
+
const tail = end < text.length ? "…" : "";
|
|
458
|
+
return lead + text.slice(start, end).replace(/\s+/g, " ").trim() + tail;
|
|
459
|
+
}
|
|
404
460
|
/** Extract one timeline node per direct user message from a session log. */
|
|
405
461
|
function extractTurns(events) {
|
|
406
462
|
const items = [];
|
|
@@ -482,7 +538,14 @@ async function buildExportRows(snapshot, format, readImage) {
|
|
|
482
538
|
text: text.slice(0, 2e3),
|
|
483
539
|
images: []
|
|
484
540
|
});
|
|
485
|
-
} else if (event.type === "
|
|
541
|
+
} else if (event.type === "system/message" || event.type === "developer/message") rows.push({
|
|
542
|
+
seq: event.seq,
|
|
543
|
+
time: event.time,
|
|
544
|
+
kind: "context",
|
|
545
|
+
text: messageText(event.data.message.content).slice(0, 2e3),
|
|
546
|
+
images: []
|
|
547
|
+
});
|
|
548
|
+
else if (event.type === "assistant/message") {
|
|
486
549
|
const message = event.data.message;
|
|
487
550
|
rows.push({
|
|
488
551
|
seq: event.seq,
|
|
@@ -501,13 +564,13 @@ async function buildExportRows(snapshot, format, readImage) {
|
|
|
501
564
|
toolArgs: event.data.arguments ?? ""
|
|
502
565
|
});
|
|
503
566
|
} else if (event.type === "tool/result") {
|
|
504
|
-
const callId = event.data.message?.source?.callId;
|
|
567
|
+
const callId = event.data.message?.toolCallId ?? event.data.message?.source?.callId;
|
|
505
568
|
rows.push({
|
|
506
569
|
seq: event.seq,
|
|
507
570
|
time: event.time,
|
|
508
571
|
kind: "tool-result",
|
|
509
572
|
toolName: (callId !== void 0 ? callNames.get(String(callId)) : void 0) ?? "",
|
|
510
|
-
text: messageText(event.data.message
|
|
573
|
+
text: messageText(event.data.message?.content).slice(0, 3e3)
|
|
511
574
|
});
|
|
512
575
|
}
|
|
513
576
|
}
|
|
@@ -960,7 +1023,7 @@ function importedState(current, backup, mode) {
|
|
|
960
1023
|
}
|
|
961
1024
|
async function writeRecoveryBackup(path, state) {
|
|
962
1025
|
const target = path + ".backup.json";
|
|
963
|
-
const temporary = target
|
|
1026
|
+
const temporary = tempPathFor(target);
|
|
964
1027
|
await writeFile(temporary, JSON.stringify(createBackup(state), null, 2), "utf8");
|
|
965
1028
|
await rename(temporary, target);
|
|
966
1029
|
return target;
|
|
@@ -1027,13 +1090,14 @@ var CustomPluginHost = class {
|
|
|
1027
1090
|
* live/restore paths without that constructor, so fall back to it before
|
|
1028
1091
|
* surfacing the error. */
|
|
1029
1092
|
async readSessionLog(sessionId) {
|
|
1093
|
+
const id = sessionId;
|
|
1030
1094
|
try {
|
|
1031
|
-
return await this.sessionQuery.readSession(
|
|
1095
|
+
return await this.sessionQuery.readSession(id);
|
|
1032
1096
|
} catch (error) {
|
|
1033
|
-
const
|
|
1034
|
-
if (typeof
|
|
1035
|
-
const lease = await
|
|
1036
|
-
const events = [...lease.events
|
|
1097
|
+
const { observeSession } = this.sessionQuery;
|
|
1098
|
+
if (typeof observeSession !== "function") throw error;
|
|
1099
|
+
const lease = await observeSession.call(this.sessionQuery, id, { projectionMode: "none" });
|
|
1100
|
+
const events = [...lease.events];
|
|
1037
1101
|
const disposeSymbol = Symbol.dispose;
|
|
1038
1102
|
if (disposeSymbol !== void 0) {
|
|
1039
1103
|
const dispose = lease[disposeSymbol];
|
|
@@ -1372,33 +1436,52 @@ var CustomPluginHost = class {
|
|
|
1372
1436
|
source: "none"
|
|
1373
1437
|
};
|
|
1374
1438
|
}
|
|
1375
|
-
/** Search one session
|
|
1439
|
+
/** Search one session and bind hits to a user-turn anchor.
|
|
1440
|
+
*
|
|
1441
|
+
* DSH's indexed event search is the preferred path, but its shipped web
|
|
1442
|
+
* profile composes `session-query-sqlite` with `openAt: never`, so the index
|
|
1443
|
+
* is absent by default and `searchEvents()` rejects. The full log is read for
|
|
1444
|
+
* the anchor map anyway, so a rejected index degrades to a literal scan of
|
|
1445
|
+
* that log instead of failing the whole feature. */
|
|
1376
1446
|
async conversationSearch(sessionId, query, kinds) {
|
|
1377
1447
|
const wanted = new Set(kinds.length > 0 ? kinds : [
|
|
1378
1448
|
"user",
|
|
1379
1449
|
"assistant",
|
|
1380
1450
|
"tool"
|
|
1381
1451
|
]);
|
|
1452
|
+
const eventTypes = kinds.length > 0 ? kinds.flatMap((kind) => kind === "user" ? ["user/message"] : kind === "assistant" ? ["assistant/message"] : ["tool/call", "tool/result"]) : [];
|
|
1453
|
+
const request = {
|
|
1454
|
+
sessionId,
|
|
1455
|
+
query,
|
|
1456
|
+
limit: 100,
|
|
1457
|
+
...eventTypes.length > 0 ? { filters: [{
|
|
1458
|
+
kind: "type",
|
|
1459
|
+
values: eventTypes
|
|
1460
|
+
}] } : {}
|
|
1461
|
+
};
|
|
1462
|
+
const indexRead = Promise.resolve().then(() => this.sessionQuery.searchEvents(request)).then((page) => page, () => null);
|
|
1463
|
+
let snapshot;
|
|
1464
|
+
let page;
|
|
1382
1465
|
try {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1466
|
+
const both = await Promise.all([this.readSessionLog(sessionId), indexRead]);
|
|
1467
|
+
snapshot = both[0];
|
|
1468
|
+
page = both[1];
|
|
1469
|
+
} catch (error) {
|
|
1470
|
+
return {
|
|
1471
|
+
ok: false,
|
|
1472
|
+
error: String(error?.message ?? error)
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
1476
|
+
let anchor;
|
|
1477
|
+
for (const event of snapshot.events) {
|
|
1478
|
+
if (event.type === "user/message") anchor = event.seq;
|
|
1479
|
+
if (anchor !== void 0) anchors.set(event.seq, anchor);
|
|
1480
|
+
}
|
|
1481
|
+
const items = [];
|
|
1482
|
+
if (page !== null) {
|
|
1400
1483
|
for (const hit of page.items) {
|
|
1401
|
-
const kind = hit.type
|
|
1484
|
+
const kind = searchKindOf(hit.type);
|
|
1402
1485
|
if (kind === null || !wanted.has(kind)) continue;
|
|
1403
1486
|
const anchorSeq = anchors.get(hit.seq);
|
|
1404
1487
|
if (anchorSeq === void 0) continue;
|
|
@@ -1414,14 +1497,39 @@ var CustomPluginHost = class {
|
|
|
1414
1497
|
return {
|
|
1415
1498
|
ok: true,
|
|
1416
1499
|
items,
|
|
1417
|
-
hasMore: page.nextCursor !== void 0
|
|
1418
|
-
|
|
1419
|
-
} catch (error) {
|
|
1420
|
-
return {
|
|
1421
|
-
ok: false,
|
|
1422
|
-
error: String(error?.message ?? error)
|
|
1500
|
+
hasMore: page.nextCursor !== void 0,
|
|
1501
|
+
source: "index"
|
|
1423
1502
|
};
|
|
1424
1503
|
}
|
|
1504
|
+
const needle = query.toLowerCase();
|
|
1505
|
+
let truncated = false;
|
|
1506
|
+
for (const event of snapshot.events) {
|
|
1507
|
+
const kind = searchKindOf(event.type);
|
|
1508
|
+
if (kind === null || !wanted.has(kind)) continue;
|
|
1509
|
+
const anchorSeq = anchors.get(event.seq);
|
|
1510
|
+
if (anchorSeq === void 0) continue;
|
|
1511
|
+
const text = eventSearchText(event);
|
|
1512
|
+
const at = text.toLowerCase().indexOf(needle);
|
|
1513
|
+
if (at < 0) continue;
|
|
1514
|
+
if (items.length >= 100) {
|
|
1515
|
+
truncated = true;
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
items.push({
|
|
1519
|
+
sessionId,
|
|
1520
|
+
seq: event.seq,
|
|
1521
|
+
anchorSeq,
|
|
1522
|
+
kind,
|
|
1523
|
+
time: event.time,
|
|
1524
|
+
snippet: snippetAround(text, at, needle.length, 500)
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
return {
|
|
1528
|
+
ok: true,
|
|
1529
|
+
items,
|
|
1530
|
+
hasMore: truncated,
|
|
1531
|
+
source: "scan"
|
|
1532
|
+
};
|
|
1425
1533
|
}
|
|
1426
1534
|
async resolveApiKey() {
|
|
1427
1535
|
return (await this.resolveApiKeyWithSource()).key;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* @module @alexpeng/dsh-custom-plugin/client/custom
|
|
11
11
|
*/
|
|
12
12
|
import type { SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots';
|
|
13
|
-
import type { SessionListState, TurnLocation, WorkspaceListState } from '@deepseek-ai/dsh-client-runtime/client';
|
|
14
13
|
import type { Context } from '@deepseek-ai/cordis';
|
|
15
14
|
/** Minimal input-state face the input dock owner provides. */
|
|
16
15
|
interface InputStateLike {
|
|
@@ -20,24 +19,62 @@ interface InputStateLike {
|
|
|
20
19
|
interface InputActionsLike {
|
|
21
20
|
setDraft(text: string, editRange?: unknown): void;
|
|
22
21
|
}
|
|
22
|
+
/** Minimal workspace row face (official WorkspaceView carries workspaceId). */
|
|
23
|
+
interface WorkspaceRowLike {
|
|
24
|
+
workspaceId: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The slot-prop data shapes below are declared locally on purpose: the harness
|
|
30
|
+
* controller packages that own them rename and re-shape them across releases,
|
|
31
|
+
* and importing their types would couple this bundle to modules it never loads
|
|
32
|
+
* at runtime. Only the fields actually read are declared.
|
|
33
|
+
*/
|
|
34
|
+
/** One Session row of the `useSessions()` list snapshot. */
|
|
35
|
+
interface SessionRowLike {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly displayTitle?: string;
|
|
38
|
+
readonly title?: string;
|
|
39
|
+
readonly running?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** The `useSessions()` snapshot. `phase` is monotone: `ready` never steps back. */
|
|
42
|
+
interface SessionListLike {
|
|
43
|
+
readonly ids: readonly string[];
|
|
44
|
+
readonly byId: Readonly<Record<string, SessionRowLike>>;
|
|
45
|
+
readonly phase: 'pending' | 'ready';
|
|
46
|
+
}
|
|
47
|
+
/** The `useWorkspaces()` snapshot. */
|
|
48
|
+
interface WorkspaceListLike {
|
|
49
|
+
readonly items?: readonly WorkspaceRowLike[];
|
|
50
|
+
readonly state: 'idle' | 'loading' | 'error';
|
|
51
|
+
}
|
|
52
|
+
/** Turn placement the Chat turnTail slot hands to its entries. */
|
|
53
|
+
interface TurnLocationLike {
|
|
54
|
+
readonly turn: number;
|
|
55
|
+
readonly status?: 'open' | 'closed' | 'unknown';
|
|
56
|
+
}
|
|
57
|
+
/** Standard prop every `scope: 'session'` slot entry receives. */
|
|
58
|
+
interface SessionScopedProps {
|
|
59
|
+
readonly sessionId?: string | null;
|
|
60
|
+
}
|
|
23
61
|
/** Palette of 20 muted low-saturation backgrounds (with matching tab colors).
|
|
24
62
|
* 天青灰 leads the list: it is the install default and renders first among
|
|
25
63
|
* the palette swatches, right after 无颜色 / 极光. */
|
|
26
64
|
export declare const PALETTE: Array<[string, string, string]>;
|
|
27
65
|
/** Public component props (the product slot system injects these). */
|
|
28
66
|
export interface OverlayProps {
|
|
29
|
-
useSessions: SnapshotSelectorHook<
|
|
30
|
-
useWorkspaces: SnapshotSelectorHook<
|
|
67
|
+
useSessions: SnapshotSelectorHook<SessionListLike>;
|
|
68
|
+
useWorkspaces: SnapshotSelectorHook<WorkspaceListLike>;
|
|
31
69
|
}
|
|
32
|
-
export interface QuoteDockProps {
|
|
70
|
+
export interface QuoteDockProps extends SessionScopedProps {
|
|
33
71
|
input: InputStateLike;
|
|
34
72
|
inputActions: InputActionsLike;
|
|
35
73
|
}
|
|
36
|
-
export interface TurnTailProps {
|
|
37
|
-
turn:
|
|
74
|
+
export interface TurnTailProps extends SessionScopedProps {
|
|
75
|
+
turn: TurnLocationLike;
|
|
38
76
|
seq: number;
|
|
39
77
|
openFile: (path: string) => void;
|
|
40
|
-
matched?: number | null;
|
|
41
78
|
}
|
|
42
79
|
/** Install the whole Custom UI into the client context. Returns a disposer that unregisters every slot entry. */
|
|
43
80
|
export declare function installCustomPlugin(ctx: Context, reportDiag: (message: string) => void): () => void;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* additions.
|
|
11
11
|
* @module @alexpeng/dsh-custom-plugin/client
|
|
12
12
|
*/
|
|
13
|
-
import type { ClientContext } from '@deepseek-ai/
|
|
13
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
14
14
|
/**
|
|
15
15
|
* Required services. Deliberately empty: the mount waits on `slots` inside
|
|
16
16
|
* `apply` (a child fiber) instead of declaring it here, so this entry can
|
package/lib/types/extract.d.ts
CHANGED
|
@@ -24,6 +24,22 @@ export declare function flagsOf(text: string): {
|
|
|
24
24
|
hasMathml: boolean;
|
|
25
25
|
hasMermaid: boolean;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Searchable text of one event, flattened the same way the export does it.
|
|
29
|
+
* The session-query index is opt-in on current dsh deployments, so the search
|
|
30
|
+
* route falls back to scanning this text over the log it already read.
|
|
31
|
+
*/
|
|
32
|
+
export declare function eventSearchText(event: SessionEvent): string;
|
|
33
|
+
/** Which conversation role a search hit belongs to, or null when it is not one. */
|
|
34
|
+
export declare function searchKindOf(type: string): 'user' | 'assistant' | 'tool' | null;
|
|
35
|
+
/**
|
|
36
|
+
* Excerpt centered on the match, with the window extended so the whole match
|
|
37
|
+
* fits. The centering already covers ordinary queries (the match starts 1/3 of
|
|
38
|
+
* the window in, so it fits while the query is shorter than the remaining 2/3);
|
|
39
|
+
* the extension only binds for a pasted query longer than that, which would
|
|
40
|
+
* otherwise be cut off and leave a highlighted-but-invisible result row.
|
|
41
|
+
*/
|
|
42
|
+
export declare function snippetAround(text: string, at: number, needleLength: number, max: number): string;
|
|
27
43
|
/** Extract one timeline node per direct user message from a session log. */
|
|
28
44
|
export declare function extractTurns(events: readonly SessionEvent[]): TimelineItem[];
|
|
29
45
|
/** One flattened export row. */
|
|
@@ -142,7 +142,13 @@ export declare class CustomPluginHost {
|
|
|
142
142
|
}>;
|
|
143
143
|
/** Resolve the key and its source without returning either value to the browser. */
|
|
144
144
|
private resolveApiKeyWithSource;
|
|
145
|
-
/** Search one session
|
|
145
|
+
/** Search one session and bind hits to a user-turn anchor.
|
|
146
|
+
*
|
|
147
|
+
* DSH's indexed event search is the preferred path, but its shipped web
|
|
148
|
+
* profile composes `session-query-sqlite` with `openAt: never`, so the index
|
|
149
|
+
* is absent by default and `searchEvents()` rejects. The full log is read for
|
|
150
|
+
* the anchor map anyway, so a rejected index degrades to a literal scan of
|
|
151
|
+
* that log instead of failing the whole feature. */
|
|
146
152
|
conversationSearch(sessionId: string, query: string, kinds: readonly ConversationSearchKind[]): Promise<{
|
|
147
153
|
ok: true;
|
|
148
154
|
} & ConversationSearchResult | {
|
package/lib/types/protocol.d.ts
CHANGED
|
@@ -154,6 +154,8 @@ export interface ConversationSearchItem {
|
|
|
154
154
|
export interface ConversationSearchResult {
|
|
155
155
|
items: ConversationSearchItem[];
|
|
156
156
|
hasMore: boolean;
|
|
157
|
+
/** 'index' when dsh's event index answered, 'scan' when the session log was searched directly. */
|
|
158
|
+
source: 'index' | 'scan';
|
|
157
159
|
}
|
|
158
160
|
/** Balance payload returned by the DeepSeek balance endpoint. */
|
|
159
161
|
export interface BalanceInfo {
|
package/lib/types/state.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export declare function normalizePrompt(raw: unknown): PromptItem | null;
|
|
|
22
22
|
export declare function mergeState(target: CustomPluginState, raw: unknown): void;
|
|
23
23
|
/** Load and merge the persisted document into `state`. */
|
|
24
24
|
export declare function loadStateFile(state: CustomPluginState, home?: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Temp name for an atomic replace, qualified by the writing process.
|
|
27
|
+
*
|
|
28
|
+
* The queue above is per-process, but `$DSH_HOME` is not: dsh Web and dsh
|
|
29
|
+
* Desktop both run hosts against one home (separate profiles, one `$DSH_HOME`),
|
|
30
|
+
* so a fixed temp name would let the two hosts write and rename the same file
|
|
31
|
+
* and hand each other a partially written document.
|
|
32
|
+
*/
|
|
33
|
+
export declare function tempPathFor(target: string, pid?: number): string;
|
|
25
34
|
/** Atomically persist the state document. Saves to the same path are
|
|
26
35
|
* serialized: a caller awaits its own turn's completion, a failed turn never
|
|
27
36
|
* poisons the queue behind it. */
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexpeng/dsh-custom-plugin",
|
|
3
3
|
"description": "Custom convenience suite for the dsh web GUI: appearance, timeline, folders, prompts, session export/search, Mermaid, quote reply, usage analytics, local budget, key-free backups, and a Ctrl/Cmd+K command palette; dual-face plugin mounted without dsh source changes.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"icon": "./icon.svg",
|
|
6
7
|
"main": "lib/index.js",
|
|
7
8
|
"types": "lib/types/index.d.ts",
|
|
8
9
|
"exports": {
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
"types": "./lib/types/client/index.d.ts",
|
|
15
16
|
"default": "./lib/client.js"
|
|
16
17
|
},
|
|
18
|
+
"./locale/*.json": "./locale/*.json",
|
|
17
19
|
"./package.json": "./package.json"
|
|
18
20
|
},
|
|
19
21
|
"dsh": {
|
|
@@ -21,10 +23,14 @@
|
|
|
21
23
|
"patch": "./cordis.patch.yml"
|
|
22
24
|
},
|
|
23
25
|
"client": {
|
|
26
|
+
"platform": "web",
|
|
24
27
|
"inject": [
|
|
25
|
-
"@deepseek-ai/dsh-client-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
29
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
30
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
31
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
32
|
+
"@deepseek-ai/dsh-client-ui-sidebar"
|
|
33
|
+
]
|
|
28
34
|
}
|
|
29
35
|
},
|
|
30
36
|
"publishConfig": {
|
|
@@ -38,7 +44,8 @@
|
|
|
38
44
|
"bugs": "https://github.com/AlexPeng07/dsh-custom-plugin/issues",
|
|
39
45
|
"homepage": "https://github.com/AlexPeng07/dsh-custom-plugin#readme",
|
|
40
46
|
"engines": {
|
|
41
|
-
"node": ">=22"
|
|
47
|
+
"node": ">=22",
|
|
48
|
+
"dsh": ">=0.1.7-rc.2 <0.2.0-0 || >=0.2.0-rc.2 <0.2.0-rc.3"
|
|
42
49
|
},
|
|
43
50
|
"scripts": {
|
|
44
51
|
"build": "tsc -p tsconfig.build.json && tsdown",
|
|
@@ -53,35 +60,38 @@
|
|
|
53
60
|
"prepublishOnly": "pnpm typecheck && pnpm test"
|
|
54
61
|
},
|
|
55
62
|
"peerDependencies": {
|
|
56
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
57
|
-
"@deepseek-ai/dsh-tools": "
|
|
63
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
64
|
+
"@deepseek-ai/dsh-tools": ">=0.1.7-rc.2 <0.2.0-0 || >=0.2.0-rc.2 <0.2.0-rc.3"
|
|
58
65
|
},
|
|
59
66
|
"dependencies": {
|
|
60
67
|
"mermaid": "^11.6.0"
|
|
61
68
|
},
|
|
62
69
|
"devDependencies": {
|
|
63
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
64
|
-
"@deepseek-ai/dsh-attachment": "
|
|
65
|
-
"@deepseek-ai/dsh-client-
|
|
66
|
-
"@deepseek-ai/dsh-client-ui-slots": "
|
|
67
|
-
"@deepseek-ai/dsh-client-ui-theme": "
|
|
68
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
69
|
-
"@deepseek-ai/dsh-llm": "
|
|
70
|
-
"@deepseek-ai/dsh-session": "
|
|
71
|
-
"@deepseek-ai/dsh-session-query": "
|
|
72
|
-
"@deepseek-ai/dsh-tools": "
|
|
70
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
71
|
+
"@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-client-store": "0.2.0-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-theme": "0.2.0-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
77
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-session-query": "0.2.0-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
73
80
|
"@types/node": "^22.20.0",
|
|
74
81
|
"@types/react": "~18.3.1",
|
|
75
82
|
"@types/react-dom": "^18.3.5",
|
|
76
83
|
"puppeteer-core": "^25.8.0",
|
|
77
84
|
"react": "^18.3.1",
|
|
78
85
|
"react-dom": "^18.3.1",
|
|
86
|
+
"semver": "^7.8.5",
|
|
79
87
|
"tsdown": "0.22.2",
|
|
80
88
|
"typescript": "~5.7.2",
|
|
81
89
|
"vitest": "^3.0.0"
|
|
82
90
|
},
|
|
83
91
|
"files": [
|
|
84
92
|
"lib",
|
|
93
|
+
"locale/*.json",
|
|
94
|
+
"icon.svg",
|
|
85
95
|
"cordis.patch.yml",
|
|
86
96
|
"CHANGELOG.md",
|
|
87
97
|
"README.md",
|