@linxin666/dsh-liangshen 0.3.24 → 0.4.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.
Files changed (52) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +24 -17
  3. package/README.zh.md +25 -18
  4. package/cordis.patch.yml +3 -2
  5. package/icon.svg +3 -0
  6. package/lib/client.js +381 -77
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +594 -428
  9. package/lib/types/announce.test.d.ts +10 -0
  10. package/lib/types/client/LiangShenSettingsCard.d.ts +27 -10
  11. package/lib/types/client/PluginSettingsCard.d.ts +4 -0
  12. package/lib/types/client/index.d.ts +32 -13
  13. package/lib/types/client/lever-controller.d.ts +16 -2
  14. package/lib/types/client/locales.d.ts +13 -0
  15. package/lib/types/client/main-session.d.ts +32 -0
  16. package/lib/types/client/plugin-card-seat.d.ts +23 -16
  17. package/lib/types/client/settings-form.d.ts +17 -17
  18. package/lib/types/composition.d.ts +116 -0
  19. package/lib/types/composition.test.d.ts +7 -0
  20. package/lib/types/index.d.ts +146 -31
  21. package/lib/types/index.test.d.ts +5 -0
  22. package/package.json +25 -20
  23. package/presets/liangshen/agent.cordis.yml +44 -10
  24. package/presets/liangshen/fact-ledger.mjs +141 -0
  25. package/presets/liangshen/guard.mjs +426 -0
  26. package/presets/liangshen/minimal-prompt.mjs +2 -2
  27. package/presets/liangshen/tool-catalog.mjs +24 -20
  28. package/presets/liangshen/working-context.mjs +10 -2
  29. package/src/announce.test.ts +248 -55
  30. package/src/client/LiangShenLever.module.css +2 -0
  31. package/src/client/LiangShenLever.tsx +37 -9
  32. package/src/client/LiangShenSettingsCard.tsx +96 -12
  33. package/src/client/PluginSettingsCard.tsx +7 -2
  34. package/src/client/index.ts +61 -23
  35. package/src/client/lever-controller.ts +76 -9
  36. package/src/client/locales.ts +30 -4
  37. package/src/client/main-session.ts +43 -0
  38. package/src/client/plugin-card-seat.ts +24 -17
  39. package/src/client/settings-form.ts +34 -31
  40. package/src/composition.test.ts +294 -0
  41. package/src/composition.ts +554 -0
  42. package/src/index.test.ts +68 -1
  43. package/src/index.ts +278 -107
  44. package/tools/benchmark-live-run.mjs +171 -32
  45. package/lib/types/schema.d.ts +0 -18
  46. package/lib/types/schema.test.d.ts +0 -1
  47. package/lib/types/sync.d.ts +0 -74
  48. package/lib/types/sync.test.d.ts +0 -1
  49. package/src/schema.test.ts +0 -64
  50. package/src/schema.ts +0 -110
  51. package/src/sync.test.ts +0 -303
  52. package/src/sync.ts +0 -324
package/lib/client.js CHANGED
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
7
7
  let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
9
  //#region \0dsh-css:packages/dsh-liangshen/src/client/LiangShenLever.module.css.mjs
