@alexpeng/dsh-custom-plugin 0.4.0 → 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/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
- /** Persist the state document (debounced by the loader entry). */
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.sessionQuery.readSession(sessionId)).events).slice(-400)
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.sessionQuery.readSession(sessionId);
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.sessionQuery.readSession(sessionId)]);
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.sessionQuery.readSession(record.header.id)).events, today)
1516
+ usage: aggregateDayUsage((await this.readSessionLog(record.header.id)).events, today)
1491
1517
  };
1492
1518
  } catch {
1493
1519
  return {
@@ -12,15 +12,15 @@
12
12
  */
13
13
  import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
14
14
  /**
15
- * Required services. Deliberately empty: every surface is looked up lazily
16
- * (with a graceful no-op fallback), so this plugin can never sit "pending
17
- * (waiting for services)" — a fiber that waits on a service name the client
18
- * runtime never provides would block the whole web boot behind the
19
- * "Loading plugins…" gate forever.
15
+ * Required services. Deliberately empty: the mount waits on `slots` inside
16
+ * `apply` (a child fiber) instead of declaring it here, so this entry can
17
+ * never sit "pending (waiting for services)" — a top-level fiber that waits
18
+ * on a service name the client runtime never provides would block the whole
19
+ * web boot behind the "Loading plugins…" gate forever.
20
20
  */
21
21
  export declare const inject: never[];
22
22
  /**
23
- * Mount the Custom suite.
23
+ * Mount the Custom suite once the slots service is available.
24
24
  * @param ctx - client root context.
25
25
  */
26
26
  export declare function apply(ctx: ClientContext): void;
@@ -72,8 +72,16 @@ export declare class CustomPluginHost {
72
72
  private localMermaidPath;
73
73
  private readCredential;
74
74
  constructor(options: CustomPluginHostOptions);
75
- /** Persist the state document (debounced by the loader entry). */
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.0",
4
+ "version": "0.4.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -88,8 +88,5 @@
88
88
  "README.zh.md",
89
89
  "README.i18n.yaml"
90
90
  ],
91
- "license": "Apache-2.0",
92
- "optionalDependencies": {
93
- "keytar": "7.9.0"
94
- }
91
+ "license": "Apache-2.0"
95
92
  }