dsh-plugin-memory 0.19.0 → 0.19.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
4
4
 
5
+ ## [0.19.1] - 2026-11-11
6
+
7
+ ### Fixed
8
+
9
+ - **开启 memory 后会话不可用(DSH 0.2.2-rc.2)**:`ctx.systemPrompt.context` 的两个 `text` 回调若抛错会让整个 prompt 构建失败、所有会话发不出消息。两个回调(boot / 最近动态)现在整体 try/catch,异常只记录日志并返回空串——最坏情况记忆不注入,会话照常可用。
10
+ - 会话 chip 兼容 rc.2 的 `conversation.input.left` 空 props:宿主不传 `sessionId` 时请求走 `/api/memory/session` 的活跃会话兜底(不再直接隐藏 chip)。
11
+
5
12
  ## [0.19.0] - 2026-11-11
6
13
 
7
14
  ### Changed
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "versions": [
28
28
  {
29
- "version": "0.18.4",
30
- "publishTimestamp": 1794277785,
29
+ "version": "0.19.0",
30
+ "publishTimestamp": 1794409756,
31
31
  "source": {
32
32
  "type": "npm"
33
33
  },
34
34
  "engines": {
35
- "dsh": "^0.2.1-rc.5"
35
+ "dsh": "^0.2.1-rc.5 || ^0.2.2-rc.2"
36
36
  }
37
37
  }
38
38
  ]