10
- const css$1 = ".hYkIZq_lever{align-items:center;font-size:12px;line-height:1;display:inline-flex;position:relative}.hYkIZq_control{color:var(--dsw-alias-label-secondary,inherit);font:inherit;cursor:pointer;touch-action:none;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;margin:0;padding:2px 8px 2px 4px;transition:background-color .16s,color .16s;display:inline-flex}.hYkIZq_control:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#0000000f)}.hYkIZq_control:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}.hYkIZq_control:disabled{cursor:default;opacity:.55}.hYkIZq_track{background:linear-gradient(#2b2f36,#14161a);border-radius:8px;justify-content:center;align-items:flex-end;width:24px;height:28px;display:inline-flex;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px #ffffff24,inset 0 6px 10px #0000008c}.hYkIZq_track:after{content:\"\";background:#ffffff38;border-radius:2px;height:3px;position:absolute;bottom:2px;left:3px;right:3px}.hYkIZq_arm{transform-origin:50% 24px;width:16px;height:26px;margin-left:-8px;transition:transform .34s cubic-bezier(.2,1.7,.32,1);position:absolute;bottom:2px;left:50%;transform:rotate(-24deg)}.hYkIZq_lever[data-state=on] .hYkIZq_arm{transform:rotate(24deg)}.hYkIZq_rod{fill:#c9ced6;transition:fill .2s}.hYkIZq_knob{fill:#e04a33;stroke:#00000059;stroke-width:.6px;transition:fill .2s}.hYkIZq_lever[data-state=on] .hYkIZq_rod{fill:#ffd76a}.hYkIZq_lever[data-state=on] .hYkIZq_knob{fill:#f7c637}.hYkIZq_lever[data-state=on] .hYkIZq_track{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l3,#0000001f), 0 0 10px #f7c6378c}.hYkIZq_lever[data-busy=true] .hYkIZq_arm{animation:.42s ease-in-out infinite hYkIZq_lever-jitter}.hYkIZq_readout{white-space:nowrap;letter-spacing:.02em;min-width:4.4em}.hYkIZq_lever[data-state=on] .hYkIZq_readout{color:var(--dsw-alias-label-primary,inherit);font-weight:600}.hYkIZq_error{background:var(--dsw-alias-bg-layer-3,#0000000f);max-width:22ch;color:var(--dsw-alias-state-error-primary,#c0392b);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;margin-left:4px;padding:2px 6px;overflow:hidden}.hYkIZq_burst{z-index:60;pointer-events:none;place-items:center;display:grid;position:fixed;inset:0;overflow:hidden}.hYkIZq_flash{background:radial-gradient(circle at 50% 62%,#fff6c8eb,#ffd04a73 38%,#ffa00000 72%);animation:.72s ease-out both hYkIZq_burst-flash;position:absolute;inset:0}.hYkIZq_ring{border:6px solid #ffd65ad9;border-radius:50%;width:220px;height:220px;animation:1.1s cubic-bezier(.16,.9,.3,1) both hYkIZq_burst-ring;position:absolute}.hYkIZq_ring:nth-of-type(2){animation-delay:.12s}.hYkIZq_ring:nth-of-type(3){animation-delay:.24s}.hYkIZq_banner{color:#ffe9a8;text-align:center;background:linear-gradient(160deg,#181004f0,#402604eb);border-radius:22px;flex-direction:column;align-items:center;gap:6px;padding:22px 40px;animation:.6s cubic-bezier(.16,1.5,.3,1) both hYkIZq_banner-slam,.5s ease-in-out .6s 2 hYkIZq_banner-shake;display:flex;position:relative;box-shadow:0 0 0 2px #ffd65abf,0 24px 70px #00000073}.hYkIZq_bannerName{letter-spacing:.16em;background:linear-gradient(#fff6d0,#ffc93c 55%,#b8730a);color:#0000;text-shadow:0 0 24px #ffc93ca6;-webkit-background-clip:text;background-clip:text;font-size:44px;font-weight:800}.hYkIZq_line{letter-spacing:.08em;font-size:15px}.hYkIZq_code{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);letter-spacing:.06em;opacity:.82;font-size:11px;animation:.5s steps(2,end) 6 hYkIZq_code-blink}.hYkIZq_sparks{place-items:center;display:grid;position:absolute;inset:0}.hYkIZq_spark{transform-origin:50%;background:linear-gradient(#ffeca0f2,#ffaa1400);border-radius:3px;grid-area:1/1;width:3px;height:30px;animation:.95s ease-out both hYkIZq_spark-fly}@keyframes hYkIZq_lever-jitter{0%,to{transform:rotate(-22deg)}50%{transform:rotate(-8deg)}}@keyframes hYkIZq_burst-flash{0%{opacity:0;transform:scale(.6)}18%{opacity:1}to{opacity:0;transform:scale(1.5)}}@keyframes hYkIZq_burst-ring{0%{opacity:.9;transform:scale(.2)}to{opacity:0;transform:scale(3.4)}}@keyframes hYkIZq_banner-slam{0%{opacity:0;transform:scale(3.6)rotate(-9deg)}55%{opacity:1;transform:scale(.94)rotate(1.5deg)}75%{transform:scale(1.06)rotate(-1deg)}to{opacity:1;transform:scale(1)rotate(0)}}@keyframes hYkIZq_banner-shake{0%,to{transform:translate(0)}25%{transform:translate(-9px)rotate(-.6deg)}75%{transform:translate(9px)rotate(.6deg)}}@keyframes hYkIZq_spark-fly{0%{opacity:0;transform:translateY(-40px)scaleY(.3)}18%{opacity:1}to{opacity:0;transform:translateY(-300px)scaleY(1.15)}}@keyframes hYkIZq_code-blink{0%,to{opacity:.35}50%{opacity:1}}@media (prefers-reduced-motion:reduce){.hYkIZq_arm,.hYkIZq_control,.hYkIZq_rod,.hYkIZq_knob{transition:none}.hYkIZq_lever[data-busy=true] .hYkIZq_arm,.hYkIZq_flash,.hYkIZq_ring,.hYkIZq_banner,.hYkIZq_code,.hYkIZq_spark{animation:none}.hYkIZq_burst{animation:.3s ease-out both hYkIZq_burst-flash}.hYkIZq_spark{display:none}}";
10
+ const css$1 = ".hYkIZq_lever{align-items:center;font-size:12px;line-height:1;display:inline-flex;position:relative}.hYkIZq_control{color:var(--dsw-alias-label-secondary,inherit);font:inherit;cursor:pointer;touch-action:none;-webkit-user-select:none;user-select:none;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;margin:0;padding:2px 8px 2px 4px;transition:background-color .16s,color .16s;display:inline-flex}.hYkIZq_control:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#0000000f)}.hYkIZq_control:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}.hYkIZq_control:disabled{cursor:default;opacity:.55}.hYkIZq_track{background:linear-gradient(#2b2f36,#14161a);border-radius:8px;justify-content:center;align-items:flex-end;width:24px;height:28px;display:inline-flex;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px #ffffff24,inset 0 6px 10px #0000008c}.hYkIZq_track:after{content:\"\";background:#ffffff38;border-radius:2px;height:3px;position:absolute;bottom:2px;left:3px;right:3px}.hYkIZq_arm{transform-origin:50% 24px;width:16px;height:26px;margin-left:-8px;transition:transform .34s cubic-bezier(.2,1.7,.32,1);position:absolute;bottom:2px;left:50%;transform:rotate(-24deg)}.hYkIZq_lever[data-state=on] .hYkIZq_arm{transform:rotate(24deg)}.hYkIZq_rod{fill:#c9ced6;transition:fill .2s}.hYkIZq_knob{fill:#e04a33;stroke:#00000059;stroke-width:.6px;transition:fill .2s}.hYkIZq_lever[data-state=on] .hYkIZq_rod{fill:#ffd76a}.hYkIZq_lever[data-state=on] .hYkIZq_knob{fill:#f7c637}.hYkIZq_lever[data-state=on] .hYkIZq_track{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l3,#0000001f), 0 0 10px #f7c6378c}.hYkIZq_lever[data-busy=true] .hYkIZq_arm{animation:.42s ease-in-out infinite hYkIZq_lever-jitter}.hYkIZq_readout{white-space:nowrap;letter-spacing:.02em;min-width:4.4em}.hYkIZq_lever[data-state=on] .hYkIZq_readout{color:var(--dsw-alias-label-primary,inherit);font-weight:600}.hYkIZq_error{background:var(--dsw-alias-bg-layer-3,#0000000f);max-width:22ch;color:var(--dsw-alias-state-error-primary,#c0392b);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;margin-left:4px;padding:2px 6px;overflow:hidden}.hYkIZq_burst{z-index:60;pointer-events:none;place-items:center;display:grid;position:fixed;inset:0;overflow:hidden}.hYkIZq_flash{background:radial-gradient(circle at 50% 62%,#fff6c8eb,#ffd04a73 38%,#ffa00000 72%);animation:.72s ease-out both hYkIZq_burst-flash;position:absolute;inset:0}.hYkIZq_ring{border:6px solid #ffd65ad9;border-radius:50%;width:220px;height:220px;animation:1.1s cubic-bezier(.16,.9,.3,1) both hYkIZq_burst-ring;position:absolute}.hYkIZq_ring:nth-of-type(2){animation-delay:.12s}.hYkIZq_ring:nth-of-type(3){animation-delay:.24s}.hYkIZq_banner{color:#ffe9a8;text-align:center;background:linear-gradient(160deg,#181004f0,#402604eb);border-radius:22px;flex-direction:column;align-items:center;gap:6px;padding:22px 40px;animation:.6s cubic-bezier(.16,1.5,.3,1) both hYkIZq_banner-slam,.5s ease-in-out .6s 2 hYkIZq_banner-shake;display:flex;position:relative;box-shadow:0 0 0 2px #ffd65abf,0 24px 70px #00000073}.hYkIZq_bannerName{letter-spacing:.16em;background:linear-gradient(#fff6d0,#ffc93c 55%,#b8730a);color:#0000;text-shadow:0 0 24px #ffc93ca6;-webkit-background-clip:text;background-clip:text;font-size:44px;font-weight:800}.hYkIZq_line{letter-spacing:.08em;font-size:15px}.hYkIZq_code{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);letter-spacing:.06em;opacity:.82;font-size:11px;animation:.5s steps(2,end) 6 hYkIZq_code-blink}.hYkIZq_sparks{place-items:center;display:grid;position:absolute;inset:0}.hYkIZq_spark{transform-origin:50%;background:linear-gradient(#ffeca0f2,#ffaa1400);border-radius:3px;grid-area:1/1;width:3px;height:30px;animation:.95s ease-out both hYkIZq_spark-fly}@keyframes hYkIZq_lever-jitter{0%,to{transform:rotate(-22deg)}50%{transform:rotate(-8deg)}}@keyframes hYkIZq_burst-flash{0%{opacity:0;transform:scale(.6)}18%{opacity:1}to{opacity:0;transform:scale(1.5)}}@keyframes hYkIZq_burst-ring{0%{opacity:.9;transform:scale(.2)}to{opacity:0;transform:scale(3.4)}}@keyframes hYkIZq_banner-slam{0%{opacity:0;transform:scale(3.6)rotate(-9deg)}55%{opacity:1;transform:scale(.94)rotate(1.5deg)}75%{transform:scale(1.06)rotate(-1deg)}to{opacity:1;transform:scale(1)rotate(0)}}@keyframes hYkIZq_banner-shake{0%,to{transform:translate(0)}25%{transform:translate(-9px)rotate(-.6deg)}75%{transform:translate(9px)rotate(.6deg)}}@keyframes hYkIZq_spark-fly{0%{opacity:0;transform:translateY(-40px)scaleY(.3)}18%{opacity:1}to{opacity:0;transform:translateY(-300px)scaleY(1.15)}}@keyframes hYkIZq_code-blink{0%,to{opacity:.35}50%{opacity:1}}@media (prefers-reduced-motion:reduce){.hYkIZq_arm,.hYkIZq_control,.hYkIZq_rod,.hYkIZq_knob{transition:none}.hYkIZq_lever[data-busy=true] .hYkIZq_arm,.hYkIZq_flash,.hYkIZq_ring,.hYkIZq_banner,.hYkIZq_code,.hYkIZq_spark{animation:none}.hYkIZq_burst{animation:.3s ease-out both hYkIZq_burst-flash}.hYkIZq_spark{display:none}}";
11
11
  const tagId$1 = "@linxin666/dsh-liangshen/packages/dsh-liangshen/src/client/LiangShenLever.module.css";
