dsh-sixlayer-memory 2.3.2 → 2.4.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/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/lib/index.js +35 -4
- package/lib/memory/asr.js +3 -1
- package/lib/memory/lifecycle.js +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 变更记录 · dsh-sixlayer-memory(六层记忆底座)
|
|
2
2
|
|
|
3
|
+
## 2.4.0 — 2026-12-05
|
|
4
|
+
|
|
5
|
+
主题:**说完直接发出去,不看焦点、不碰剪贴板**。
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
|
|
9
|
+
- **语音结果直接投递进当前会话**:`agent/pre-step` 时记下活着的 agent,识别完把文字用
|
|
10
|
+
`agent.followup()` 当成一条用户消息送进去——不需要点输入框、不需要光标、不依赖剪贴板。
|
|
11
|
+
拿不到 agent 或投递失败才回退到"粘到输入框"。
|
|
12
|
+
- 配置 `asr.deliver`:`agent`(默认,直接发)/ `paste`(只粘输入框)
|
|
13
|
+
- 每次投递在审计里记 `op:'voice'` + `delivered: agent|paste|failed`
|
|
14
|
+
|
|
15
|
+
### 修复
|
|
16
|
+
|
|
17
|
+
- 2.3.2 的 SendKeys 粘贴在部分窗口仍不生效——现在这条路径只是兜底,不再是主路径
|
|
18
|
+
|
|
19
|
+
### 回归
|
|
20
|
+
|
|
21
|
+
- 全量 35 个套件全绿 · 工具 35 个
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
3
25
|
## 2.3.2 — 2026-12-05
|
|
4
26
|
|
|
5
27
|
修「识别出来了但没粘进输入框、也没提示音」——两处都是进程环境问题。
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
dsh plugin --profile desktop add dsh-sixlayer-memory
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
**当前版本**:2.
|
|
14
|
+
**当前版本**:2.4.0 · **35 个工具** · schema v9 · 零外部依赖 · 回归 35 个套件全绿
|
|
15
15
|
|
|
16
16
|
📦 [npm](https://www.npmjs.com/package/dsh-sixlayer-memory) · 🎬 [40 秒介绍视频](media/intro-40s.mp4) · 📝 [变更记录](CHANGELOG.md)
|
|
17
17
|
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
13
13
|
import MemoryStore from './memory/store.js'
|
|
14
14
|
import { buildRegistry } from './memory/tools.js'
|
|
15
15
|
import { Injector } from './memory/inject.js'
|
|
16
|
-
import { attachLifecycle, lifecycleSummary } from './memory/lifecycle.js'
|
|
16
|
+
import { attachLifecycle, lifecycleSummary, resolveMessageFactory } from './memory/lifecycle.js'
|
|
17
17
|
import { decorateRows, explainRecord } from './memory/explain.js'
|
|
18
18
|
import { readDetail } from './memory/detail.js'
|
|
19
19
|
import { createQqBridge } from './memory/qq.js'
|
|
@@ -203,6 +203,9 @@ export function apply(ctx, config = {}) {
|
|
|
203
203
|
})
|
|
204
204
|
let lastVoice = null
|
|
205
205
|
let lastHotkeyAt = 0
|
|
206
|
+
// pre-step 时记下活着的 agent:语音识别完直接把文字当消息投进去,不靠剪贴板
|
|
207
|
+
let lastAgent = null
|
|
208
|
+
let lastSessionId = ''
|
|
206
209
|
const toggleVoice = async () => {
|
|
207
210
|
// 正在录 → 停 + 转写 + 粘贴
|
|
208
211
|
if (voice.recording) {
|
|
@@ -236,9 +239,32 @@ export function apply(ctx, config = {}) {
|
|
|
236
239
|
diag('asr: 转写失败 ' + result.reason)
|
|
237
240
|
return lastVoice
|
|
238
241
|
}
|
|
239
|
-
|
|
242
|
+
// 优先直接把文字当一条用户消息送进当前会话(不看焦点、不用剪贴板);
|
|
243
|
+
// 拿不到 agent 或失败时才退回"粘到输入框"。
|
|
244
|
+
let delivered = 'none'
|
|
245
|
+
const factory = resolveMessageFactory()
|
|
246
|
+
if (asrConfig.deliver !== 'paste' && lastAgent && typeof lastAgent.followup === 'function' && factory) {
|
|
247
|
+
try {
|
|
248
|
+
lastAgent.followup(factory({ content: [{ type: 'text', text: result.text }], source: { kind: 'user' } }))
|
|
249
|
+
delivered = 'agent'
|
|
250
|
+
} catch (error) {
|
|
251
|
+
diag('asr: 直接投递失败(回退粘贴)' + (error?.message ?? error))
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (delivered === 'none') {
|
|
255
|
+
const pasted = await pasteText(result.text, { autoEnter: asrConfig.autoEnter })
|
|
256
|
+
delivered = pasted.ok ? 'paste' : 'failed'
|
|
257
|
+
}
|
|
240
258
|
try {
|
|
241
|
-
store?.recorder?.record?.({
|
|
259
|
+
store?.recorder?.record?.({
|
|
260
|
+
op: 'voice',
|
|
261
|
+
via,
|
|
262
|
+
delivered,
|
|
263
|
+
session: lastSessionId,
|
|
264
|
+
key_source: source,
|
|
265
|
+
chars: result.text.length,
|
|
266
|
+
ms: result.durationMs ?? stopped.ms,
|
|
267
|
+
})
|
|
242
268
|
} catch {
|
|
243
269
|
/* 审计失败不影响 */
|
|
244
270
|
}
|
|
@@ -248,8 +274,9 @@ export function apply(ctx, config = {}) {
|
|
|
248
274
|
stage: 'done',
|
|
249
275
|
text: result.text,
|
|
250
276
|
via,
|
|
277
|
+
delivered,
|
|
251
278
|
ms: result.durationMs ?? stopped.ms,
|
|
252
|
-
pasted:
|
|
279
|
+
pasted: delivered !== 'failed',
|
|
253
280
|
file: stopped.file,
|
|
254
281
|
}
|
|
255
282
|
return lastVoice
|
|
@@ -562,6 +589,10 @@ export function apply(ctx, config = {}) {
|
|
|
562
589
|
store,
|
|
563
590
|
config: config.lifecycle ?? {},
|
|
564
591
|
diag,
|
|
592
|
+
onAgent: (agent, sessionId) => {
|
|
593
|
+
if (agent) lastAgent = agent
|
|
594
|
+
if (sessionId) lastSessionId = sessionId
|
|
595
|
+
},
|
|
565
596
|
})
|
|
566
597
|
return () => {
|
|
567
598
|
try {
|
package/lib/memory/asr.js
CHANGED
|
@@ -256,6 +256,8 @@ export function resolveAsrConfig(config = {}, dataDir = '') {
|
|
|
256
256
|
localCommand: String(pick('localCommand', '')),
|
|
257
257
|
device: String(pick('device', '')),
|
|
258
258
|
autoEnter: Boolean(pick('autoEnter', false)),
|
|
259
|
+
// agent = 直接把文字当消息送进当前会话(不看焦点);paste = 粘到输入框
|
|
260
|
+
deliver: String(pick('deliver', 'agent')) === 'paste' ? 'paste' : 'agent',
|
|
259
261
|
apiKey: config?.apiKey ? String(config.apiKey) : '',
|
|
260
262
|
}
|
|
261
263
|
}
|
|
@@ -263,7 +265,7 @@ export function resolveAsrConfig(config = {}, dataDir = '') {
|
|
|
263
265
|
/** 写覆盖文件(工具改配置时用)。apiKey 不进文件。 */
|
|
264
266
|
export function saveAsrConfig(dataDir, patch = {}) {
|
|
265
267
|
const next = { ...readAsrOverrides(dataDir) }
|
|
266
|
-
for (const k of ['enabled', 'baseUrl', 'localCommand', 'device', 'autoEnter']) {
|
|
268
|
+
for (const k of ['enabled', 'baseUrl', 'localCommand', 'device', 'autoEnter', 'deliver']) {
|
|
267
269
|
if (patch[k] !== undefined) next[k] = patch[k]
|
|
268
270
|
}
|
|
269
271
|
const file = asrOverridesPath(dataDir)
|
package/lib/memory/lifecycle.js
CHANGED
|
@@ -237,7 +237,7 @@ function deepFreeze(value) {
|
|
|
237
237
|
* @param {any} ctx 宿主上下文
|
|
238
238
|
* @param {{store:any, config?:any, diag?:(m:string)=>void, createUserMessage?:Function}} options
|
|
239
239
|
*/
|
|
240
|
-
export function attachLifecycle(ctx, { store, config, diag = () => {}, createUserMessage } = {}) {
|
|
240
|
+
export function attachLifecycle(ctx, { store, config, diag = () => {}, createUserMessage, onAgent = null } = {}) {
|
|
241
241
|
const cfg = normalizeLifecycle(config)
|
|
242
242
|
if (!store) return () => {}
|
|
243
243
|
if (cfg.enabled === false) {
|
|
@@ -311,6 +311,13 @@ export function attachLifecycle(ctx, { store, config, diag = () => {}, createUse
|
|
|
311
311
|
if (!query) return decision
|
|
312
312
|
|
|
313
313
|
const sessionId = String(payload?.agent?.session?.id ?? '')
|
|
314
|
+
// 把当前活着的 agent 交出去:语音输入要能"直接把文字当一条消息发进去",
|
|
315
|
+
// 而不是靠模拟 Ctrl+V 去猜用户焦点在哪个窗口。
|
|
316
|
+
try {
|
|
317
|
+
onAgent?.(payload?.agent ?? null, sessionId)
|
|
318
|
+
} catch (error) {
|
|
319
|
+
diag('lifecycle: onAgent 回调出错 ' + (error?.message ?? error))
|
|
320
|
+
}
|
|
314
321
|
const hash = sha256(query)
|
|
315
322
|
const now = Date.now()
|
|
316
323
|
const cooldown = Number(cfg.recall.cooldownMs ?? 30_000)
|