dsh-sixlayer-memory 2.3.1 → 2.3.2
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 +14 -0
- package/README.md +1 -1
- package/lib/memory/asr.js +62 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# 变更记录 · dsh-sixlayer-memory(六层记忆底座)
|
|
2
2
|
|
|
3
|
+
## 2.3.2 — 2026-12-05
|
|
4
|
+
|
|
5
|
+
修「识别出来了但没粘进输入框、也没提示音」——两处都是进程环境问题。
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **粘贴**:`keybd_event` 从独立进程发 Ctrl+V,在 Electron 窗口里收不到(用户实测要手动按)。
|
|
10
|
+
改用 `System.Windows.Forms.SendKeys::SendWait('^v')`(走"当前活动窗口"的正路),
|
|
11
|
+
失败时再回退到 `keybd_event` 老路,两条都失败才报错。
|
|
12
|
+
- **提示音**:`[Console]::Beep` 在隐藏窗口的 PowerShell 里没有控制台,调用直接哑掉。
|
|
13
|
+
改用 `System.Media.SoundPlayer` 播系统自带 wav(开始 `Windows Notify.wav`、结束 `Windows Notify Calendar.wav`)。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
3
17
|
## 2.3.1 — 2026-12-05
|
|
4
18
|
|
|
5
19
|
修两个让「按一下说话」实际不可用的问题(2.3.0 当天发现)。
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
dsh plugin --profile desktop add dsh-sixlayer-memory
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
**当前版本**:2.3.
|
|
14
|
+
**当前版本**:2.3.2 · **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/memory/asr.js
CHANGED
|
@@ -315,14 +315,19 @@ export function saveAsrConfig(dataDir, patch = {}) {
|
|
|
315
315
|
|
|
316
316
|
/**
|
|
317
317
|
* 提示音:录音开始/结束各响一声。没有界面可看时,声音就是"我在听"的反馈。
|
|
318
|
-
*
|
|
318
|
+
*
|
|
319
|
+
* 不用 `[Console]::Beep`:隐藏窗口的 PowerShell 没有控制台,调用直接哑掉(用户实测没声音)。
|
|
320
|
+
* 改用 SoundPlayer 放系统自带的 wav,任何进程都能出声。
|
|
319
321
|
*/
|
|
320
322
|
export function beep({ freq = 880, ms = 80 } = {}) {
|
|
321
323
|
try {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
// 高音/低音用两个系统 wav 代替,避免依赖 freq(系统 wav 不支持调频,但够区分开始和结束)
|
|
325
|
+
const file = freq >= 700 ? 'Windows Notify.wav' : 'Windows Notify Calendar.wav'
|
|
326
|
+
const child = spawn(
|
|
327
|
+
'powershell.exe',
|
|
328
|
+
['-NoProfile', '-Command', `$p = New-Object System.Media.SoundPlayer "$env:SystemRoot\\Media\\${file}"; $p.PlaySync()`],
|
|
329
|
+
{ windowsHide: true, stdio: 'ignore' },
|
|
330
|
+
)
|
|
326
331
|
child.on('error', () => {})
|
|
327
332
|
} catch {
|
|
328
333
|
/* 忽略 */
|
|
@@ -330,28 +335,59 @@ export function beep({ freq = 880, ms = 80 } = {}) {
|
|
|
330
335
|
}
|
|
331
336
|
|
|
332
337
|
/**
|
|
333
|
-
* 把文本送进当前焦点输入框:写剪贴板 +
|
|
338
|
+
* 把文本送进当前焦点输入框:写剪贴板 + SendKeys 发 Ctrl+V。
|
|
339
|
+
*
|
|
340
|
+
* 为什么改成 SendKeys:`keybd_event` 从独立进程发键时,在部分应用(Electron 窗口)
|
|
341
|
+
* 里收不到,用户实测要手动按 Ctrl+V 才能粘上。SendKeys 走的是"当前活动窗口"这条正路。
|
|
342
|
+
*
|
|
334
343
|
* 故意**不自动回车**——粘错了还能改,自动发送就救不回来了。
|
|
335
344
|
*/
|
|
336
345
|
export function pasteText(text, { autoEnter = false } = {}) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
346
|
+
const one = String(text).replace(/\r?\n/g, ' ').replace(/'/g, "''")
|
|
347
|
+
|
|
348
|
+
const runSendKeys = () =>
|
|
349
|
+
new Promise((resolve) => {
|
|
350
|
+
const script = [
|
|
351
|
+
'Add-Type -AssemblyName System.Windows.Forms',
|
|
352
|
+
`Set-Clipboard -Value '${one}'`,
|
|
353
|
+
'Start-Sleep -Milliseconds 60',
|
|
354
|
+
"[System.Windows.Forms.SendKeys]::SendWait('^v')",
|
|
355
|
+
autoEnter ? "Start-Sleep -Milliseconds 120; [System.Windows.Forms.SendKeys]::SendWait('{ENTER}')" : "Write-Output 'pasted'",
|
|
356
|
+
].join('\n')
|
|
357
|
+
const child = spawn('powershell.exe', ['-NoProfile', '-STA', '-Command', script], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
358
|
+
let err = ''
|
|
359
|
+
child.stderr.on('data', (c) => {
|
|
360
|
+
err += c.toString('utf8')
|
|
361
|
+
})
|
|
362
|
+
child.stdout.on('data', () => {})
|
|
363
|
+
child.on('error', (e) => resolve({ ok: false, reason: e.message }))
|
|
364
|
+
child.on('exit', (code) =>
|
|
365
|
+
resolve({ ok: code === 0, reason: code === 0 ? '' : `SendKeys 退出 ${code}${err ? ':' + err.trim().slice(0, 120) : ''}` }),
|
|
366
|
+
)
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
// 老路:keybd_event。SendKeys 在某些环境被拦时还能兜住。
|
|
370
|
+
const runKeybd = () =>
|
|
371
|
+
new Promise((resolve) => {
|
|
372
|
+
const script = [
|
|
373
|
+
'Add-Type -AssemblyName System.Windows.Forms',
|
|
374
|
+
`Set-Clipboard -Value '${one}'`,
|
|
375
|
+
'Add-Type @"',
|
|
376
|
+
'using System;using System.Runtime.InteropServices;',
|
|
377
|
+
'public class PK { [DllImport("user32.dll")] public static extern void keybd_event(byte vk, byte scan, uint flags, UIntPtr extra); }',
|
|
378
|
+
'"@',
|
|
379
|
+
'Start-Sleep -Milliseconds 40',
|
|
380
|
+
'[PK]::keybd_event(0x11,0,0,[UIntPtr]::Zero)',
|
|
381
|
+
'[PK]::keybd_event(0x56,0,0,[UIntPtr]::Zero)',
|
|
382
|
+
'Start-Sleep -Milliseconds 40',
|
|
383
|
+
'[PK]::keybd_event(0x56,0,2,[UIntPtr]::Zero)',
|
|
384
|
+
'[PK]::keybd_event(0x11,0,2,[UIntPtr]::Zero)',
|
|
385
|
+
autoEnter ? 'Start-Sleep -Milliseconds 100; [PK]::keybd_event(0x0D,0,0,[UIntPtr]::Zero); [PK]::keybd_event(0x0D,0,2,[UIntPtr]::Zero)' : "Write-Output 'pasted'",
|
|
386
|
+
].join('\n')
|
|
387
|
+
const child = spawn('powershell.exe', ['-NoProfile', '-Command', script], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
388
|
+
child.on('error', (e) => resolve({ ok: false, reason: e.message }))
|
|
389
|
+
child.on('exit', (code) => resolve({ ok: code === 0, reason: code === 0 ? '' : `keybd 退出 ${code}` }))
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
return runSendKeys().then((r) => (r.ok ? r : runKeybd().then((r2) => (r2.ok ? { ok: true, via: 'keybd' } : { ok: false, reason: `${r.reason} / ${r2.reason}` }))))
|
|
357
393
|
}
|