12
12
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
13
13
  const tag = document.createElement("style");
@@ -66,6 +66,14 @@ window.__ModuleLoader__.load({
66
66
  const MORSE = "-.. . . .--. ... . . -.- / .... .- .-. -. . ... ...";
67
67
  /** One spark per spoke of the burst. */
68
68
  const SPARKS = Array.from({ length: 14 }, (_, index) => index);
69
+ /** Sync the hero preset chip above the composer so both controls always agree. */
70
+ function syncHeroChip(label) {
71
+ try {
72
+ if (typeof document === "undefined") return;
73
+ const chip = document.querySelector("button[aria-haspopup=\"menu\"] span[class*=\"seatLabel\"]") ?? Array.from(document.querySelectorAll("button[aria-haspopup=\"menu\"] span")).find((s) => s.className.includes("seatLabel"));
74
+ if (chip && chip.textContent !== label) chip.textContent = label;
75
+ } catch {}
76
+ }
69
77
  /** Slot entry for `conversation.input.right` (left of the model selector). */
70
78
  function LiangShenLever(face) {
71
79
  const { state, restoreLabel, busy, error, burst } = (0, react.useSyncExternalStore)(face.store.subscribe, face.store.getSnapshot);
@@ -88,6 +96,16 @@ window.__ModuleLoader__.load({
88
96
  clearTimeout(timer);
89
97
  };
90
98
  }, [burstKey]);
99
+ const prevState = (0, react.useRef)(state);
100
+ (0, react.useEffect)(() => {
101
+ if (state === "on") syncHeroChip(face.t("lever.name"));
102
+ else if (prevState.current === "on" && state === "off" && restoreLabel !== "") syncHeroChip(restoreLabel);
103
+ prevState.current = state;
104
+ }, [
105
+ state,
106
+ restoreLabel,
107
+ face
108
+ ]);
91
109
  if (state === "locked" || state === "missing" || state === "on" && restoreLabel === "") return null;
92
110
  const toggle = () => {
93
111
  if (!actionable) return;
@@ -97,21 +115,23 @@ window.__ModuleLoader__.load({
97
115
  const onPointerDown = (event) => {
98
116
  if (!actionable) return;
99
117
  drag.current = {
118
+ x: event.clientX,
100
119
  y: event.clientY,
101
120
  fired: false
102
121
  };
103
- event.currentTarget.setPointerCapture?.(event.pointerId);
122
+ try {
123
+ event.currentTarget.setPointerCapture?.(event.pointerId);
124
+ } catch {}
104
125
  };
105
126
  const onPointerMove = (event) => {
106
127
  const pending = drag.current;
107
128
  if (pending === void 0 || pending.fired) return;
108
- const travel = event.clientY - pending.y;
109
- if (travel >= DRAG_THRESHOLD_PX) {
110
- pending.fired = true;
111
- face.pull();
112
- } else if (travel <= -14) {
129
+ const travelY = event.clientY - pending.y;
130
+ const travelX = event.clientX - pending.x;
131
+ if (Math.hypot(travelX, travelY) >= DRAG_THRESHOLD_PX) {
113
132
  pending.fired = true;
114
- face.push();
133
+ if (on) face.push();
134
+ else face.pull();
115
135
  }
116
136
  };
117
137
  const onPointerUp = () => {
@@ -236,6 +256,21 @@ window.__ModuleLoader__.load({
236
256
  });
237
257
  }
238
258
  //#endregion
259
+ //#region src/client/main-session.ts
260
+ /**
261
+ * Resolve the Session the main view currently shows.
262
+ *
263
+ * Reads the catalog's rows rather than a per-id retain-info source: ownership
264
+ * counts ride the list snapshot, so this neither allocates observers nor opens
265
+ * history, and a subscription to the list still fires when the selection moves.
266
+ * @param byId - the session catalog's rows (`SessionListState.byId`), when available.
267
+ * @returns the main-view session id, or undefined when the main view shows none.
268
+ */
269
+ function mainViewSessionId(byId) {
270
+ if (byId === void 0 || byId === null) return void 0;
271
+ for (const row of Object.values(byId)) if (row !== void 0 && (row.retainedBy?.mainView ?? 0) > 0) return row.id;
272
+ }
273
+ //#endregion
239
274
  //#region \0dsh-store-engine
240
275
  const platform = ["@deepseek-ai/dsh-client", "-store"].join("");
241
276
  const legacy = ["@deepseek-ai/dsh-client-runtime", "/client"].join("");
@@ -292,6 +327,18 @@ window.__ModuleLoader__.load({
292
327
  function isActionable(state) {
293
328
  return state === "on" || state === "off";
294
329
  }
330
+ /**
331
+ * Settings entry ids whose writes can move the roster this lever reads: the
332
+ * agent-preset registry's own entry (its default and selection policy) and this
333
+ * plugin's row under either install shape — the aggregate's generated row id
334
+ * and the standalone row id — because disabling the plugin unregisters the
335
+ * preset it declares.
336
+ */
337
+ const ROSTER_SETTINGS_ENTRY_IDS = [
338
+ "agent-preset-registry",
339
+ "web-ui-liangshen",
340
+ "liangshen"
341
+ ];
295
342
  /** Read the preset a session summary reports, when it reports one. */
296
343
  function presetOf(session) {
297
344
  const value = session?.projectionValues?.["agentPreset"];
@@ -341,7 +388,7 @@ window.__ModuleLoader__.load({
341
388
  }));
342
389
  const remote = readService(() => this.ctx.remote);
343
390
  if (typeof remote?.$on === "function") this.disposers.push(remote.$on("settings/document-updated", (ns) => {
344
- if (ns === "agent-presets") this.load();
391
+ if (ROSTER_SETTINGS_ENTRY_IDS.includes(ns)) this.load();
345
392
  }));
346
393
  this.refresh();
347
394
  if (this.remote !== void 0) this.load();
@@ -443,7 +490,10 @@ window.__ModuleLoader__.load({
443
490
  this.refresh();
444
491
  return;
445
492
  }
446
- this.previous = direction === "down" ? facts.agentPreset : void 0;
493
+ if (direction === "down") {
494
+ const prev = facts.agentPreset ?? this.detectPreset();
495
+ if (prev !== void 0 && prev !== "liangshen") this.rememberPrevious(prev);
496
+ }
447
497
  const next = this.store.getSnapshot();
448
498
  this.store.set({
449
499
  ...next,
@@ -453,26 +503,56 @@ window.__ModuleLoader__.load({
453
503
  });
454
504
  this.refresh();
455
505
  }
506
+ /**
507
+ * Try to detect the active preset from the DOM hero chip or storage
508
+ * when session.projectionValues.agentPreset is absent.
509
+ */
510
+ detectPreset() {
511
+ try {
512
+ if (typeof document !== "undefined") {
513
+ const text = (document.querySelector("button[aria-haspopup=\"menu\"] span[class*=\"seatLabel\"]") ?? Array.from(document.querySelectorAll("button[aria-haspopup=\"menu\"] span")).find((s) => s.className.includes("seatLabel")))?.textContent?.trim();
514
+ if (text) {
515
+ const matched = this.rows.find((row) => (row.name === text || row.id === text) && row.id !== "liangshen");
516
+ if (matched) return matched.id;
517
+ }
518
+ }
519
+ } catch {}
520
+ try {
521
+ if (typeof sessionStorage !== "undefined") {
522
+ const stored = sessionStorage.getItem("dsh-liangshen:previous-preset");
523
+ if (stored && stored !== "liangshen" && this.rows.some((r) => r.id === stored)) return stored;
524
+ }
525
+ } catch {}
526
+ }
527
+ rememberPrevious(presetId) {
528
+ if (presetId === void 0 || presetId === "liangshen") return;
529
+ this.previous = presetId;
530
+ try {
531
+ if (typeof sessionStorage !== "undefined") sessionStorage.setItem("dsh-liangshen:previous-preset", presetId);
532
+ } catch {}
533
+ }
456
534
  /** The facts one decision reads, from the live session and the roster. */
457
535
  facts() {
458
536
  const summary = this.currentSession();
459
537
  const available = this.rows.filter((row) => row.broken === void 0).map((row) => row.id);
460
538
  const fallback = this.rows.find((row) => row.isDefault)?.id;
539
+ const currentPreset = presetOf(summary);
540
+ if (currentPreset !== void 0 && currentPreset !== "liangshen") this.rememberPrevious(currentPreset);
541
+ const previous = this.previous ?? this.detectPreset();
461
542
  return {
462
543
  blank: summary?.blank === true,
463
- agentPreset: presetOf(summary),
544
+ agentPreset: currentPreset,
464
545
  available,
465
546
  fallback,
466
- previous: this.previous
547
+ previous
467
548
  };
468
549
  }
469
550
  currentSessionId() {
470
- const current = this.sessions?.list.getSnapshot().current;
471
- return current === void 0 ? void 0 : String(current);
551
+ return mainViewSessionId(this.sessions?.list.getSnapshot().byId);
472
552
  }
473
553
  currentSession() {
474
554
  const state = this.sessions?.list.getSnapshot();
475
- const current = state?.current;
555
+ const current = mainViewSessionId(state?.byId);
476
556
  if (state === void 0 || current === void 0) return void 0;
477
557
  return state.byId[current];
478
558
  }
@@ -665,17 +745,20 @@ window.__ModuleLoader__.load({
665
745
  })
666
746
  ]
667
747
  });
668
- if (!state.exposed) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
669
- className: cardClass,
670
- children: [header, expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
671
- className: settings_card_module_css_default.body,
672
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
673
- className: settings_card_module_css_default.notExposed,
674
- role: "status",
675
- children: props.t("settings.notExposed")
676
- })
677
- }) : null]
678
- });
748
+ if (!state.exposed && props.renderChildrenWhenNotExposed !== true) {
749
+ const showNotice = props.hideNotExposedNotice !== true;
750
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
751
+ className: cardClass,
752
+ children: [header, expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
753
+ className: settings_card_module_css_default.body,
754
+ children: showNotice ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
755
+ className: settings_card_module_css_default.notExposed,
756
+ role: "status",
757
+ children: props.t("settings.notExposed")
758
+ }) : null
759
+ }) : null]
760
+ });
761
+ }
679
762
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
680
763
  className: cardClass,
