@alexpeng/dsh-custom-plugin 0.4.1 → 0.4.2
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 +25 -0
- package/lib/client.js +75 -53
- package/lib/client.js.map +1 -1
- package/lib/index.js +31 -5
- package/lib/types/host-service.d.ts +9 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1015,10 +1015,36 @@ var CustomPluginHost = class {
|
|
|
1015
1015
|
this.localMermaidPath = options.localMermaidPath ?? defaultLocalMermaidPath;
|
|
1016
1016
|
this.readCredential = options.readCredential ?? readDeepSeekCredential;
|
|
1017
1017
|
}
|
|
1018
|
-
/**
|
|
1018
|
+
/** Persisted state document (debounced by the loader entry). */
|
|
1019
1019
|
async persist() {
|
|
1020
1020
|
await this.persistNow();
|
|
1021
1021
|
}
|
|
1022
|
+
/** Read one complete session log snapshot. `readSession` replay-validates
|
|
1023
|
+
* through a snapshot-mode constructor that rejects any seeded (forked or
|
|
1024
|
+
* resumed) session whose log outgrew its seed boundary — newer dsh builds
|
|
1025
|
+
* then fail every read with "seeded session constructor seed must equal its
|
|
1026
|
+
* inherited prefix". `observeSession` serves the same log through its
|
|
1027
|
+
* live/restore paths without that constructor, so fall back to it before
|
|
1028
|
+
* surfacing the error. */
|
|
1029
|
+
async readSessionLog(sessionId) {
|
|
1030
|
+
try {
|
|
1031
|
+
return await this.sessionQuery.readSession(sessionId);
|
|
1032
|
+
} catch (error) {
|
|
1033
|
+
const engine = this.sessionQuery;
|
|
1034
|
+
if (typeof engine.observeSession !== "function") throw error;
|
|
1035
|
+
const lease = await engine.observeSession(sessionId, { projectionMode: "none" });
|
|
1036
|
+
const events = [...lease.events ?? []];
|
|
1037
|
+
const disposeSymbol = Symbol.dispose;
|
|
1038
|
+
if (disposeSymbol !== void 0) {
|
|
1039
|
+
const dispose = lease[disposeSymbol];
|
|
1040
|
+
if (typeof dispose === "function") dispose.call(lease);
|
|
1041
|
+
}
|
|
1042
|
+
return {
|
|
1043
|
+
session: lease.header,
|
|
1044
|
+
events
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1022
1048
|
/** Persist after all queued state mutations have reached a stable point. */
|
|
1023
1049
|
async persistWhenIdle() {
|
|
1024
1050
|
await this.runStateOperation(() => this.persist());
|
|
@@ -1199,7 +1225,7 @@ var CustomPluginHost = class {
|
|
|
1199
1225
|
return {
|
|
1200
1226
|
ok: true,
|
|
1201
1227
|
sessionId,
|
|
1202
|
-
items: extractTurns((await this.
|
|
1228
|
+
items: extractTurns((await this.readSessionLog(sessionId)).events).slice(-400)
|
|
1203
1229
|
};
|
|
1204
1230
|
} catch (error) {
|
|
1205
1231
|
return {
|
|
@@ -1212,7 +1238,7 @@ var CustomPluginHost = class {
|
|
|
1212
1238
|
async exportRun(sessionId, format) {
|
|
1213
1239
|
let snapshot;
|
|
1214
1240
|
try {
|
|
1215
|
-
snapshot = await this.
|
|
1241
|
+
snapshot = await this.readSessionLog(sessionId);
|
|
1216
1242
|
} catch (error) {
|
|
1217
1243
|
return {
|
|
1218
1244
|
ok: false,
|
|
@@ -1363,7 +1389,7 @@ var CustomPluginHost = class {
|
|
|
1363
1389
|
kind: "type",
|
|
1364
1390
|
values: eventTypes
|
|
1365
1391
|
}] } : {}
|
|
1366
|
-
}), this.
|
|
1392
|
+
}), this.readSessionLog(sessionId)]);
|
|
1367
1393
|
const anchors = /* @__PURE__ */ new Map();
|
|
1368
1394
|
let anchor;
|
|
1369
1395
|
for (const event of snapshot.events) {
|
|
@@ -1487,7 +1513,7 @@ var CustomPluginHost = class {
|
|
|
1487
1513
|
try {
|
|
1488
1514
|
return {
|
|
1489
1515
|
readable: true,
|
|
1490
|
-
usage: aggregateDayUsage((await this.
|
|
1516
|
+
usage: aggregateDayUsage((await this.readSessionLog(record.header.id)).events, today)
|
|
1491
1517
|
};
|
|
1492
1518
|
} catch {
|
|
1493
1519
|
return {
|
|
@@ -72,8 +72,16 @@ export declare class CustomPluginHost {
|
|
|
72
72
|
private localMermaidPath;
|
|
73
73
|
private readCredential;
|
|
74
74
|
constructor(options: CustomPluginHostOptions);
|
|
75
|
-
/**
|
|
75
|
+
/** Persisted state document (debounced by the loader entry). */
|
|
76
76
|
persist(): Promise<void>;
|
|
77
|
+
/** Read one complete session log snapshot. `readSession` replay-validates
|
|
78
|
+
* through a snapshot-mode constructor that rejects any seeded (forked or
|
|
79
|
+
* resumed) session whose log outgrew its seed boundary — newer dsh builds
|
|
80
|
+
* then fail every read with "seeded session constructor seed must equal its
|
|
81
|
+
* inherited prefix". `observeSession` serves the same log through its
|
|
82
|
+
* live/restore paths without that constructor, so fall back to it before
|
|
83
|
+
* surfacing the error. */
|
|
84
|
+
private readSessionLog;
|
|
77
85
|
/** Persist after all queued state mutations have reached a stable point. */
|
|
78
86
|
persistWhenIdle(): Promise<void>;
|
|
79
87
|
private runStateOperation;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|