@wenbin_wb/dsh-bridge 1.2.0 → 1.2.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 (2) hide show
  1. package/lib/wechat/node.js +15 -4
  2. package/package.json +1 -1
@@ -451,8 +451,16 @@ export class WechatConversationNode {
451
451
  // agent 不在内存(DSH 重启后或切换到持久化会话)→ re-attach。
452
452
  // agents.create(sessionId) 对已持久化的 session 会自动采纳其历史,对不存在的则新建。
453
453
  try {
454
+ // 读取持久化会话的 cwd,避免 cwd 冲突
455
+ let sessionCwd = this.config.cwd || process.cwd()
456
+ try {
457
+ const headers = await this.ctx.sessionPersistence?.list?.()
458
+ const header = headers?.find?.((h) => h?.id === this.activeSessionId)
459
+ if (header?.cwd) sessionCwd = header.cwd
460
+ } catch { /* 读取失败则用 fallback */ }
461
+
454
462
  const meta = {
455
- cwd: this.config.cwd || process.cwd(),
463
+ cwd: sessionCwd,
456
464
  agentPreset: this.config.agentPreset || 'routing-suite',
457
465
  }
458
466
  const agentOptions = {}
@@ -811,9 +819,12 @@ function foldTitle(events) {
811
819
  }
812
820
 
813
821
  // 列出会话:使用 DSH 官方 API(ctx.sessions + sessionPersistence),与 web 端一致。
814
- // 返回 [{ id, createdAt, events?, seq?, cwd?, title? }],按时间倒序。
822
+ // 屏蔽已归档会话。返回 [{ id, createdAt, events?, seq?, cwd?, title? }],按时间倒序。
815
823
  async function listSessions(node) {
816
- const live = [...(node.ctx.sessions?.list() ?? [])]
824
+ // 归档会话 ID 集合
825
+ let archived = new Set()
826
+ try { archived = new Set(node.ctx.workspaceRegistry?.archivedSessionIds ?? []) } catch { /* ignore */ }
827
+ const live = [...(node.ctx.sessions?.list() ?? [])].filter((s) => !archived.has(s.id))
817
828
  const liveIds = new Set(live.map((s) => s.id))
818
829
  // 内存活跃会话(带完整 events/title)
819
830
  const liveMapped = live.map((s) => {
@@ -828,7 +839,7 @@ async function listSessions(node) {
828
839
  try {
829
840
  const headers = await node.ctx.sessionPersistence?.list?.()
830
841
  if (Array.isArray(headers)) {
831
- const coldHeaders = headers.filter((h) => h && h.id && !liveIds.has(h.id) && h.cwd !== undefined)
842
+ const coldHeaders = headers.filter((h) => h && h.id && !liveIds.has(h.id) && h.cwd !== undefined && !archived.has(h.id))
832
843
  // 并行加载每个冷会话的 events 以提取标题
833
844
  cold = await Promise.all(coldHeaders.map(async (h) => {
834
845
  let title
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenbin_wb/dsh-bridge",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "手机扫码即可在移动端/公网继续用 DeepSeek Harness,人不在电脑前也能接着干。一键局域网二维码、Cloudflare 公网隧道、自建隧道与微信 Bot(多工作区/会话持久化/媒体/审批),无需自己搭公网服务器。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",