@240xu/dsh-message-ops 0.11.1 → 0.11.3

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/src/index.js CHANGED
@@ -9,11 +9,12 @@
9
9
  import { zstdCompressSync } from "node:zlib";
10
10
  import { open as openFile, truncate as truncateFile, stat as statFile } from "node:fs/promises";
11
11
  import { isSessionId, sessionIdVariants, findSessionDirs, readSessionFileAsync, listMessages, computeShadowed, messageText, messageTextFull, turnBounds, markCommitted } from "./session-file.js";
12
- import { restoreNoticeText, planRevertFromEvents, planDeleteFromEvents, nextSeqFrom, buildMarkerEvent, buildRestoreNoticeEvent, buildReplayEvent, planNoticeWindow, noticeWindowPreamble, noticeWindowPostamble,
12
+ import { restoreNoticeText, planRevertFromEvents, planDeleteFromEvents, nextSeqFrom, buildMarkerEvent, buildRestoreNoticeEvent, buildReplayEvent, planNoticeWindow, noticeWindowPreamble, noticeWindowPostamble, sessionLogOf, alignLiveTurnCursor,
13
13
  OpsError, planRevert, planDelete, planRestore, applyRestore, applySurfaceReplace,
14
- restoreProgress, pendingRestoreTurns,
14
+ restoreProgress, pendingRestoreTurns, buildRestoreIndex, restoreProgressFromIndex, pendingRestoreTurnsFromIndex,
15
15
  isTrustedApiRequest, isJsonContentType, webAuthGate,
16
16
  } from "./ops-core.js";
17
+ import { deleteSessionToTrash, listTrash, restoreTrash, purgeTrash, resolveSessionTitle } from "./session-trash.js";
17
18
 
18
19
  export const name = "dsh-message-ops";
19
20
  // 保持 inject 为空:tools 是可选增强而非硬依赖(cordis 的 inject 是
@@ -50,8 +51,8 @@ async function fence(targetCtx, req, res) {
50
51
  }
51
52
  // 0.10.8:宿主同条件 GET 被读全量(审计缺口)。宿主 /api admit = 三层围栏
52
53
  // 之外还要 BrowserAuth cookie(无 cookie → 401);前端同源 fetch 自动带
53
- // cookie,取数不受影响。secret 读不到 = 降级回旧围栏(webAuthGate 内部
54
- // 告警一次),老宿主/测桩不破坏。
54
+ // cookie,取数不受影响。无 credentials 服务 = 老宿主旧围栏;有服务但
55
+ // 记录不可读 = 401 fail-closed(webAuthGate 内部告警一次)。
55
56
  if (!(await webAuthGate(targetCtx, req))) {
56
57
  sendJson(res, 401, { ok: false, error: "unauthorized (browser auth cookie required; reopen the URL printed by dsh web)" });
57
58
  return false;
@@ -354,6 +355,7 @@ async function buildDerived(logPath) {
354
355
  // seqText 索引,也不扫一遍 events(seqText 为 null 时下面两处都短路:
355
356
  // 本循环直接跳过,marker 循环体也一次都不会执行)。
356
357
  const seqText = messages.some((m) => m.marker === true) ? new Map() : null;
358
+ const restoreIndex = seqText ? buildRestoreIndex(events) : null;
357
359
  for (const e of seqText ? events : []) {
358
360
  if (!e || typeof e.seq !== "number") continue;
359
361
  if (e.type !== "user/message" && e.type !== "assistant/message") continue;
@@ -378,10 +380,10 @@ async function buildDerived(logPath) {
378
380
  // —— 这正是 opencode 的 `messages.slice(0, boundaryIndex)`(边界自己也不显示)。
379
381
  for (const m of messages) {
380
382
  if (!m || m.marker !== true) continue;
381
- const prog = restoreProgress(events, m.seq);
383
+ const prog = restoreProgressFromIndex(restoreIndex, m.seq);
382
384
  if (!prog) { m.restoreComplete = false; m.pendingTurns = []; continue; }
383
385
  m.restoreComplete = prog.complete;
384
- m.pendingTurns = pendingRestoreTurns(events, m.seq, prog).map((t) => ({
386
+ m.pendingTurns = pendingRestoreTurnsFromIndex(restoreIndex, m.seq, prog).map((t) => ({
385
387
  upTo: t.seqs[t.seqs.length - 1],
386
388
  count: t.seqs.length,
387
389
  // 0.10.2:轮起点常落在注入行上(system-reminder / 后台任务 / 子代理通知),
@@ -455,8 +457,9 @@ async function loadDerived(logPath) {
455
457
  return entry.promise;
456
458
  }
457
459
 
458
- async function opsList(targetCtx, sessionId) {
460
+ async function opsList(targetCtx, sessionId, opts = {}) {
459
461
  if (!isSessionId(sessionId)) throw new OpsError("invalid sessionId", 400);
462
+ const compact = opts && opts.compact === true;
460
463
  const { logPath } = pickSessionDir(sessionId);
461
464
  // 文件派生段(读日志 → 消息 → 遮蔽集 → marker 进度 → turn 边界)走缓存:
462
465
  // key = logPath、失效看读前 stat 的 mtimeMs+size,见 loadDerived 注释。
@@ -470,6 +473,8 @@ async function opsList(targetCtx, sessionId) {
470
473
  applyLiveCommitted(messages, live);
471
474
  const visibleNodes = live && live.surface && Array.isArray(live.surface.nodes) ? new Set(live.surface.nodes) : null;
472
475
  let visibleCount = 0;
476
+ let shadowedCount = 0;
477
+ let markerCount = 0;
473
478
  for (const m of messages) {
474
479
  m.visible = visibleNodes ? visibleNodes.has(m.seq) : !shadowed.has(m.seq);
475
480
  // 0.9.6:**shadowed 与 visible 是两套语义,不能混用。**
@@ -484,22 +489,128 @@ async function opsList(targetCtx, sessionId) {
484
489
  // transcript 藏行必须用它;visible 只留给「可回滚目标」(lastRevertable)。
485
490
  m.shadowed = shadowed.has(m.seq);
486
491
  if (m.visible) visibleCount++;
492
+ if (m.shadowed) shadowedCount++;
493
+ if (m.marker === true) markerCount++;
487
494
  }
488
495
 
496
+ const visibleMessages = compact
497
+ ? messages.map((m) => ({
498
+ seq: m.seq,
499
+ role: m.role,
500
+ snippet: m.snippet,
501
+ time: m.time,
502
+ visible: m.visible,
503
+ shadowed: m.shadowed,
504
+ }))
505
+ : messages;
506
+
489
507
  return {
490
508
  ok: true,
491
- session: { id: header.id, createdAt: header.createdAt, parentSession: header.parentSession ?? null },
509
+ session: {
510
+ id: header.id,
511
+ createdAt: header.createdAt,
512
+ parentSession: header.parentSession ?? null,
513
+ confirmTitle: resolveSessionTitle(targetCtx, sessionId) || header.id,
514
+ },
492
515
  running: isRunning(targetCtx, sessionId),
493
516
  runningSource: __runningSource,
494
517
  total: messages.length,
495
518
  visibleCount,
519
+ shadowedCount,
520
+ markerCount,
496
521
  turnEndSeq,
497
- messages,
522
+ messages: visibleMessages,
498
523
  };
499
524
  }
500
525
 
501
- /** 测试钩子(非公开 API):直接驱动 list 与文件派生缓存。 */
502
- export const _internals = { opsList, loadDerived, derivedCache };
526
+ // ---------------------------------------------------------------------------
527
+ // Per-session search (full text, beyond the 160-char snippet)
528
+ // ---------------------------------------------------------------------------
529
+ const SEARCH_CACHE_MAX = 8;
530
+ const searchCache = new Map(); // logPath -> { mtimeMs, size, promise }
531
+
532
+ /** Build the searchable corpus once per log revision (full text, lowercased lazily). */
533
+ async function buildSearchCorpus(logPath) {
534
+ const { events } = await readSessionFileAsync(logPath);
535
+ const messages = listMessages(events);
536
+ const shadowed = computeShadowed(events);
537
+ const bySeq = new Map();
538
+ for (const e of events) if (e && typeof e.seq === "number") bySeq.set(e.seq, e);
539
+ const corpus = [];
540
+ for (const m of messages) {
541
+ const ev = bySeq.get(m.seq);
542
+ const text = ev ? messageTextFull(ev) : "";
543
+ corpus.push({
544
+ seq: m.seq,
545
+ type: m.type,
546
+ role: m.role,
547
+ marker: m.marker === true,
548
+ shadowed: shadowed.has(m.seq),
549
+ text: text || m.snippet || "",
550
+ });
551
+ }
552
+ return corpus;
553
+ }
554
+
555
+ async function loadSearchCorpus(logPath) {
556
+ const st = await statFile(logPath);
557
+ const hit = searchCache.get(logPath);
558
+ if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size) {
559
+ searchCache.delete(logPath);
560
+ searchCache.set(logPath, hit);
561
+ return hit.promise;
562
+ }
563
+ const entry = { mtimeMs: st.mtimeMs, size: st.size, promise: buildSearchCorpus(logPath) };
564
+ searchCache.delete(logPath);
565
+ searchCache.set(logPath, entry);
566
+ while (searchCache.size > SEARCH_CACHE_MAX) searchCache.delete(searchCache.keys().next().value);
567
+ entry.promise.catch(() => { if (searchCache.get(logPath) === entry) searchCache.delete(logPath); });
568
+ return entry.promise;
569
+ }
570
+
571
+ function searchSnippet(text, query, radius = 45) {
572
+ const lower = text.toLowerCase();
573
+ const at = lower.indexOf(query);
574
+ const start = at < 0 ? 0 : Math.max(0, at - radius);
575
+ const end = at < 0 ? Math.min(text.length, 160) : Math.min(text.length, at + query.length + radius);
576
+ const raw = text.slice(start, end).replace(/\s+/g, " ").trim();
577
+ return (start > 0 ? "…" : "") + raw.slice(0, 158) + (end < text.length ? "…" : "");
578
+ }
579
+
580
+ async function opsSearch(targetCtx, sessionId, query, opts = {}) {
581
+ if (!isSessionId(sessionId)) throw new OpsError("invalid sessionId", 400);
582
+ const q = typeof query === "string" ? query.trim() : "";
583
+ if (q.length === 0) throw new OpsError("query is required", 400);
584
+ if (q.length > 500) throw new OpsError("query too long (max 500)", 400);
585
+ const role = opts && typeof opts.role === "string" && opts.role ? opts.role : null;
586
+ if (role && !["user", "assistant", "system", "tool"].includes(role)) {
587
+ throw new OpsError("invalid role", 400);
588
+ }
589
+ const limit = Number.isSafeInteger(opts && opts.limit) ? Math.max(1, Math.min(100, opts.limit)) : 50;
590
+ const { logPath } = pickSessionDir(sessionId);
591
+ const corpus = await loadSearchCorpus(logPath);
592
+ const needle = q.toLowerCase();
593
+ const results = [];
594
+ let total = 0;
595
+ for (const row of corpus) {
596
+ if (role && row.role !== role) continue;
597
+ if (!row.text.toLowerCase().includes(needle)) continue;
598
+ total++;
599
+ if (results.length >= limit) continue;
600
+ results.push({
601
+ seq: row.seq,
602
+ type: row.type,
603
+ role: row.role,
604
+ marker: row.marker,
605
+ shadowed: row.shadowed,
606
+ snippet: searchSnippet(row.text, needle),
607
+ });
608
+ }
609
+ return { ok: true, query: q, role, limit, total, truncated: total > results.length, results };
610
+ }
611
+
612
+ /** 测试钩子(非公开 API):直接驱动 list / search 与文件派生缓存。 */
613
+ export const _internals = { opsList, opsSearch, loadDerived, loadSearchCorpus, derivedCache, searchCache };
503
614
 
504
615
  async function opsCommit(targetCtx, mode, sessionId, seq) {
505
616
  if (!isSessionId(sessionId)) throw new OpsError("invalid sessionId", 400);
@@ -511,8 +622,7 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
511
622
  // 承载 notice,而不是拒绝。引擎 append-only 插不进已有 step,但合成一整个 turn 合法
512
623
  //��已对官方校验闸实测:append 型 / 单节点 replace / 多节点 replace 全 PASS,遮蔽受保护头正确拒绝)。
513
624
  // 带 reason:"message-ops",UI 与审计可识别,不与真实模型轮次混淆。
514
- const win = planNoticeWindow(events);
515
- const turnStep = { turn: win.turn, step: win.step };
625
+ let win = planNoticeWindow(events);
516
626
  const notice = mode === "delete"
517
627
  ? `[消息删除] 已遮蔽 seq ${seq}`
518
628
  : null; // revert 文案含 shadowed 数量,规划后拼
@@ -520,6 +630,9 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
520
630
  if (acq !== null && acq.session !== undefined) {
521
631
  try {
522
632
  const session = acq.session;
633
+ const liveEvents = sessionLogOf(session);
634
+ if (liveEvents) win = planNoticeWindow(liveEvents);
635
+ const turnStep = { turn: win.turn, step: win.step };
523
636
  // 0.5.4(P0):v4 准入要求 system/message 带正 turn/step——缺字段时持久层
524
637
  // encodeEventBatch 的 SessionFormatError 未捕获会**打死整个 dsh 进程**。
525
638
  const plan = mode === "delete" ? planDelete(session.surface, seq) : planRevert(session.surface, seq);
@@ -534,11 +647,27 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
534
647
  // turn(0.8.2 注释锁定的「后半操作被 409 锁拒」形态),随后原样抛出,
535
648
  // 由路由层按既有 OpsError 映射。append-only 引擎无「删除已落事件」能力,
536
649
  // 闭合孤儿窗口是最小且可被动校验的整理。
650
+ // 0.11.3 P0:postamble 只能写一次。
651
+ // 旧实现把 `for (const post of postamble) session.append(...)` 同时放在 try
652
+ // 成功路径和 catch 里;一旦**成功路径的 postamble 自身**抛错(引擎已接受
653
+ // step/end,第二个 turn/end 被拒 / flush 失败),catch 会再写一遍 →
654
+ // 日志落成 `step/end, turn/end, step/end, turn/end`。宿主读盘直接判
655
+ // `step/end does not match an open turn and step`,整份会话变 corrupt
656
+ // (实测 session-5b49db5b seq 806-809)。用 closed 标志保证闭环只发生一次。
657
+ let closed = false
658
+ const closeWindow = () => {
659
+ if (closed) return
660
+ closed = true
661
+ for (const post of noticeWindowPostamble(win)) {
662
+ try { session.append(post.kind, post.data) } catch { /* 引擎拒:维持原错误/继续 */ }
663
+ }
664
+ }
537
665
  try {
538
666
  for (const pre of noticeWindowPreamble(win)) session.append(pre.kind, pre.data);
539
667
  const event = applySurfaceReplace(session, plan.startSeq, plan.endSeq, plan.shadowedSeqs, text, turnStep);
540
- // 必须闭合:否则引擎内存里 turn 16 永远开着 → isRunning 恒真 → 后续操作全被 409
541
- for (const post of noticeWindowPostamble(win)) session.append(post.kind, post.data);
668
+ // 必须闭合:否则引擎内存里 turn 永远开着 → isRunning 恒真 → 后续操作全被 409
669
+ closeWindow()
670
+ if (win.synthetic) alignLiveTurnCursor(targetCtx, session, win.turn);
542
671
  flushSessions(targetCtx, session);
543
672
  return {
544
673
  ok: true, mode, seq,
@@ -547,10 +676,8 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
547
676
  eventSeq: event && event.seq != null ? event.seq : null,
548
677
  };
549
678
  } catch (err) {
550
- // 孤儿整理失败不再包一层也不会更糟(append 已失败态);原错误照抛。
551
- for (const post of noticeWindowPostamble(win)) {
552
- try { session.append(post.kind, post.data); } catch { /* postamble 被引擎拒:维持原错误上抛 */ }
553
- }
679
+ // 只补闭合**尚未发生**的窗口;已闭合过就绝不再写第二遍。
680
+ closeWindow()
554
681
  throw err;
555
682
  }
556
683
  } finally {
@@ -568,7 +695,7 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
568
695
  type: e.kind, seq: cursor++, time: baseTime + i, data: e.data,
569
696
  }));
570
697
  const marker = buildMarkerEvent({
571
- seq: cursor++, time: baseTime + batch.length, turnStep, text, version: header?.version ?? 4,
698
+ seq: cursor++, time: baseTime + batch.length, turnStep: { turn: win.turn, step: win.step }, text, version: header?.version ?? 4,
572
699
  startSeq: plan.startSeq, endSeq: plan.endSeq, shadowedSeqs: plan.shadowedSeqs,
573
700
  });
574
701
  batch.push(marker);
@@ -594,27 +721,34 @@ async function opsRestore(targetCtx, sessionId, restoreSeq, upToSeq, discard) {
594
721
  // 0.8.0(B1 修复):步进恢复必须排除先前轮次已重放的源 seq,
595
722
  // 否则每轮从区间头重放 → 消息副本成倍出现。
596
723
  // 合成 turn 承载 notice 的完整理由见 opsCommit() 处(0.8.2,实测 340/364 空闲会话)。
597
- const win = planNoticeWindow(events);
598
- const progress = restoreProgress(events, restoreSeq);
599
- const plan = planRestore(events, restoreSeq, upToSeq, progress ? progress.restoredSeqs : null);
600
- plan.turnStep = { turn: win.turn, step: win.step };
601
- plan.window = win;
602
- if (discard) plan.discard = true;
603
- if (plan.replayable.length === 0 && progress && !progress.complete && progress.pendingSeqs.length > 0) {
604
- // 请求的 upTo 之前已全部重放过 → 只补一条进度 notice(不重复重放)
605
- plan.upToSeq = upToSeq != null ? Math.min(upToSeq, plan.endSeq) : plan.endSeq;
606
- }
724
+ const buildPlan = (sourceEvents) => {
725
+ const window = planNoticeWindow(sourceEvents);
726
+ const progress = restoreProgress(sourceEvents, restoreSeq);
727
+ const restorePlan = planRestore(sourceEvents, restoreSeq, upToSeq, progress ? progress.restoredSeqs : null);
728
+ restorePlan.turnStep = { turn: window.turn, step: window.step };
729
+ restorePlan.window = window;
730
+ if (discard) restorePlan.discard = true;
731
+ if (restorePlan.replayable.length === 0 && progress && !progress.complete && progress.pendingSeqs.length > 0) {
732
+ // 请求的 upTo 之前已全部重放过 → 只补一条进度 notice(不重复重放)
733
+ restorePlan.upToSeq = upToSeq != null ? Math.min(upToSeq, restorePlan.endSeq) : restorePlan.endSeq;
734
+ }
735
+ return { win: window, plan: restorePlan };
736
+ };
737
+ let { win, plan } = buildPlan(events);
607
738
  const acq = await acquireSession(targetCtx, sessionId);
608
739
  if (acq !== null && acq.session !== undefined) {
609
740
  // 0.10.8 孤儿护栏(与 opsCommit 同型):planRestore/进度校验本就在 preamble
610
741
  // 之前完成;applyRestore 里的引擎 append 若抛(如 replay 坐标错开),
611
742
  // preamble 已落——闭合合成 turn 再原样抛出,不留常开孤儿窗口。
612
743
  try {
744
+ const liveEvents = sessionLogOf(acq.session);
745
+ if (liveEvents) ({ win, plan } = buildPlan(liveEvents));
613
746
  for (const pre of noticeWindowPreamble(win)) acq.session.append(pre.kind, pre.data);
614
747
  const result = applyRestore(acq.session, plan, {
615
748
  flush: () => { flushSessions(targetCtx, acq.session); },
616
749
  });
617
750
  for (const post of noticeWindowPostamble(win)) acq.session.append(post.kind, post.data);
751
+ if (win.synthetic) alignLiveTurnCursor(targetCtx, acq.session, win.turn);
618
752
  return { ok: true, ...result, discarded: plan.discard === true, upToSeq: plan.upToSeq, restoredSourceSeqs: plan.replayable.map((i) => i.seq), range: { startSeq: plan.startSeq, endSeq: plan.endSeq } };
619
753
  } catch (err) {
620
754
  for (const post of noticeWindowPostamble(win)) {
@@ -797,13 +931,40 @@ export function apply(ctx) {
797
931
  if (!(await fence(targetCtx, req, res))) return;
798
932
  try {
799
933
  const url = new URL(req.url, "http://localhost");
800
- return sendJson(res, 200, await opsList(targetCtx, url.searchParams.get("sessionId") || ""));
934
+ return sendJson(res, 200, await opsList(targetCtx, url.searchParams.get("sessionId") || "", {
935
+ compact: url.searchParams.get("view") === "compact",
936
+ }));
801
937
  } catch (err) {
802
938
  return sendJson(res, err instanceof OpsError ? err.status : 500, { ok: false, error: String(err && err.message ? err.message : err) });
803
939
  }
804
940
  },
805
941
  }), "dsh-message-ops: messages route");
806
942
 
943
+ // --- GET /api/message-ops/search:会话内全文搜索(服务端,匹配 snippet 之外) --
944
+ targetCtx.effect(() => host.register({
945
+ kind: "exact",
946
+ path: "/api/message-ops/search",
947
+ handler: async (req, res) => {
948
+ if (req.method !== "GET") return sendJson(res, 405, { ok: false, error: "method not allowed" });
949
+ if (!(await fence(targetCtx, req, res))) return;
950
+ try {
951
+ const url = new URL(req.url, "http://localhost");
952
+ const limitRaw = Number.parseInt(url.searchParams.get("limit") || "", 10);
953
+ return sendJson(res, 200, await opsSearch(
954
+ targetCtx,
955
+ url.searchParams.get("sessionId") || "",
956
+ url.searchParams.get("q") || "",
957
+ {
958
+ role: url.searchParams.get("role") || null,
959
+ limit: Number.isSafeInteger(limitRaw) ? limitRaw : undefined,
960
+ },
961
+ ));
962
+ } catch (err) {
963
+ return sendJson(res, err instanceof OpsError ? err.status : 500, { ok: false, error: String(err && err.message ? err.message : err) });
964
+ }
965
+ },
966
+ }), "dsh-message-ops: search route");
967
+
807
968
  // --- GET /api/message-ops/text:单条消息全文(0.5.2 引用按钮按需取) ----------
808
969
  // assistant 消息的 fullText 不在 messages 列表里(载荷控制),quote 点击时单取。
809
970
  targetCtx.effect(() => host.register({
@@ -877,6 +1038,45 @@ export function apply(ctx) {
877
1038
  },
878
1039
  }), "dsh-message-ops: restore route");
879
1040
 
1041
+ // --- Session trash:删除整条会话(可逆),列表 / 恢复 / 永久清理 ----------
1042
+ targetCtx.effect(() => host.register({
1043
+ kind: "exact",
1044
+ path: "/api/message-ops/session/trash",
1045
+ handler: async (req, res) => {
1046
+ if (req.method !== "GET") return sendJson(res, 405, { ok: false, error: "method not allowed" });
1047
+ if (!(await fence(targetCtx, req, res))) return;
1048
+ try {
1049
+ return sendJson(res, 200, { ok: true, entries: await listTrash(targetCtx, { purgeExpired: true }) });
1050
+ } catch (err) {
1051
+ return sendJson(res, err instanceof OpsError ? err.status : 500, { ok: false, error: String(err && err.message ? err.message : err) });
1052
+ }
1053
+ },
1054
+ }), "dsh-message-ops: session trash route");
1055
+
1056
+ const sessionAction = (path, action) => targetCtx.effect(() => host.register({
1057
+ kind: "exact",
1058
+ path,
1059
+ handler: async (req, res) => {
1060
+ if (req.method !== "POST") return sendJson(res, 405, { ok: false, error: "method not allowed" });
1061
+ if (!(await writeFence(targetCtx, req, res))) return;
1062
+ const body = await readFencedBody(req, res);
1063
+ if (body === undefined) return;
1064
+ if (!body || typeof body !== "object") return sendJson(res, 400, { ok: false, error: "invalid json" });
1065
+ try {
1066
+ return sendJson(res, 200, await action(targetCtx, body));
1067
+ } catch (err) {
1068
+ return sendJson(res, err instanceof OpsError ? err.status : 500, { ok: false, error: String(err && err.message ? err.message : err) });
1069
+ }
1070
+ },
1071
+ }), "dsh-message-ops: " + path);
1072
+
1073
+ sessionAction("/api/message-ops/session/delete", (c, b) =>
1074
+ deleteSessionToTrash(c, b.sessionId, b.confirmTitle));
1075
+ sessionAction("/api/message-ops/session/restore", (c, b) =>
1076
+ restoreTrash(c, b.trashId));
1077
+ sessionAction("/api/message-ops/session/purge", (c, b) =>
1078
+ purgeTrash(c, b.trashId));
1079
+
880
1080
  }
881
1081
 
882
1082
  const ws = ctx.get("webServer");