681
764
  children: [header, expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -715,6 +798,51 @@ window.__ModuleLoader__.load({
715
798
  }) : null]
716
799
  });
717
800
  }
801
+ /** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */
802
+ function ValueField(props) {
803
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
804
+ className: settings_card_module_css_default.field,
805
+ children: [
806
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
807
+ className: settings_card_module_css_default.head,
808
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
809
+ className: settings_card_module_css_default.label,
810
+ htmlFor: props.id,
811
+ children: props.label
812
+ }), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
813
+ className: settings_card_module_css_default.badges,
814
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
815
+ className: settings_card_module_css_default.badge,
816
+ children: props.overriddenLabel
817
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
818
+ type: "button",
819
+ className: settings_card_module_css_default.reset,
820
+ disabled: props.disabled,
821
+ onClick: props.onReset,
822
+ children: props.resetLabel
823
+ })]
824
+ }) : null]
825
+ }),
826
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
827
+ id: props.id,
828
+ className: props.invalid ? settings_card_module_css_default.inputInvalid : settings_card_module_css_default.input,
829
+ type: "text",
830
+ ...props.numeric === true ? { inputMode: "numeric" } : {},
831
+ ...props.invalid ? { "aria-invalid": true } : {},
832
+ value: props.text,
833
+ placeholder: props.placeholder ?? "",
834
+ disabled: props.disabled,
835
+ onChange: (event) => {
836
+ props.onEdit(event.target.value);
837
+ }
838
+ }),
839
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
840
+ className: props.invalid ? settings_card_module_css_default.invalid : settings_card_module_css_default.hint,
841
+ children: props.invalid ? props.invalidLabel : props.hint
842
+ })
843
+ ]
844
+ });
845
+ }
718
846
  const NON_SKIN_BODY_MARKERS = /* @__PURE__ */ new Set(["dshSkinCenter", "dshSidebarCollapsed"]);
