dsh-cabinet-mode 0.5.3 → 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/client.js CHANGED
@@ -2407,8 +2407,13 @@ window.__ModuleLoader__.load({
2407
2407
  'body[data-ds-dark-theme] .cabinet-status-running{color:#4ade80}body[data-ds-dark-theme] .cabinet-status-inactive{color:#adb2b8}body[data-ds-dark-theme] .cabinet-status-provisioning{color:#f7ad31}body[data-ds-dark-theme] .cabinet-status-failed{color:#f25a5a}',
2408
2408
  '.cabinet-task-pending{color:#61666b}.cabinet-task-in_progress{color:#2563eb}.cabinet-task-completed{color:#15803d}',
2409
2409
  'body[data-ds-dark-theme] .cabinet-task-pending{color:#adb2b8}body[data-ds-dark-theme] .cabinet-task-in_progress{color:#60a5fa}body[data-ds-dark-theme] .cabinet-task-completed{color:#4ed17e}',
2410
- // task dependency edges (blocked → blocker): one class per blocker state,
2410
+ // task dependency edges (blocker → blocked): one class per blocker state,
2411
2411
  // same palette as TASK_COLOR (done #22c55e / active #3b82f6 / pending #9aa0a6)
2412
+ // Flow direction: the path now runs blocker → blocked, and a dash pattern
2413
+ // starts at path distance ≡ -offset, so animating offset 0 → -24 slides
2414
+ // the dashes toward the path END — with the arrow, toward the blocked
2415
+ // task. No sign flip was needed after reversing the path; this is a desk
2416
+ // derivation from the SVG dash rule, not a browser observation (未验证).
2412
2417
  '@keyframes cabinetEdgeFlow{to{stroke-dashoffset:-24}}',
2413
2418
  '.cabinet-edge{fill:none;stroke-width:1.5;stroke-linecap:round}',
2414
2419
  '.cabinet-edge-done{stroke:light-dark(#15803d,#4ade80)}',
@@ -2526,6 +2531,7 @@ window.__ModuleLoader__.load({
2526
2531
  八、责任到人:缺陷点名到人到行号,不许用「我们」糊过去。
2527
2532
  九、反制糊弄:报「已完成」必追问证据三件(命令输出、路径行号、未验证清单);报「卡住」必追问三件(已做什么、卡在哪、需要什么);两次含糊即降级处理(换人、拆小)。
2528
2533
  十、收束:闭环才许说「这一版可以交差」,不许提前许诺功劳。
2534
+ 十一、监控纠偏:分派时约定回报节点、产物清单和单一交付范围;按实际可用的团队状态与消息工具检查进展,必要时要求回报做了什么、卡在哪里、需要什么。工具未提供时间字段时不得臆造耗时;文件时间戳仅作辅助,须读回产物并结合执行状态。finished、not found 或暂时沉默均不是成功或安全接管的证据。同一命令反复无进展、任务范围过大时先核实原因,再请求中断;中断返回不代表在途工具或写入已结束。必须确认原执行者及其写入停止后才能重派同一工作,无法确认则报告阻塞,不并发增加第二写入者。收窄任务后可重派或换人;超出当前上下文的回访使用宿主明确支持的调度机制,没有该机制不得承诺定时自动唤醒。
2529
2535
  红线(压过全部话术):只对 AI 阁臣施压,对用户只有敬;不许逼造假、删证据、凑绿;不许人身侮辱辱骂;不许以施压换取违规操作(越权改 live、泄密钥、跳验收);施压必须落在可核验的时间/交付物/判据上,空口威胁无效。`;
2530
2536
  /**
2531
2537
  * Factory duty prompt for each non-Lead member — the office duties the
@@ -2554,6 +2560,34 @@ window.__ModuleLoader__.load({
2554
2560
  let memberWriter = null;
2555
2561
  /** Host remote handle for the model catalog; null degrades the picker to text. */
2556
2562
  let memberRemote = null;
2563
+ /**
2564
+ * Optional uiWorkspace opener, captured by ctx.inject() inside apply()
2565
+ * (same pattern as memberRemote/memberWriter). It stays null on a
2566
+ * deployment without the workspace service, and every panel click then
2567
+ * degrades to a silent no-op instead of throwing at the panel.
2568
+ */
2569
+ let cabinetOpenSession = null;
2570
+ /**
2571
+ * Open a teammate's child session the way the native roster does
2572
+ * (dsh-experimental-client-ui-agent-team openTeammate): the Lead session
2573
+ * is the parent, the member id the child, mode "continuable"; when the
2574
+ * target IS the parent the native code takes the plain-string branch, so
2575
+ * mirror that too. Returns false when the channel or the id is missing —
2576
+ * callers simply do nothing, no exception reaches the panel.
2577
+ */
2578
+ function openCabinetSession(childSessionId, parentSessionId) {
2579
+ const open = cabinetOpenSession;
2580
+ if (typeof open !== 'function') return false;
2581
+ if (typeof childSessionId !== 'string' || childSessionId === '') return false;
2582
+ try {
2583
+ if (parentSessionId && childSessionId === parentSessionId) open(parentSessionId);
2584
+ else open({ parentSessionId: parentSessionId ?? childSessionId, childSessionId, mode: 'continuable' });
2585
+ return true;
2586
+ } catch (error) {
2587
+ try { console.warn('[cabinet-ui] open session failed:', error); } catch (ignored) { /* console may be unavailable */ }
2588
+ return false;
2589
+ }
2590
+ }
2557
2591
  const MEMBER_LISTENERS = new Set();
2558
2592
  let memberT = (key) => key;
2559
2593
  function clampMemberText(value, limit) {
@@ -2996,13 +3030,23 @@ window.__ModuleLoader__.load({
2996
3030
  // line one; status dot + state text (+ live dots / model) on line two.
2997
3031
  // State text carries a theme-aware class so 11px copy clears 3:1 in both
2998
3032
  // themes; the badge keeps lead's formula with a light-theme dark amber.
2999
- function MemberCard({ member, running, model, isCurrent, lead, statusLabel, t, size, children }) {
3033
+ function MemberCard({ member, running, model, isCurrent, lead, statusLabel, t, size, onOpen, children }) {
3000
3034
  const tt = typeof t === 'function' ? t : (key) => key;
3001
3035
  const status = member.phase === 'active' ? (running ? 'running' : 'inactive') : member.phase;
3036
+ // Availability mirrors the native roster row (agent-team TeamMemberRow):
3037
+ // the session you are already viewing, and failed/provisioning members,
3038
+ // are inert — no click, no pointer cursor. Opening also needs a real
3039
+ // session id, which is what member.id is (sessionIdSchema).
3040
+ const canOpen = typeof onOpen === 'function'
3041
+ && isCurrent !== true
3042
+ && member.phase !== 'failed'
3043
+ && member.phase !== 'provisioning'
3044
+ && typeof member.id === 'string' && member.id !== '';
3002
3045
  return h('div', { className: lead ? 'cabinet-card cabinet-card-lead' : 'cabinet-card', style: { position: 'relative', zIndex: 1 } }, [
3003
3046
  h('div', {
3004
3047
  key: 'who',
3005
- style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap', minWidth: 0 }
3048
+ onClick: canOpen ? () => onOpen(member) : undefined,
3049
+ style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap', minWidth: 0, cursor: canOpen ? 'pointer' : undefined }
3006
3050
  }, [
3007
3051
  h(Avatar, { key: 'avatar', name: member.name, size: size || 22, live: status === 'running' }),
3008
3052
  h('span', {
@@ -3039,11 +3083,16 @@ window.__ModuleLoader__.load({
3039
3083
  ]);
3040
3084
  }
3041
3085
 
3042
- function TaskLine({ task, blockerOf, t, taskLabel, ownerRunning }) {
3086
+ function TaskLine({ task, blockerOf, t, taskLabel, ownerRunning, onOpenOwner }) {
3043
3087
  const [openBlockers, setOpenBlockers] = React.useState(true);
3044
3088
  const status = TASK_COLOR[task.status] ? task.status : 'pending';
3045
3089
  const color = TASK_COLOR[status];
3046
3090
  const blockers = Array.isArray(task.blockedBy) ? [...new Set(task.blockedBy.filter((id) => typeof id === 'string' && id !== task.id))] : [];
3091
+ // The subject itself is the affordance, but only when the panel handed
3092
+ // us a resolved opener: lead-owned, unassigned, foreign-owner and
3093
+ // inert-owner tasks arrive with onOpenOwner === null and keep the plain
3094
+ // look (no onClick, no pointer cursor).
3095
+ const openTask = typeof onOpenOwner === 'function';
3047
3096
  const parts = [
3048
3097
  h('span', {
3049
3098
  key: 'dot',
@@ -3053,8 +3102,9 @@ window.__ModuleLoader__.load({
3053
3102
  h('span', { key: 'st', className: 'cabinet-task-' + status, style: { fontSize: 11, flex: 'none' } }, taskLabel(status)),
3054
3103
  h('span', {
3055
3104
  key: 'subj',
3056
- style: { fontSize: 12.5, color: INK, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
3057
- title: task.subject
3105
+ style: { fontSize: 12.5, color: INK, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', cursor: openTask ? 'pointer' : undefined },
3106
+ title: task.subject,
3107
+ onClick: openTask ? () => onOpenOwner(task) : undefined
3058
3108
  }, task.subject)
3059
3109
  ];
3060
3110
  if (!task.ownerName) {
@@ -3100,11 +3150,13 @@ window.__ModuleLoader__.load({
3100
3150
  }, children);
3101
3151
  }
3102
3152
 
3103
- // Dependency-edge overlay: one cubic path + one blocker-side dot per edge,
3104
- // paths are masked behind card interiors; endpoint dots remain visible. The
3105
- // layer is pointer-transparent, so rows stay
3106
- // clickable. `data-cabinet-edge="<blocked>-><blocker>"` plus a
3107
- // cabinet-edge-pending/active/done class makes every edge assertable.
3153
+ // Dependency-edge overlay: one cubic path + one blocked-side dot per edge
3154
+ // (the line leaves the blocker's row and lands on the blocked task's row),
3155
+ // masked behind card interiors while endpoint dots remain visible. The
3156
+ // layer is pointer-transparent, so rows stay clickable.
3157
+ // `data-cabinet-edge="<blocked>-><blocker>"` — key format is unchanged by
3158
+ // the geometry flip — plus a cabinet-edge-pending/active/done class makes
3159
+ // every edge assertable.
3108
3160
  function TaskEdgeLayer({ edges, cards = [] }) {
3109
3161
  const maskId = React.useId();
3110
3162
  if (!Array.isArray(edges) || edges.length === 0) return null;
@@ -3240,16 +3292,19 @@ window.__ModuleLoader__.load({
3240
3292
  }
3241
3293
  return paths;
3242
3294
  }
3243
- // One cubic per dependency: from the blocked task's row to its blocker's
3244
- // row, both endpoints taken from task-row DOM rects relative to the
3245
- // overlay container. State mirrors the BLOCKER's status — completed →
3246
- // solid green, in_progress → flowing dashes (travelling toward the
3247
- // blocker, "the dependency is progressing"), pending → static grey
3248
- // dashes; a missing or deleted blocker, or an unmeasured row, draws
3249
- // nothing (tolerant, never throws). Edges sharing a source row or a
3250
- // target row fan their control points apart so parallel lines never sit
3251
- // exactly on top of each other. Returns null while the panel is hidden
3252
- // (zero-size base) so a collapsed pane keeps the last drawing.
3295
+ // One cubic per dependency: from the BLOCKER's row to the blocked task's
3296
+ // row (首辅 → 阁臣 reading on a normal board), both endpoints taken from
3297
+ // task-row DOM rects relative to the overlay container. The edge key stays
3298
+ // `<blocked>-><blocker>` — only the geometry flipped, so data-cabinet-edge
3299
+ // and the CSS class names keep their old form. State mirrors the BLOCKER's
3300
+ // status — completed → solid green, in_progress → flowing dashes
3301
+ // (travelling with the arrow, toward the blocked task, "the dependency is
3302
+ // progressing"), pending → static grey dashes; a missing or deleted
3303
+ // blocker, or an unmeasured row, draws nothing (tolerant, never throws).
3304
+ // Edges sharing a source row or a target row fan their control points
3305
+ // apart so parallel lines never sit exactly on top of each other. Returns
3306
+ // null while the panel is hidden (zero-size base) so a collapsed pane
3307
+ // keeps the last drawing.
3253
3308
  function buildTaskEdges(base, tasks, rectOf, isLive) {
3254
3309
  if (!base || base.width === 0 || base.height === 0) return null;
3255
3310
  const list = Array.isArray(tasks) ? tasks : [];
@@ -3275,8 +3330,13 @@ window.__ModuleLoader__.load({
3275
3330
  seen.add(key);
3276
3331
  const blocker = byId.get(blockerId);
3277
3332
  if (!blocker || blocker.status === 'deleted') continue; // missing/removed task: skip, don't crash
3278
- const from = rectOf(task.id);
3279
- const to = rectOf(blockerId);
3333
+ // Geometry reversed: the path starts on the blocker's row and
3334
+ // ends on the blocked task's row (the key above still reads
3335
+ // blocked->blocker). from/to drive the anchors, fromId/toId the
3336
+ // parallel-edge fan, and the endpoint dot lands on edge.e — i.e.
3337
+ // on the blocked task.
3338
+ const from = rectOf(blockerId);
3339
+ const to = rectOf(task.id);
3280
3340
  if (!from || !to || from.width === 0 || from.height === 0 || to.width === 0 || to.height === 0) continue;
3281
3341
  const state = blocker.status === 'completed' ? 'done'
3282
3342
  : blocker.status === 'in_progress' ? 'active'
@@ -3285,8 +3345,8 @@ window.__ModuleLoader__.load({
3285
3345
  key,
3286
3346
  state,
3287
3347
  live: state === 'active' && typeof isLive === 'function' && isLive(blockerId) === true,
3288
- fromId: task.id,
3289
- toId: blockerId,
3348
+ fromId: blockerId,
3349
+ toId: task.id,
3290
3350
  from: rel(from),
3291
3351
  to: rel(to)
3292
3352
  });
@@ -3325,9 +3385,10 @@ window.__ModuleLoader__.load({
3325
3385
  edge.c2 = [c2x, c2y];
3326
3386
  edge.e = [ex, ey];
3327
3387
  }
3328
- // Parallel-edge offset: edges from the same row (or into the same
3329
- // blocker row) share an anchor, so shift their control points apart
3330
- // perpendicular to the travel axis (7px pitch, centred on the group).
3388
+ // Parallel-edge offset: edges leaving the same blocker row (or arriving
3389
+ // at the same blocked row) share an anchor, so shift their control
3390
+ // points apart perpendicular to the travel axis (7px pitch, centred on
3391
+ // the group). fromId is the blocker, toId the blocked task.
3331
3392
  const fan = (pointField, idField, prefix) => {
3332
3393
  const groups = new Map();
3333
3394
  for (const edge of edges) {
@@ -3576,6 +3637,24 @@ window.__ModuleLoader__.load({
3576
3637
  const isLeadTask = (task) => task.ownerName === 'lead' || (lead !== undefined && task.ownerName === lead.name);
3577
3638
  const unassigned = tasks.filter((task) => !task.ownerName);
3578
3639
  const leadOwn = tasks.filter((task) => task.ownerName !== undefined && isLeadTask(task));
3640
+
3641
+ // ---- click-to-open a member's child session (optional channel) ----
3642
+ // cabinetOpenSession is filled by ctx.inject(['uiWorkspace']) in apply()
3643
+ // and stays null when the service is missing — the helpers below then
3644
+ // return false and the click does nothing. Availability follows the
3645
+ // native roster's inert rule (agent-team: self / failed / provisioning
3646
+ // never open); lead-owned and unassigned tasks resolve to no member at
3647
+ // all, so the panel hands TaskLine null and nothing is bound.
3648
+ const openableMember = (member) => Boolean(member)
3649
+ && typeof member.id === 'string' && member.id !== ''
3650
+ && member.id !== sessionId
3651
+ && member.phase !== 'failed'
3652
+ && member.phase !== 'provisioning';
3653
+ const openMemberSession = (member) => openableMember(member) && openCabinetSession(member.id, leadSessionId);
3654
+ const ownerMemberOf = (task) => (task && task.ownerName && !isLeadTask(task) ? memberByName.get(task.ownerName) : undefined);
3655
+ const openOwnerSession = (task) => openMemberSession(ownerMemberOf(task));
3656
+ // Per-task opener handed to TaskLine: null means "do not bind".
3657
+ const ownerOpener = (task) => (openableMember(ownerMemberOf(task)) ? openOwnerSession : null);
3579
3658
  const rosterNames = new Set(mates.map((member) => member.name));
3580
3659
  const foreignOwners = [];
3581
3660
  for (const task of tasks) {
@@ -3599,7 +3678,8 @@ window.__ModuleLoader__.load({
3599
3678
  lead: true,
3600
3679
  size: 26,
3601
3680
  statusLabel,
3602
- t: tt
3681
+ t: tt,
3682
+ onOpen: openMemberSession
3603
3683
  });
3604
3684
 
3605
3685
  // Cells: every minister first, then 未分派 / 首辅自办 / 不在册 as
@@ -3657,6 +3737,7 @@ window.__ModuleLoader__.load({
3657
3737
  isCurrent: member.id === sessionId,
3658
3738
  statusLabel,
3659
3739
  t: tt,
3740
+ onOpen: openMemberSession,
3660
3741
  // tasks live inside the card, elbow-connected by RailList
3661
3742
  children: own.length > 0
3662
3743
  ? h(RailList, { key: 'tasks', style: { marginTop: 4 } }, own.map((task) => h(TaskLine, {
@@ -3665,7 +3746,8 @@ window.__ModuleLoader__.load({
3665
3746
  blockerOf,
3666
3747
  t: tt,
3667
3748
  taskLabel,
3668
- ownerRunning: memberRunning
3749
+ ownerRunning: memberRunning,
3750
+ onOpenOwner: ownerOpener(task)
3669
3751
  })))
3670
3752
  : h('div', { key: 'tasks', style: { fontSize: 11, color: INK3, padding: '2px 0' } }, tt('task.none'))
3671
3753
  });
@@ -3681,7 +3763,8 @@ window.__ModuleLoader__.load({
3681
3763
  blockerOf,
3682
3764
  t: tt,
3683
3765
  taskLabel,
3684
- ownerRunning: false
3766
+ ownerRunning: false,
3767
+ onOpenOwner: ownerOpener(task)
3685
3768
  })))
3686
3769
  ]);
3687
3770
  }
@@ -3793,9 +3876,184 @@ window.__ModuleLoader__.load({
3793
3876
  };
3794
3877
  }
3795
3878
 
3879
+ // ---------- memory plugin install card (one-click, 方案A) --------------
3880
+ // Optional install channel: set by the ctx.inject guard in apply() and
3881
+ // cleared on dispose. Without the host's plugin-manager remote the card
3882
+ // renders an explicit unavailable line instead of a dead button — the
3883
+ // same degradation as memberRemote and cabinetOpenSession.
3884
+ let cabinetPluginManager = null;
3885
+ const memoryPluginListeners = new Set();
3886
+ const notifyMemoryPlugin = () => { for (const listener of memoryPluginListeners) listener(); };
3887
+ /** Package this card manages. */
3888
+ const MEMORY_PLUGIN_NAME = '@rsrsai/dsh';
3889
+ /** Public pinned package; inspect and install use the same spec. */
3890
+ const MEMORY_PLUGIN_SPEC = '@rsrsai/dsh@0.1.13';
3891
+ const MEMORY_PLUGIN_SOURCE_VERSION = '';
3892
+ const memoryPluginJobs = new WeakMap();
3893
+ const memoryPluginRestart = new WeakSet();
3894
+ function pluginDeadline(operation, ms = 120000) {
3895
+ let timer;
3896
+ return Promise.race([operation, new Promise((_, reject) => { timer = setTimeout(() => reject(new Error('Plugin operation timed out; outcome may still be pending. Check the native plugin manager before retrying.')), ms); })]).finally(() => clearTimeout(timer));
3897
+ }
3898
+ /** The five settings tabs, in display order. */
3899
+ const SETTINGS_TABS = ['members', 'avatars', 'models', 'prompts', 'plugin'];
3900
+ /** Derive the card's installed state from a listBundles() reply. */
3901
+ function memoryPluginInstalledOf(bundles) {
3902
+ if (!Array.isArray(bundles)) return null;
3903
+ const hit = bundles.find((entry) => entry && entry.name === MEMORY_PLUGIN_NAME && entry.installed === true);
3904
+ return hit === undefined ? null : { name: MEMORY_PLUGIN_NAME, version: typeof hit.version === 'string' ? hit.version : '', enabled: hit.enabled === true };
3905
+ }
3906
+ function MemoryPluginCard(props) {
3907
+ const [, refreshChannel] = React.useState(0);
3908
+ React.useEffect(() => { const listener = () => refreshChannel(n => n + 1); memoryPluginListeners.add(listener); return () => memoryPluginListeners.delete(listener); }, []);
3909
+ const t = typeof props?.t === 'function' ? props.t : memberT;
3910
+ // Explicit props win so a host-driven render (and the tests) can pin the
3911
+ // channel; omitting them reads the injected module state.
3912
+ const manager = props !== undefined && props !== null && Object.hasOwn(props, 'manager') ? props.manager : cabinetPluginManager;
3913
+ const lifetime = React.useRef(null);
3914
+ if (!lifetime.current || lifetime.current.manager !== manager) {
3915
+ if (lifetime.current) lifetime.current.active = false;
3916
+ lifetime.current = {manager, active:true, epoch:0};
3917
+ }
3918
+ const token = lifetime.current;
3919
+ React.useEffect(() => { token.active = true; return () => { token.active = false; }; }, [token]);
3920
+ const [installed, writeInstalled] = React.useState(props?.initialInstalled ?? null);
3921
+ const [working, writeWorking] = React.useState(false);
3922
+ const [progress, writeProgress] = React.useState('');
3923
+ const [failure, writeFailure] = React.useState('');
3924
+ const [restart, writeRestart] = React.useState(manager ? memoryPluginRestart.has(manager) : false);
3925
+ const setInstalled = value => { if (token.active) writeInstalled(value); };
3926
+ const setWorking = value => { if (token.active) writeWorking(value); };
3927
+ const setProgress = value => { if (token.active) writeProgress(value); };
3928
+ const setFailure = value => { if (token.active) writeFailure(value); };
3929
+ const setRestart = value => { if (token.active) writeRestart(value); };
3930
+ React.useEffect(() => {
3931
+ let alive = true;
3932
+ const generation = token.epoch;
3933
+ (async () => {
3934
+ if (!manager || typeof manager.listBundles !== 'function') return;
3935
+ try {
3936
+ const reply = await pluginDeadline(manager.listBundles());
3937
+ const found = reply?.ok === true ? memoryPluginInstalledOf(reply.value) : null;
3938
+ if (alive && generation === token.epoch && reply?.ok === true) setInstalled(found);
3939
+ } catch { /* keep the render-time state; the card still shows */ }
3940
+ })();
3941
+ return () => { alive = false; };
3942
+ }, [manager]);
3943
+ // Failures are echoed verbatim: the raw message is the evidence.
3944
+ const fail = (text) => { setWorking(false); setFailure(typeof text === 'string' && text !== '' ? text : String(text)); };
3945
+
3946
+ const run = async () => {
3947
+ if (!manager || typeof manager.inspect !== 'function' || typeof manager.installBundle !== 'function' || typeof manager.listBundles !== 'function') { fail('pluginManager remote unavailable'); return; }
3948
+ if (memoryPluginJobs.get(manager)?.running) return;
3949
+ if (memoryPluginJobs.get(manager)?.settled === true) memoryPluginJobs.delete(manager);
3950
+ if (memoryPluginJobs.has(manager)) { fail('An operation is pending or its result is unknown. Check the native plugin manager; do not start another installation.'); return; }
3951
+ token.epoch++;
3952
+ const job = {settled:false,running:true}; memoryPluginJobs.set(manager, job);
3953
+ const observe = (operation, update = false) => Promise.resolve(operation).then(reply => {
3954
+ const outcome = update ? reply?.value?.result : reply?.value;
3955
+ job.settled = reply?.ok === true && ['applied','restart-required','failed','cancelled'].includes(outcome?.application);
3956
+ return reply;
3957
+ });
3958
+ let uncertain = false;
3959
+ setWorking(true); setFailure(''); setRestart(memoryPluginRestart.has(manager)); setProgress('');
3960
+ const valueOf = reply => {
3961
+ if (reply?.ok !== true) throw new Error(reply?.error?.message || 'Plugin manager returned no successful reply');
3962
+ return reply.value;
3963
+ };
3964
+ const outcomeOf = outcome => {
3965
+ if (!outcome || !['applied', 'restart-required'].includes(outcome.application)) throw new Error(outcome?.error?.message || outcome?.error?.diagnostic || outcome?.packageResult?.stderr || outcome?.application || 'Unknown plugin application result');
3966
+ if (outcome.application === 'restart-required') { memoryPluginRestart.add(manager); setRestart(true); }
3967
+ return outcome;
3968
+ };
3969
+ try {
3970
+ const before = memoryPluginInstalledOf(valueOf(await pluginDeadline(manager.listBundles())));
3971
+ if (before && before.version !== '0.1.13') {
3972
+ // Only known, older stable versions are offered this pinned update.
3973
+ // The official host independently enforces semver.gt(target, installed).
3974
+ const parts = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.exec(before.version);
3975
+ const values = parts?.slice(1).map(Number);
3976
+ const older = values && values.every(Number.isSafeInteger) && values[0] === 0 && (values[1] === 0 || values[1] === 1 && values[2] < 13);
3977
+ if (!older) throw new Error('Installed version is newer than the pinned version or cannot be safely compared. Use the native plugin manager; no package was changed.');
3978
+ }
3979
+ const inspected = valueOf(await pluginDeadline(manager.inspect(MEMORY_PLUGIN_SPEC, {})));
3980
+ if (!inspected || inspected.status !== 'accepted' || inspected.name !== MEMORY_PLUGIN_NAME || inspected.bundle !== true) throw new Error(inspected?.reason || 'Plugin spec refused');
3981
+ const requestId = globalThis.crypto?.randomUUID?.() || 'cabinet-' + Date.now() + '-' + Math.random().toString(16).slice(2);
3982
+ let outcome;
3983
+ if (before && before.version === '0.1.13') {
3984
+ outcome = { application: 'applied' };
3985
+ } else {
3986
+ if (before && typeof manager.updateBundle !== 'function') throw new Error('Use the native plugin manager to update this installed bundle');
3987
+ uncertain = true;
3988
+ const operation = before ? manager.updateBundle(MEMORY_PLUGIN_NAME, '0.1.13', {requestId}) : manager.installBundle(MEMORY_PLUGIN_SPEC, {enabled:false,requestId});
3989
+ let reply = await pluginDeadline(observe(operation, !!before));
3990
+ if (reply?.ok !== true && !before && typeof manager.waitForInstall === 'function') reply = await pluginDeadline(observe(manager.waitForInstall(requestId)));
3991
+ const result = valueOf(reply);
3992
+ if (!result) throw new Error('Install outcome is unknown; check the native plugin manager before retrying');
3993
+ outcome = before ? result.result : result;
3994
+ if (!outcome || !['applied','restart-required','failed','cancelled'].includes(outcome.application)) throw new Error('Install outcome is unknown');
3995
+ uncertain = false;
3996
+ outcomeOf(outcome);
3997
+ }
3998
+ // Installation and enabling are separate operations; neither implies the other succeeded.
3999
+ setInstalled({name:MEMORY_PLUGIN_NAME,version:outcome.version || before?.version || '',enabled:false});
4000
+ if (!token.active) return;
4001
+ if (typeof manager.setBundleEnabled !== 'function') throw new Error('Installed, but enable is unavailable; enable it in the native plugin manager');
4002
+ uncertain = true; job.settled = false;
4003
+ const enabled = valueOf(await pluginDeadline(observe(manager.setBundleEnabled(MEMORY_PLUGIN_NAME,true))));
4004
+ if (!enabled || !['applied','restart-required','failed','cancelled'].includes(enabled.application)) throw new Error('Enable outcome is unknown');
4005
+ uncertain = false;
4006
+ outcomeOf(enabled);
4007
+ const found = memoryPluginInstalledOf(valueOf(await pluginDeadline(manager.listBundles())));
4008
+ if (!found) throw new Error('Installation cannot be confirmed from the plugin inventory');
4009
+ setInstalled(found);
4010
+ if (!found.enabled) throw new Error('Installed, but the plugin inventory reports disabled');
4011
+ setFailure('');
4012
+ } catch(error) { fail(error?.message || String(error)); }
4013
+ finally {
4014
+ job.running = false;
4015
+ if (!uncertain && memoryPluginJobs.get(manager) === job) memoryPluginJobs.delete(manager);
4016
+ setWorking(false);
4017
+ }
4018
+ };
4019
+ // Version shown on the card: the installed bundle's own version, with
4020
+ // the local source package.json version as display-only fallback.
4021
+ const hasInstalledVersion = installed !== null && typeof installed.version === 'string' && installed.version !== '';
4022
+ const shownVersion = hasInstalledVersion ? installed.version : MEMORY_PLUGIN_SOURCE_VERSION;
4023
+ const line = { fontSize: 11, color: INK3, marginTop: 4 };
4024
+ const border = '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.28))';
4025
+ return h('div', { 'data-cabinet-plugin-card': 'memory', style: { border, borderRadius: 8, padding: '10px 12px', marginBottom: 10 } }, [
4026
+ h('div', { key: 'head', style: { display: 'flex', alignItems: 'center', gap: 8 } }, [
4027
+ h('span', { key: 'gap', style: { flex: 1 } }),
4028
+ installed !== null ? h('span', { key: 'badge', 'data-cabinet-plugin-state': 'installed', style: { fontSize: 11, color: '#3fb950' } }, t('settings.plugin.installed')) : null
4029
+ ]),
4030
+ // Highlight lines replace the old one-line description; the file:
4031
+ // path and the registry spec are install parameters only and are
4032
+ // never rendered on the card face.
4033
+ h('div', { key: 'hints', style: line }, [1, 2, 3, 4, 5].map((n) => h('div', { key: 'hint' + n, 'data-cabinet-plugin-hint': String(n), style: { ...line, marginTop: 3 } }, t('settings.plugin.hint' + n)))),
4034
+ installed !== null
4035
+ ? h('div', { key: 'where', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginTop: 8 } }, [
4036
+ h('span', { key: 'version', 'data-cabinet-plugin-version': shownVersion, style: { fontSize: 11, color: INK2 } }, shownVersion + (hasInstalledVersion ? '' : ' · ' + t('settings.plugin.versionFallback'))),
4037
+ h('span', { key: 'gap2', style: { flex: 1 } }),
4038
+ h('button', { key: 'update', 'data-cabinet-plugin-action': 'update', type: 'button', disabled: !manager || working, style: { fontSize: 11, cursor: 'pointer' }, onClick: () => { void run(); } }, working ? t('settings.plugin.installing') : t('settings.plugin.update'))
4039
+ ])
4040
+ : h('div', { key: 'row', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginTop: 8 } }, [
4041
+ h('button', { key: 'install', 'data-cabinet-plugin-action': 'install', type: 'button', disabled: !manager || working, style: { fontSize: 11, cursor: 'pointer' }, onClick: () => { void run(); } }, working ? t('settings.plugin.installing') : t('settings.plugin.install'))
4042
+ ]),
4043
+ !manager ? h('div', { key: 'unavailable', 'data-cabinet-plugin-state': 'unavailable', style: line }, t('settings.plugin.unavailable')) : null,
4044
+ progress !== '' ? h('div', { key: 'progress', 'data-cabinet-plugin-progress': '1', style: line }, progress) : null,
4045
+ restart ? h('div', { key: 'restart', 'data-cabinet-plugin-state': 'restart', style: { ...line, color: '#d29922' } }, t('settings.plugin.restartRequired')) : null,
4046
+ failure !== '' ? h('div', { key: 'failure', 'data-cabinet-plugin-state': 'error', style: { ...line, color: '#f25a5a' } }, failure) : null
4047
+ ]);
4048
+ }
4049
+
3796
4050
  function CabinetMemberSettings(props) {
3797
4051
  const t = typeof props?.t === 'function' ? props.t : memberT;
3798
4052
  const [, redraw] = React.useState(0);
4053
+ // Active settings tab: session-local state (approved plan A). It is a
4054
+ // navigation preference, not user data, and client.js has no
4055
+ // localStorage precedent — so no second persistence source.
4056
+ const [activeTab, setActiveTab] = React.useState('members');
3799
4057
  const editorRef = React.useRef(null);
3800
4058
  if (!editorRef.current) editorRef.current = createMemberEditor(memberWriter, () => redraw(n => n + 1));
3801
4059
  const editor = editorRef.current;
@@ -3846,7 +4104,7 @@ window.__ModuleLoader__.load({
3846
4104
  onClick: () => resetMember(key)
3847
4105
  }, t('member.reset'))
3848
4106
  ]),
3849
- h('div', { key: 'builtin', style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', marginBottom: 6 } }, [
4107
+ activeTab === 'avatars' ? h('div', { key: 'builtin', style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', marginBottom: 6 } }, [
3850
4108
  h('span', { key: 'l', style: { fontSize: 11, color: INK3 } }, t('member.builtin')),
3851
4109
  ...(function () {
3852
4110
  const out = [];
@@ -3874,59 +4132,65 @@ window.__ModuleLoader__.load({
3874
4132
  t('member.upload')
3875
4133
  ]),
3876
4134
  avatars[key] ? h('button', { key: 'clear', type: 'button', style: { fontSize: 11, cursor: 'pointer' }, onClick: () => writeAvatar(key, '') }, t('member.avatar.clear')) : null
3877
- ]),
4135
+ ]) : null,
3878
4136
  errors[key] ? h('div', { key: 'e', style: { fontSize: 11, color: '#f25a5a', marginBottom: 4 } }, errors[key] === 'member.error.model' ? t(errors[key]) : errors[key]) : null,
3879
- h('label', { key: 'name', style: { display: 'block', fontSize: 11, color: INK2, marginBottom: 2 } }, t('member.name')),
3880
- h('input', {
3881
- key: 'ni',
3882
- type: 'text',
3883
- value: draft[key].name,
3884
- maxLength: MEMBER_NAME_LIMIT,
3885
- placeholder: t('member.name.placeholder'),
3886
- style: inputStyle,
3887
- onChange: (event) => update(key, { name: event?.target?.value ?? '' })
3888
- }),
3889
- h('label', { key: 'ml', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.model')),
3890
- modelOptions.length > 0
3891
- ? (function () {
3892
- const value = draft[key].model || '';
3893
- const opts = [h('option', { key: '', value: '' }, t(key === 'lead' ? 'member.model.defaultLead' : 'member.model.default'))];
3894
- if (value !== '' && !modelOptions.some((option) => option.value === value)) opts.push(h('option', { key: 'current', value }, value));
3895
- for (const option of modelOptions) opts.push(h('option', { key: option.value, value: option.value }, option.label));
3896
- return h('select', {
4137
+ activeTab === 'members' ? [
4138
+ h('label', { key: 'name', style: { display: 'block', fontSize: 11, color: INK2, marginBottom: 2 } }, t('member.name')),
4139
+ h('input', {
4140
+ key: 'ni',
4141
+ type: 'text',
4142
+ value: draft[key].name,
4143
+ maxLength: MEMBER_NAME_LIMIT,
4144
+ placeholder: t('member.name.placeholder'),
4145
+ style: inputStyle,
4146
+ onChange: (event) => update(key, { name: event?.target?.value ?? '' })
4147
+ })
4148
+ ] : null,
4149
+ activeTab === 'models' ? [
4150
+ h('label', { key: 'ml', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.model')),
4151
+ modelOptions.length > 0
4152
+ ? (function () {
4153
+ const value = draft[key].model || '';
4154
+ const opts = [h('option', { key: '', value: '' }, t(key === 'lead' ? 'member.model.defaultLead' : 'member.model.default'))];
4155
+ if (value !== '' && !modelOptions.some((option) => option.value === value)) opts.push(h('option', { key: 'current', value }, value));
4156
+ for (const option of modelOptions) opts.push(h('option', { key: option.value, value: option.value }, option.label));
4157
+ return h('select', {
4158
+ key: 'mi',
4159
+ value,
4160
+ style: inputStyle,
4161
+ onChange: (event) => update(key, { model: event?.target?.value ?? '' })
4162
+ }, opts);
4163
+ }())
4164
+ : h('input', {
3897
4165
  key: 'mi',
3898
- value,
4166
+ type: 'text',
4167
+ disabled: modelCatalog === undefined,
4168
+ value: draft[key].model,
4169
+ maxLength: 200,
4170
+ placeholder: 'provider/id',
3899
4171
  style: inputStyle,
3900
4172
  onChange: (event) => update(key, { model: event?.target?.value ?? '' })
3901
- }, opts);
3902
- }())
3903
- : h('input', {
3904
- key: 'mi',
3905
- type: 'text',
3906
- disabled: modelCatalog === undefined,
3907
- value: draft[key].model,
3908
- maxLength: 200,
3909
- placeholder: 'provider/id',
3910
- style: inputStyle,
3911
- onChange: (event) => update(key, { model: event?.target?.value ?? '' })
4173
+ }),
4174
+ modelCatalog !== undefined && modelOptions.length === 0 ? h('div', { key: 'mh', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.unavailable')) : null,
4175
+ h('div', { key: 'mhint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.hint'))
4176
+ ] : null,
4177
+ activeTab === 'prompts' ? [
4178
+ h('label', { key: 'prompt', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.prompt')),
4179
+ h('textarea', {
4180
+ key: 'pi',
4181
+ value: promptOf(key),
4182
+ maxLength: MEMBER_PROMPT_LIMIT,
4183
+ rows: key === 'lead' ? 8 : 3,
4184
+ placeholder: t('member.prompt.placeholder'),
4185
+ style: { ...inputStyle, resize: 'vertical', fontFamily: 'inherit' },
4186
+ onChange: (event) => {
4187
+ const value = event?.target?.value ?? '';
4188
+ const mode = value.trim() === '' ? 'off' : 'custom';
4189
+ update(key, { prompt: value, mode }, false);
4190
+ }
3912
4191
  }),
3913
- modelCatalog !== undefined && modelOptions.length === 0 ? h('div', { key: 'mh', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.unavailable')) : null,
3914
- h('div', { key: 'mhint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.model.hint')),
3915
- h('label', { key: 'prompt', style: { display: 'block', fontSize: 11, color: INK2, margin: '8px 0 2px' } }, t('member.prompt')),
3916
- h('textarea', {
3917
- key: 'pi',
3918
- value: promptOf(key),
3919
- maxLength: MEMBER_PROMPT_LIMIT,
3920
- rows: key === 'lead' ? 8 : 3,
3921
- placeholder: t('member.prompt.placeholder'),
3922
- style: { ...inputStyle, resize: 'vertical', fontFamily: 'inherit' },
3923
- onChange: (event) => {
3924
- const value = event?.target?.value ?? '';
3925
- const mode = value.trim() === '' ? 'off' : 'custom';
3926
- update(key, { prompt: value, mode }, false);
3927
- }
3928
- }),
3929
- key === 'lead' ? h('div', { key: 'hint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.lead.hint')) : null
4192
+ key === 'lead' ? h('div', { key: 'hint', style: { fontSize: 11, color: INK3, marginTop: 4 } }, t('member.lead.hint')) : null
4193
+ ] : null
3930
4194
  ]);
3931
4195
  });
3932
4196
  return h('div', { style: { padding: '4px 2px 20px' } }, [
@@ -3939,9 +4203,27 @@ window.__ModuleLoader__.load({
3939
4203
  !ready ? h('div', { key: 'unavailable', role: 'status' }, t('member.status.unavailable')) : null,
3940
4204
  status ? h('div', { key: 'status', style: { fontSize: 11, color: INK2, marginBottom: 8 } }, t(status)) : null,
3941
4205
  conflict ? h('div', { key: 'conflict', role: 'alert' }, t('member.status.conflict')) : null,
3942
- h('button', { key: 'catalog', type: 'button', onClick: () => refreshCatalog(value => value + 1) }, t('member.model.refresh')),
3943
- modelCatalog?.failures?.length ? h('div', { key: 'catalog-errors', role: 'status' }, t('member.model.partial')) : null,
3944
- h('fieldset', { key: 'fields', disabled: !ready || busy, style: { border: 0, padding: 0, margin: 0 } }, cards),
4206
+ // Tab bar: session-local active tab, one button per field group.
4207
+ // The catalog refresh only serves the model picker, so it lives
4208
+ // with the models tab instead of the global chrome.
4209
+ h('div', { key: 'tabs', role: 'tablist', style: { display: 'flex', gap: 6, marginBottom: 8, flexWrap: 'wrap' } }, SETTINGS_TABS.map((id) => h('button', {
4210
+ key: id,
4211
+ type: 'button',
4212
+ role: 'tab',
4213
+ 'aria-selected': activeTab === id,
4214
+ 'data-cabinet-settings-tab': id,
4215
+ 'data-cabinet-settings-active': activeTab === id ? '1' : '0',
4216
+ style: { fontSize: 11, cursor: 'pointer', padding: '3px 8px', borderRadius: 6, border: '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.4))', background: activeTab === id ? 'rgba(79,140,255,.16)' : 'transparent', color: activeTab === id ? INK : INK2 },
4217
+ onClick: () => setActiveTab(id)
4218
+ }, t('settings.tab.' + id)))),
4219
+ activeTab === 'models' ? h('div', { key: 'catalog-row', style: { marginBottom: 8 } }, [
4220
+ h('button', { key: 'catalog', type: 'button', 'data-cabinet-settings-refresh': '1', onClick: () => refreshCatalog(value => value + 1) }, t('member.model.refresh')),
4221
+ modelCatalog?.failures?.length ? h('div', { key: 'catalog-errors', role: 'status' }, t('member.model.partial')) : null
4222
+ ]) : null,
4223
+ activeTab === 'plugin' ? null : h('fieldset', { key: 'fields', disabled: !ready || busy, style: { border: 0, padding: 0, margin: 0 } }, cards),
4224
+ // Memory plugin card: the plugin tab's own content — hidden on every
4225
+ // other tab, so the default view's save/cancel are never preceded by it.
4226
+ activeTab === 'plugin' ? h(MemoryPluginCard, { key: 'memory-plugin', t }) : null,
3945
4227
  h('button', { key: 'save', type: 'button', disabled: !ready || busy || !dirty || conflict, onClick: () => editor.save() }, t('member.save')),
3946
4228
  h('button', { key: 'cancel', type: 'button', disabled: busy, onClick: () => editor.cancel() }, t('member.cancel'))
3947
4229
  ]);
@@ -4004,6 +4286,23 @@ window.__ModuleLoader__.load({
4004
4286
  'member.model.default': '使用首辅配置;未配置时使用 DSH 默认模型',
4005
4287
  'member.model.defaultLead': '使用 DSH 默认模型',
4006
4288
  'member.model.refresh': '刷新模型目录',
4289
+ 'settings.tab.members': '成员',
4290
+ 'settings.tab.avatars': '头像',
4291
+ 'settings.tab.models': '模型',
4292
+ 'settings.tab.prompts': '提示词',
4293
+ 'settings.tab.plugin': '记忆插件',
4294
+ 'settings.plugin.install': '一键安装',
4295
+ 'settings.plugin.installing': '安装中…',
4296
+ 'settings.plugin.installed': '已安装',
4297
+ 'settings.plugin.update': '更新',
4298
+ 'settings.plugin.versionFallback': '已安装版本未知',
4299
+ 'settings.plugin.restartRequired': '已安装,需重启 DSH 生效',
4300
+ 'settings.plugin.unavailable': '安装通道不可用:宿主未提供 remote.pluginManager。可在宿主会话执行 dsh plugin --profile web add <本地路径> 安装。',
4301
+ 'settings.plugin.hint1': 'respire/dsh:原生 TypeScript 记忆插件,存储、去重与加密由 rsrs 负责',
4302
+ 'settings.plugin.hint2': '自动召回:新会话自动想起早前结论,不用重复交代背景',
4303
+ 'settings.plugin.hint3': '本地优先:记忆存本机,引擎故障只提示、主任务照跑',
4304
+ 'settings.plugin.hint4': '教训入库:报错与教训沉淀成条,同一坑不踩第二次',
4305
+ 'settings.plugin.hint5': '结构化记忆:正文分段、判重合并,分类树可挂父子',
4007
4306
  'member.model.partial': '部分提供方加载失败;现有选择保留。可刷新重试。',
4008
4307
  'member.error.model': '模型必须为 provider/id,最长 200 字符,不能含控制字符。',
4009
4308
  'member.model.unavailable': '模型列表暂不可用:请手动输入 provider/id。',
@@ -4069,6 +4368,23 @@ window.__ModuleLoader__.load({
4069
4368
  'member.model.default': 'Use Lead configuration, otherwise DSH default',
4070
4369
  'member.model.defaultLead': 'Use DSH default model',
4071
4370
  'member.model.refresh': 'Refresh model catalog',
4371
+ 'settings.tab.members': 'Members',
4372
+ 'settings.tab.avatars': 'Avatars',
4373
+ 'settings.tab.models': 'Models',
4374
+ 'settings.tab.prompts': 'Prompts',
4375
+ 'settings.tab.plugin': 'Memory Plugin',
4376
+ 'settings.plugin.install': 'Install',
4377
+ 'settings.plugin.installing': 'Installing…',
4378
+ 'settings.plugin.installed': 'Installed',
4379
+ 'settings.plugin.update': 'Update',
4380
+ 'settings.plugin.versionFallback': 'Installed version unavailable',
4381
+ 'settings.plugin.restartRequired': 'Installed; restart DSH to take effect',
4382
+ 'settings.plugin.unavailable': 'Install channel unavailable: the host did not expose remote.pluginManager. Run dsh plugin --profile web add <local path> in a host session instead.',
4383
+ 'settings.plugin.hint1': 'respire/dsh: native TypeScript memory plugin; rsrs owns storage, dedup and encryption',
4384
+ 'settings.plugin.hint2': 'Auto-recall: a new session resurfaces earlier conclusions without re-briefing',
4385
+ 'settings.plugin.hint3': 'Local first: memories stay on this machine; an engine outage only notices, work continues',
4386
+ 'settings.plugin.hint4': 'Lessons recorded: errors and pitfalls are stored, to help avoid repeating earlier mistakes',
4387
+ 'settings.plugin.hint5': 'Structured memory: sectioned bodies, dedup and merges, a taxonomy tree with parents',
4072
4388
  'member.model.partial': 'Some providers failed to load; saved choices are retained. Refresh to retry.',
4073
4389
  'member.error.model': 'Use provider/id, at most 200 characters, without control characters.',
4074
4390
  'member.model.unavailable': 'Model list unavailable: type provider/id manually.',
@@ -4122,6 +4438,32 @@ window.__ModuleLoader__.load({
4122
4438
  return () => { if (memberRemote === remote) memberRemote = null; };
4123
4439
  }, 'cabinet-ui: model catalog remote');
4124
4440
  });
4441
+ // Optional navigation channel for the panel's click-to-open rows. The
4442
+ // manifest inject list above stays untouched: without the workspace
4443
+ // service this callback never runs, cabinetOpenSession stays null and
4444
+ // every click no-ops — the same degradation as the remote channel.
4445
+ ctx.inject(['uiWorkspace'], (scope) => {
4446
+ const workspace = scope.uiWorkspace;
4447
+ if (!workspace || typeof workspace.openSession !== 'function') return;
4448
+ scope.effect(() => {
4449
+ const opener = (target) => workspace.openSession(target);
4450
+ cabinetOpenSession = opener;
4451
+ return () => { if (cabinetOpenSession === opener) cabinetOpenSession = null; };
4452
+ }, 'cabinet-ui: open teammate session');
4453
+ });
4454
+ // Optional install channel for the memory-plugin card: its own guard, so
4455
+ // a host without the plugin manager leaves the model-catalog remote and
4456
+ // every other channel exactly as it was.
4457
+ ctx.inject(['remote', 'remote.pluginManager'], (scope) => {
4458
+ const remote = scope.remote;
4459
+ const manager = remote !== undefined && remote !== null ? remote.pluginManager : undefined;
4460
+ if (!manager || typeof manager.inspect !== 'function' || typeof manager.installBundle !== 'function') return;
4461
+ scope.effect(() => {
4462
+ cabinetPluginManager = manager;
4463
+ notifyMemoryPlugin();
4464
+ return () => { if (cabinetPluginManager === manager) { cabinetPluginManager = null; notifyMemoryPlugin(); } };
4465
+ }, 'cabinet-ui: memory plugin manager');
4466
+ });
4125
4467
  // Stage one: declare the page type. No patterns => a page type, opened by kind.
4126
4468
  ctx.effect(() => ctx.sidebarRightTabs.register({
4127
4469
  id: TAB_ID,