package/lib/client.js CHANGED
@@ -1092,9 +1092,14 @@ window.__ModuleLoader__.load({
1092
1092
  const [open, setOpen] = React.useState(false)
1093
1093
  const [error, setError] = React.useState(undefined)
1094
1094
 
1095
+ // Some hosts (e.g. DSH 0.2.2-rc.2) render this slot without a sessionId;
1096
+ // the host route then falls back to the active session.
1097
+ const hasSessionId = typeof sessionId === 'string' && sessionId.length > 0
1095
1098
  const read = () => {
1096
- if (typeof sessionId !== 'string' || sessionId.length === 0) return
1097
- fetch(`${SESSION_URL}?sessionId=${encodeURIComponent(sessionId)}`)
1099
+ const url = hasSessionId
1100
+ ? `${SESSION_URL}?sessionId=${encodeURIComponent(sessionId)}`
1101
+ : SESSION_URL
1102
+ fetch(url)
1098
1103
  .then(async (response) => (response.ok ? response.json() : undefined))
1099
1104
  .then((value) => {
1100
1105
  if (value === undefined) return
@@ -1105,7 +1110,6 @@ window.__ModuleLoader__.load({
1105
1110
  }
1106
1111
 
1107
1112
  React.useEffect(() => {
1108
- if (typeof sessionId !== 'string' || sessionId.length === 0) return undefined
1109
1113
  read()
1110
1114
  const timer = typeof setInterval === 'function' ? setInterval(read, 10000) : undefined
1111
1115
  return () => {
@@ -1121,7 +1125,6 @@ window.__ModuleLoader__.load({
1121
1125
  return () => document.removeEventListener('mousedown', close)
1122
1126
  }, [open])
1123
1127
 
1124
- if (typeof sessionId !== 'string' || sessionId.length === 0) return null
1125
1128
  const enabled = state === undefined ? true : state.ok !== false && state.effective !== false
1126
1129
  const workspaceMuted = state?.workspaceDisabled === true
1127
1130
 
@@ -1131,7 +1134,7 @@ window.__ModuleLoader__.load({
1131
1134
  fetch(SESSION_URL, {
1132
1135
  method: 'POST',
1133
1136
  headers: { 'content-type': 'application/json' },
1134
- body: JSON.stringify({ action, sessionId }),
1137
+ body: JSON.stringify(hasSessionId ? { action, sessionId } : { action }),
1135
1138
  })
1136
1139
  .then(async (response) => {
1137
1140
  const body = await response.json().catch(() => ({}))
package/lib/index.js CHANGED
@@ -412,38 +412,46 @@ export function apply(ctx, config = {}) {
412
412
  name: 'memory-boot',
413
413
  order: -200,
414
414
  text: (context) => {
415
- // Per-agent gate: no agent context (e.g. a global preview) injects
416
- // unconditionally; an agent injects only once it has spoken and is
417
- // the active session.
418
- const resolved = store.get()
419
- const agent = context?.agent
420
- // User intent first (the session switch), then the two polite gates.
421
- if (agent && !sessionEnabled(agent, resolved)) return ''
422
- if (agent && !tracker.shouldInject(agent.id, resolved)) return ''
423
- // Tone drift rides on the boot block (charged to its budget). Read
424
- // live from the store so the Settings select applies on the next
425
- // prompt build without a reload.
426
- const toneGuide = resolved.toneGuideEnabled
427
- ? buildToneGuide({ intensity: resolved.toneIntensity, language: 'zh' })
428
- : ''
429
- const options = {
430
- bootFiles,
431
- bootMaxChars,
432
- bootFileBudgets,
433
- toneGuide,
434
- // The volatile log tail is injected by `memory-recent` instead.
435
- includeRecentActivity: false,
436
- }
437
- if (agent && resolved.bootSnapshot === 'session') {
438
- const signature = snapshotSignature(resolved, memoryDir)
439
- const hit = bootSnapshots.get(agent.id)
440
- if (hit !== undefined && hit.signature === signature) return hit.text
441
- const text = renderBootBlock(memoryDir, options)
442
- bootSnapshots.set(agent.id, { text, signature })
443
- if (bootSnapshots.size > 64) bootSnapshots.delete(bootSnapshots.keys().next().value)
444
- return text
415
+ // A throwing runtime-context callback fails the whole prompt build and
416
+ // makes every session unusable. Swallow errors: worst case memory is
417
+ // not injected, the session keeps working.
418
+ try {
419
+ // Per-agent gate: no agent context (e.g. a global preview) injects
420
+ // unconditionally; an agent injects only once it has spoken and is
421
+ // the active session.
422
+ const resolved = store.get()
423
+ const agent = context?.agent
424
+ // User intent first (the session switch), then the two polite gates.
425
+ if (agent && !sessionEnabled(agent, resolved)) return ''
426
+ if (agent && !tracker.shouldInject(agent.id, resolved)) return ''
427
+ // Tone drift rides on the boot block (charged to its budget). Read
428
+ // live from the store so the Settings select applies on the next
429
+ // prompt build without a reload.
430
+ const toneGuide = resolved.toneGuideEnabled
431
+ ? buildToneGuide({ intensity: resolved.toneIntensity, language: 'zh' })
432
+ : ''
433
+ const options = {
434
+ bootFiles,
435
+ bootMaxChars,
436
+ bootFileBudgets,
437
+ toneGuide,
438
+ // The volatile log tail is injected by `memory-recent` instead.
439
+ includeRecentActivity: false,
440
+ }
441
+ if (agent && resolved.bootSnapshot === 'session') {
442
+ const signature = snapshotSignature(resolved, memoryDir)
443
+ const hit = bootSnapshots.get(agent.id)
444
+ if (hit !== undefined && hit.signature === signature) return hit.text
445
+ const text = renderBootBlock(memoryDir, options)
446
+ bootSnapshots.set(agent.id, { text, signature })
447
+ if (bootSnapshots.size > 64) bootSnapshots.delete(bootSnapshots.keys().next().value)
448
+ return text
449
+ }
450
+ return renderBootBlock(memoryDir, options)
451
+ } catch (error) {
452
+ ctx.logger?.warn?.(`memory: boot context failed: ${error instanceof Error ? error.message : String(error)}`)
453
+ return ''
445
454
  }
446
- return renderBootBlock(memoryDir, options)
447
455
  },
448
456
  })
449
457
  // The volatile tail (recent log entries) lives in its own segment with a
@@ -452,11 +460,16 @@ export function apply(ctx, config = {}) {
452
460
  name: 'memory-recent',
453
461
  order: 900,
454
462
  text: (context) => {
455
- const resolved = store.get()
456
- const agent = context?.agent
457
- if (agent && !sessionEnabled(agent, resolved)) return ''
458
- if (agent && !tracker.shouldInject(agent.id, resolved)) return ''
459
- return renderRecentActivity(memoryDir)
463
+ try {
464
+ const resolved = store.get()
465
+ const agent = context?.agent
466
+ if (agent && !sessionEnabled(agent, resolved)) return ''
467
+ if (agent && !tracker.shouldInject(agent.id, resolved)) return ''
468
+ return renderRecentActivity(memoryDir)
469
+ } catch (error) {
470
+ ctx.logger?.warn?.(`memory: recent context failed: ${error instanceof Error ? error.message : String(error)}`)
471
+ return ''
472
+ }
460
473
  },
461
474
  })
462
475
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-memory",
3
3
  "description": "Long-term memory plugin for DeepSeek Harness: persistent cross-session markdown memory with a soul/persona file, auto-injected at every session start, plus remember/recall/consolidate/forget workflows and portable migration tooling.",
4
- "version": "0.19.0",
4
+ "version": "0.19.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",