719
847
  function isSkinActive() {
720
848
  return Object.keys(document.body.dataset).some((key) => key.startsWith("dsh") && !NON_SKIN_BODY_MARKERS.has(key));
@@ -982,6 +1110,26 @@ window.__ModuleLoader__.load({
982
1110
  }
983
1111
  //#endregion
984
1112
  //#region src/client/settings-form.ts
1113
+ /** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */
1114
+ function numberField(field, constraints = {}) {
1115
+ const { integer = false, min } = constraints;
1116
+ return {
1117
+ field,
1118
+ format: (value) => typeof value === "number" ? String(value) : "",
1119
+ parse: (text) => {
1120
+ const trimmed = text.trim();
1121
+ if (trimmed === "") return { kind: "clear" };
1122
+ const parsed = Number(trimmed);
1123
+ if (!Number.isFinite(parsed)) return void 0;
1124
+ if (integer && !Number.isInteger(parsed)) return void 0;
1125
+ if (min !== void 0 && parsed < min) return void 0;
1126
+ return {
1127
+ kind: "set",
1128
+ value: parsed
1129
+ };
1130
+ }
1131
+ };
1132
+ }
985
1133
  /** A boolean field, edited through true/false draft text. */
986
1134
  function booleanField(field) {
987
1135
  return {
@@ -1028,31 +1176,31 @@ window.__ModuleLoader__.load({
1028
1176
  specs;
1029
1177
  staged = /* @__PURE__ */ new Map();
1030
1178
  listeners = /* @__PURE__ */ new Set();
1031
- /** The scope subscription installed in the constructor; released by dispose(). */
1032
- disposeScope;
1179
+ /** The form subscription installed in the constructor; released by dispose(). */
1180
+ disposeForm;
1033
1181
  disposed = false;
1034
1182
  saving = false;
1035
1183
  failed = false;
1036
1184
  failedReason;
1037
- /** @param scope - the bound settings scope for this card's namespace. */
1185
+ /** @param scope - the bound configuration form for this card's namespace. */
1038
1186
  constructor(scope, specs) {
1039
1187
  this.scope = scope;
1040
1188
  this.specs = new Map(specs.map((spec) => [spec.field, spec]));
1041
- this.disposeScope = scope.subscribe(() => {
1189
+ this.disposeForm = scope.subscribe(() => {
1042
1190
  this.publish();
1043
1191
  });
1044
1192
  }
1045
1193
  /**
1046
- * Release the scope subscription and every bound store listener. The card
1194
+ * Release the form subscription and every bound store listener. The card
1047
1195
  * must call this on teardown; later calls are no-ops.
1048
1196
  */
1049
1197
  dispose() {
1050
1198
  if (this.disposed) return;
1051
1199
  this.disposed = true;
1052
- this.disposeScope();
1200
+ this.disposeForm();
1053
1201
  this.listeners.clear();
1054
1202
  }
1055
- /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */
1203
+ /** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
1056
1204
  bind(project) {
1057
1205
  const store = createSnapshotStore(project());
1058
1206
  this.listeners.add(() => {
@@ -1119,19 +1267,19 @@ window.__ModuleLoader__.load({
1119
1267
  };
1120
1268
  }
1121
1269
  /**
1122
- * Write every staged edit in one atomic scope mutation, then re-seed from
1270
+ * Write every staged edit in one atomic form mutation, then re-seed from
1123
1271
  * what the Host accepted.
1124
1272
  *
1125
1273
  * The whole batch rides one mutate, so cross-field validate hooks
1126
1274
  * (baseURL+model) judge it as a unit: the Host either applies every write
1127
- * or refuses the batch. The 0.1.2 scope contract never rejects a refused
1128
- * mutation — the scope recovers with a fresh Host view and resolves — so
1129
- * resolution alone proves nothing: the outcome is judged by reading the
1130
- * settled snapshot back, one planned write at a time, and one missed write
1131
- * fails the whole save. A scope that still rejects on refusal (the dsh-web
1132
- * bridge scope) reports through the same failure path with its rejection
1133
- * message. A save that did not land keeps its drafts, so the user can
1134
- * correct them instead of retyping.
1275
+ * or refuses the batch. The form contract answers a refusal or a skipped
1276
+ * write with `false` (it recovers with a fresh Host view instead of
1277
+ * throwing), so the outcome is judged twice: the answer itself, and then the
1278
+ * settled snapshot read back one planned write at a time. One missed write
1279
+ * fails the whole save. A transport that rejects instead (the dsh-web bridge
1280
+ * controller on a dead connection) reports through the same failure path
1281
+ * with its rejection message. A save that did not land keeps its drafts, so
1282
+ * the user can correct them instead of retyping.
1135
1283
  * @returns settlement after the mutation and the read-back.
1136
1284
  */
1137
1285
  async save() {
@@ -1153,12 +1301,13 @@ window.__ModuleLoader__.load({
1153
1301
  path: [item.field]
1154
1302
  });
1155
1303
  let failedReason;
1304
+ let accepted = false;
1156
1305
  try {
1157
- await this.scope.mutate(ops);
1306
+ accepted = await this.scope.mutate(ops);
1158
1307
  } catch (error) {
1159
1308
  failedReason = error instanceof Error ? error.message : String(error);
1160
1309
  }
1161
- const landed = failedReason === void 0 && valid.every((item) => item.judge());
1310
+ const landed = accepted && failedReason === void 0 && valid.every((item) => item.judge());
1162
1311
  for (const [field, before] of pending) if (landed && this.staged.get(field) === before) this.staged.delete(field);
1163
1312
  this.saving = false;
1164
1313
  this.failed = !landed;
@@ -1271,16 +1420,36 @@ window.__ModuleLoader__.load({
1271
1420
  "native",
1272
1421
  "both"
1273
1422
  ];
1274
- /** Bridges the `dsh-liangshen` scope onto the card's staged form. */
1423
+ /** Sensitivity presets for the circuit breaker (mirrors the Host schema). */
1424
+ const SENSITIVITY_CHOICES = [
1425
+ "conservative",
1426
+ "balanced",
1427
+ "aggressive"
1428
+ ];
1429
+ /** Bridges the `liangshen` settings form onto the card's staged form. */
1275
1430
  var LiangShenSettingsCardController = class {
1276
1431
  form;
1277
1432
  store;
1278
- /** @param scope - the bound settings scope for the `dsh-liangshen` namespace. */
1433
+ /** @param scope - the bound configuration form of the entry that owns this namespace. */
1279
1434
  constructor(scope) {
1280
1435
  this.form = new CardForm(scope, [
1281
1436
  booleanField("enabled"),
1282
1437
  booleanField("announceToAgent"),
1283
- choiceField("presentation", PRESENTATION_CHOICES)
1438
+ choiceField("presentation", PRESENTATION_CHOICES),
1439
+ booleanField("guardEnabled"),
1440
+ choiceField("guardSensitivity", SENSITIVITY_CHOICES),
1441
+ numberField("guardStallReasoningChars", {
1442
+ integer: true,
1443
+ min: 200
1444
+ }),
1445
+ numberField("guardGlobalStallCap", {
1446
+ integer: true,
1447
+ min: 2
1448
+ }),
1449
+ numberField("guardEchoFailures", {
1450
+ integer: true,
1451
+ min: 2
1452
+ })
1284
1453
  ]);
1285
1454
  this.store = this.form.bind(() => this.projection());
1286
1455
  }
@@ -1289,7 +1458,12 @@ window.__ModuleLoader__.load({
1289
1458
  ...this.form.shell(),
1290
1459
  enabled: this.form.field("enabled"),
1291
1460
  announceToAgent: this.form.field("announceToAgent"),
1292
- presentation: this.form.field("presentation")
1461
+ presentation: this.form.field("presentation"),
1462
+ guardEnabled: this.form.field("guardEnabled"),
1463
+ guardSensitivity: this.form.field("guardSensitivity"),
1464
+ guardStallReasoningChars: this.form.field("guardStallReasoningChars"),
1465
+ guardGlobalStallCap: this.form.field("guardGlobalStallCap"),
1466
+ guardEchoFailures: this.form.field("guardEchoFailures")
1293
1467
  };
1294
1468
  }
1295
1469
  /**
@@ -1328,6 +1502,8 @@ window.__ModuleLoader__.load({
1328
1502
  descriptionKey: "settings.description",
1329
1503
  defaultOpen: false,
1330
1504
  state,
1505
+ renderChildrenWhenNotExposed: true,
1506
+ hideNotExposedNotice: true,
1331
1507
  onSave: props.save,
1332
1508
  onDiscard: props.discard,
1333
1509
  children: [
@@ -1377,6 +1553,83 @@ window.__ModuleLoader__.load({
1377
1553
  onReset: () => {
1378
1554
  props.resetField("presentation");
1379
1555
  }
1556
+ }),
1557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BooleanField, {
1558
+ id: "settings-liangshen-guard-enabled",
1559
+ label: t("settings.guardEnabled"),
1560
+ hint: t("settings.guardEnabledHint"),
1561
+ onLabel: t("settings.on"),
1562
+ offLabel: t("settings.off"),
1563
+ ...fieldProps,
1564
+ ...state.guardEnabled,
1565
+ onEdit: (text) => {
1566
+ props.edit("guardEnabled", text);
1567
+ },
1568
+ onReset: () => {
1569
+ props.resetField("guardEnabled");
1570
+ }
1571
+ }),
1572
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
1573
+ id: "settings-liangshen-guard-sensitivity",
1574
+ label: t("settings.guardSensitivity"),
1575
+ hint: t("settings.guardSensitivityHint"),
1576
+ choices: SENSITIVITY_CHOICES.map((choice) => ({
1577
+ value: choice,
1578
+ label: t(`sensitivity.${choice}`)
1579
+ })),
1580
+ ...fieldProps,
1581
+ ...state.guardSensitivity,
1582
+ onEdit: (text) => {
1583
+ props.edit("guardSensitivity", text);
1584
+ },
1585
+ onReset: () => {
1586
+ props.resetField("guardSensitivity");
1587
+ }
1588
+ }),
1589
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
1590
+ id: "settings-liangshen-guard-stall-chars",
1591
+ numeric: true,
1592
+ label: t("settings.guardStallChars"),
1593
+ hint: t("settings.guardStallCharsHint"),
1594
+ placeholder: "8000",
1595
+ ...fieldProps,
1596
+ ...state.guardStallReasoningChars,
1597
+ onEdit: (text) => {
1598
+ props.edit("guardStallReasoningChars", text);
1599
+ },
1600
+ onReset: () => {
1601
+ props.resetField("guardStallReasoningChars");
1602
+ }
1603
+ }),
1604
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
1605
+ id: "settings-liangshen-guard-global-cap",
1606
+ numeric: true,
1607
+ label: t("settings.guardGlobalCap"),
1608
+ hint: t("settings.guardGlobalCapHint"),
1609
+ placeholder: "4",
1610
+ ...fieldProps,
1611
+ ...state.guardGlobalStallCap,
1612
+ onEdit: (text) => {
1613
+ props.edit("guardGlobalStallCap", text);
1614
+ },
1615
+ onReset: () => {
1616
+ props.resetField("guardGlobalStallCap");
1617
+ }
1618
+ }),
1619
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
1620
+ id: "settings-liangshen-guard-echo",
1621
+ numeric: true,
1622
+ label: t("settings.guardEchoFailures"),
1623
+ hint: t("settings.guardEchoFailuresHint"),
1624
+ placeholder: "3",
1625
+ ...fieldProps,
1626
+ ...state.guardEchoFailures,
1627
+ onEdit: (text) => {
1628
+ props.edit("guardEchoFailures", text);
1629
+ },
1630
+ onReset: () => {
1631
+ props.resetField("guardEchoFailures");
1632
+ }
1380
1633
  })
1381
1634
  ]
1382
1635
  });
@@ -1408,11 +1661,11 @@ window.__ModuleLoader__.load({
1408
1661
  "settings.title": "梁神模式",
1409
1662
  "settings.description": "控制本插件与工具面呈现方式。",
1410
1663
  "settings.enabled": "启用梁神模式",
1411
- "settings.enabledHint": "关闭后预设同步与 agent 公告都不执行。",
1664
+ "settings.enabledHint": "关闭后不声明预设、也不发 agent 公告。",
1412
1665
  "settings.announceToAgent": "向 agent 公告本插件",
1413
1666
  "settings.announceToAgentHint": "开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。",
1414
1667
  "settings.presentation": "工具面呈现方式",
1415
- "settings.presentationHint": "写入同步后的预设:ptc 把 wire 收拢为 run_code;native 保持原生工具清单;both 让两者同驻。改动需重启 DSH 生效。",
1668
+ "settings.presentationHint": "写入本插件声明的预设的 tool-catalog 行:both(出厂默认)让原生清单与 run_code 同驻(原生直调优先);native 保持原生工具清单;ptc 把 wire 收拢为 run_code。改动立即生效,但已开始的会话保持其已声明的组合。",
1416
1669
  "settings.on": "开",
1417
1670
  "settings.off": "关",
1418
1671
  "settings.inherit": "继承(跟随部署默认)",
@@ -1430,7 +1683,20 @@ window.__ModuleLoader__.load({
1430
1683
  "settings.invalidValue": "该取值不被接受",
1431
1684
  "presentation.ptc": "ptc(仅 run_code)",
1432
1685
  "presentation.native": "native(原生工具清单)",
1433
- "presentation.both": "both(两者同驻)"
1686
+ "presentation.both": "both(两者同驻)",
1687
+ "settings.guardEnabled": "启用退化熔断器",
1688
+ "settings.guardEnabledHint": "运行时检测思考退化(连续零产出长思考 / 同参重复失败),触发时注入熔断提示并临时下调推理档位。关闭后不干预任何请求。",
1689
+ "settings.guardStallChars": "单步暴走字符阈值",
1690
+ "settings.guardStallCharsHint": "单条推理达到该字符数且零产出即触发熔断(按 V4.1 官方 384K 最大输出校准;默认 8000,约 2-4K 思考 token)。",
1691
+ "settings.guardGlobalCap": "慢烧连续步数",
1692
+ "settings.guardGlobalCapHint": "连续多少步有真实推理但零产出触发慢烧熔断(默认 4;步数越小越敏感,真实长调查建议调大)。",
1693
+ "settings.guardSensitivity": "熔断灵敏度",
1694
+ "settings.guardSensitivityHint": "整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5)。阈值随推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符。",
1695
+ "sensitivity.conservative": "保守(少打断)",
1696
+ "sensitivity.balanced": "均衡(默认)",
1697
+ "sensitivity.aggressive": "激进(早触发)",
1698
+ "settings.guardEchoFailures": "同参连续失败次数",
1699
+ "settings.guardEchoFailuresHint": "同一工具以相同参数连续失败多少次触发空转熔断(默认 3)。"
1434
1700
  };
1435
1701
  /** English counterpart; the key set mirrors {@link zh} exactly. */
1436
1702
  const en = {
@@ -1452,11 +1718,11 @@ window.__ModuleLoader__.load({
1452
1718
  "settings.title": "LiangShen mode",
1453
1719
  "settings.description": "Controls this plugin and the wire presentation.",
1454
1720
  "settings.enabled": "Enable LiangShen mode",
1455
- "settings.enabledHint": "When off, neither preset sync nor the agent announcement runs.",
1721
+ "settings.enabledHint": "When off, the preset is not declared and the agent announcement does not run.",
1456
1722
  "settings.announceToAgent": "Announce this plugin to agents",
1457
1723
  "settings.announceToAgentHint": "Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.",
1458
1724
  "settings.presentation": "Wire presentation",
1459
- "settings.presentationHint": "Written into the synced preset: ptc collapses the wire to run_code; native keeps the native roster; both keeps them co-resident. Restart DSH for a change to take effect.",
1725
+ "settings.presentationHint": "Written into the tool-catalog row of the preset this plugin declares: both (the shipped default) keeps the roster and run_code co-resident (direct native calls first); native keeps the native roster; ptc collapses the wire to run_code. A change re-declares the preset immediately; sessions that already started keep the composition they declared.",
1460
1726
  "settings.on": "On",
1461
1727
  "settings.off": "Off",
1462
1728
  "settings.inherit": "Inherit (deployment default)",
@@ -1474,7 +1740,20 @@ window.__ModuleLoader__.load({
1474
1740
  "settings.invalidValue": "The value is not accepted",
1475
1741
  "presentation.ptc": "ptc (run_code only)",
1476
1742
  "presentation.native": "native (native tool roster)",
1477
- "presentation.both": "both (both co-resident)"
1743
+ "presentation.both": "both (both co-resident)",
1744
+ "settings.guardEnabled": "Degeneration circuit breaker",
1745
+ "settings.guardEnabledHint": "Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures), injecting a breaker message and stepping the reasoning effort down when it fires. Disabled means requests are never touched.",
1746
+ "settings.guardStallChars": "Runaway reasoning character floor",
1747
+ "settings.guardStallCharsHint": "One reasoning block reaching this many characters with no output fires the breaker (calibrated against V4.1's official 384K max output; default 8000, roughly 2-4K thinking tokens).",
1748
+ "settings.guardGlobalCap": "Slow-burn step count",
1749
+ "settings.guardGlobalCapHint": "Consecutive output-free steps of real reasoning that fire the slow-burn ladder (default 4; lower is more sensitive — raise it for genuinely long investigations).",
1750
+ "settings.guardSensitivity": "Breaker sensitivity",
1751
+ "settings.guardSensitivityHint": "Scales every breaker threshold: conservative (fewer interruptions, x1.5), balanced (the calibrated defaults), aggressive (fires earlier, x0.5). Thresholds adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low.",
1752
+ "sensitivity.conservative": "Conservative (fewer interruptions)",
1753
+ "sensitivity.balanced": "Balanced (default)",
1754
+ "sensitivity.aggressive": "Aggressive (fires earlier)",
1755
+ "settings.guardEchoFailures": "Identical-argument failures",
1756
+ "settings.guardEchoFailuresHint": "Identical-argument failures of the same tool in a row that fire the echo ladder (default 3)."
1478
1757
  };
1479
1758
  //#endregion
1480
1759
  //#region src/client/plugin-card-seat.ts
@@ -1486,22 +1765,24 @@ window.__ModuleLoader__.load({
1486
1765
  *
1487
1766
  * - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
1488
1767
  * group section (this family's own first-level "Web UI plugins" section);
1489
- * - `settings.plugin.item` — the official keyed seat of the harness's
1490
- * `ui-settings-plugins` tab, keyed by the settings namespace the card edits.
1768
+ * - `plugins.bundle.config` — the official keyed seat of the harness's plugin
1769
+ * manager page, keyed by the bundle's package name and rendered on that
1770
+ * bundle's page. alpha.2 removed the `settings.plugin.item` keyed seat of the
1771
+ * `ui-settings-plugins` tab that this helper used before, so a card keyed by
1772
+ * its settings namespace has no seat to land in any more.
1491
1773
  *
1492
- * SEAT SELECTION IS NOT A DECLARATION PROBE. The official `ui-settings-plugins`
1493
- * row belongs to the harness bundle and its `configurable` tab always declares
1494
- * `settings.plugin.item` before any external plugin's `apply()` runs, so
1495
- * "is the official seat declared?" answers yes even in the deployment whose
1496
- * whole point is the family group. Choosing on that probe sends every family
1497
- * card to the official Plugins tab and leaves the group's own section
1498
- * permanently empty — the family of reports where the section renders its
1499
- * heading and zero cards.
1774
+ * SEAT SELECTION IS NOT A DECLARATION PROBE. The official plugin surface
1775
+ * belongs to the harness bundle and declares its seats before any external
1776
+ * plugin's `apply()` runs, so "is the official seat declared?" answers yes even
1777
+ * in the deployment whose whole point is the family group. Choosing on that
1778
+ * probe sends every family card to the official page and leaves the group's own
1779
+ * section permanently empty — the family of reports where the section renders
1780
+ * its heading and zero cards.
1500
1781
  *
1501
1782
  * The signal that actually distinguishes the two deployments is whether
1502
1783
  * dsh-web-settings is loaded: it is the package that owns the group section and
1503
1784
  * it publishes the `webUiSettings` service during `apply()`, which every
1504
- * family plugin already reads for its settings scope. Group loaded -> the family
1785
+ * family plugin already reads for its settings form. Group loaded -> the family
1505
1786
  * seat; group absent -> the official seat.
1506
1787
  *
1507
1788
  * The decision is re-evaluated on every `slots/changed` because the group may
@@ -1517,8 +1798,8 @@ window.__ModuleLoader__.load({
1517
1798
  */
1518
1799
  /** The family list seat key. */
1519
1800
  const FAMILY_PLUGIN_CARD_SEAT = "web-ui.plugin.item";
1520
- /** The official keyed plugin-card seat key. */
1521
- const OFFICIAL_PLUGIN_CARD_SEAT = "settings.plugin.item";
1801
+ /** The official keyed plugin-card seat key (the alpha.2 bundle-configuration seat). */
1802
+ const OFFICIAL_PLUGIN_CARD_SEAT = "plugins.bundle.config";
1522
1803
  /** The service dsh-web-settings publishes while it is loaded. */
1523
1804
  const FAMILY_GROUP_SERVICE = "webUiSettings";
1524
1805
  /**
@@ -1581,7 +1862,7 @@ window.__ModuleLoader__.load({
1581
1862
  ...seat.inject === void 0 ? {} : { inject }
1582
1863
  } : {
1583
1864
  name: OFFICIAL_PLUGIN_CARD_SEAT,
1584
- key: seat.namespace,
1865
+ key: seat.bundle,
1585
1866
  locale: seat.locale,
1586
1867
  ...seat.inject === void 0 ? {} : { inject }
1587
1868
  }, component);
@@ -1603,19 +1884,41 @@ window.__ModuleLoader__.load({
1603
1884
  //#region src/client/index.ts
1604
1885
  /** Locale namespace this half owns. */
1605
1886
  const NS = "liangshen";
1606
- /** Settings namespace the settings card edits (the Host plugin registers it). */
1607
- const SETTINGS_NAMESPACE = "dsh-liangshen";
1608
1887
  /**
1609
- * Required client services: the slot registry, locale, sessions, and the roster
1610
- * Remote. Both `remote` and `remote.agentPresets` are declared: the context
1611
- * proxy refuses an uninjected service, and a nested service name does not imply
1612
- * its parent, so reading `ctx.remote.agentPresets` needs `remote` as well.
1888
+ * Settings namespace the settings card edits. Under the 0.1.7 settings
1889
+ * contract the namespace IS the Host profile entry id, so this names the
1890
+ * standalone row; the aggregate install mounts the generated
1891
+ * `web-ui-liangshen` row instead and the family binder resolves between the
1892
+ * two. Without that binder the card binds the entry id directly.
1893
+ */
1894
+ const SETTINGS_NAMESPACE = "liangshen";
1895
+ const LIANGSHEN_ENTRY_IDS = [
1896
+ "web-ui-liangshen",
1897
+ "ui-liangshen",
1898
+ SETTINGS_NAMESPACE
1899
+ ];
1900
+ function servedEntryId(forms) {
1901
+ let served;
1902
+ try {
1903
+ served = forms.describe().getSnapshot().view?.namespaces.map((view) => view.ns);
1904
+ } catch {
1905
+ served = void 0;
1906
+ }
1907
+ if (!served || served.length === 0) return SETTINGS_NAMESPACE;
1908
+ return LIANGSHEN_ENTRY_IDS.find((id) => served.includes(id)) ?? "liangshen";
1909
+ }
1910
+ /**
1911
+ * Required client services: the slot registry, locale, sessions, the shared
1912
+ * configuration forms, and the roster Remote. Both `remote` and
1913
+ * `remote.agentPresets` are declared: the context proxy refuses an uninjected
1914
+ * service, and a nested service name does not imply its parent, so reading
1915
+ * `ctx.remote.agentPresets` needs `remote` as well.
1613
1916
  */
1614
1917
  const inject = [
1615
1918
  "slots",
1616
1919
  "locale",
1617
1920
  "sessions",
1618
- "settingsScope",
1921
+ "configForms",
1619
1922
  "remote",
1620
1923
  "remote.agentPresets"
1621
1924
  ];
@@ -1641,9 +1944,10 @@ window.__ModuleLoader__.load({
1641
1944
  controller.start();
1642
1945
  } catch {}
1643
1946
  try {
1644
- const settingsCard = new LiangShenSettingsCardController((ctx.get("webUiSettings") ?? ctx.settingsScope).bind({ namespace: SETTINGS_NAMESPACE }));
1947
+ const binder = ctx.get("webUiSettings");
1948
+ const settingsCard = new LiangShenSettingsCardController(binder !== void 0 && typeof binder.bind === "function" ? binder.bind({ namespace: SETTINGS_NAMESPACE }) : ctx.configForms.get(servedEntryId(ctx.configForms)));
1645
1949
  installPluginCard(ctx, {
1646
- namespace: SETTINGS_NAMESPACE,
1950
+ bundle: "@linxin666/dsh-liangshen",
1647
1951
  id: "liangshen",
1648
1952
  order: 120,
1649
1953
  locale: NS,