dsh-her 0.0.1 → 0.1.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +113 -0
  3. package/cordis.patch.yml +5 -0
  4. package/examples/workshop/README.md +20 -0
  5. package/lib/client.js +1602 -0
  6. package/lib/core/character.js +50 -0
  7. package/lib/core/cues.js +62 -0
  8. package/lib/core/echo.js +27 -0
  9. package/lib/core/index.js +10 -0
  10. package/lib/core/paths.js +14 -0
  11. package/lib/core/prompt.js +63 -0
  12. package/lib/core/sentences.js +115 -0
  13. package/lib/core/speakable.js +26 -0
  14. package/lib/core/voices.js +43 -0
  15. package/lib/core/wav.js +71 -0
  16. package/lib/core/workshop.js +330 -0
  17. package/lib/dsh/api.js +156 -0
  18. package/lib/dsh/body-install.js +137 -0
  19. package/lib/dsh/body-launcher.js +48 -0
  20. package/lib/dsh/config.js +27 -0
  21. package/lib/dsh/her-session.js +282 -0
  22. package/lib/dsh/import-status.js +6 -0
  23. package/lib/dsh/plugin.js +1010 -0
  24. package/lib/dsh/workshop.js +222 -0
  25. package/lib/index.js +11 -0
  26. package/lib/memory/digest.js +119 -0
  27. package/lib/memory/search.js +52 -0
  28. package/lib/memory/store.js +267 -0
  29. package/lib/protocol/index.js +39 -0
  30. package/lib/server/brain-server.js +219 -0
  31. package/lib/types/core/character.d.ts +32 -0
  32. package/lib/types/core/cues.d.ts +20 -0
  33. package/lib/types/core/echo.d.ts +10 -0
  34. package/lib/types/core/index.d.ts +10 -0
  35. package/lib/types/core/paths.d.ts +11 -0
  36. package/lib/types/core/prompt.d.ts +39 -0
  37. package/lib/types/core/sentences.d.ts +40 -0
  38. package/lib/types/core/speakable.d.ts +6 -0
  39. package/lib/types/core/voices.d.ts +23 -0
  40. package/lib/types/core/wav.d.ts +9 -0
  41. package/lib/types/core/workshop.d.ts +156 -0
  42. package/lib/types/dsh/api.d.ts +163 -0
  43. package/lib/types/dsh/body-install.d.ts +58 -0
  44. package/lib/types/dsh/body-launcher.d.ts +28 -0
  45. package/lib/types/dsh/config.d.ts +34 -0
  46. package/lib/types/dsh/her-session.d.ts +215 -0
  47. package/lib/types/dsh/import-status.d.ts +17 -0
  48. package/lib/types/dsh/plugin.d.ts +34 -0
  49. package/lib/types/dsh/workshop.d.ts +94 -0
  50. package/lib/types/index.d.ts +11 -0
  51. package/lib/types/memory/digest.d.ts +33 -0
  52. package/lib/types/memory/search.d.ts +17 -0
  53. package/lib/types/memory/store.d.ts +132 -0
  54. package/lib/types/protocol/index.d.ts +434 -0
  55. package/lib/types/server/brain-server.d.ts +71 -0
  56. package/lib/types/voice/cloud-key.d.ts +10 -0
  57. package/lib/types/voice/cosyvoice.d.ts +47 -0
  58. package/lib/types/voice/edge.d.ts +52 -0
  59. package/lib/types/voice/engine.d.ts +30 -0
  60. package/lib/types/voice/models.d.ts +21 -0
  61. package/lib/types/voice/speech-queue.d.ts +55 -0
  62. package/lib/types/voice/voice.d.ts +75 -0
  63. package/lib/types/voice/worker.d.ts +37 -0
  64. package/lib/voice/cloud-key.js +23 -0
  65. package/lib/voice/cosyvoice.js +194 -0
  66. package/lib/voice/edge.js +199 -0
  67. package/lib/voice/engine.js +101 -0
  68. package/lib/voice/models.js +69 -0
  69. package/lib/voice/speech-queue.js +118 -0
  70. package/lib/voice/voice.js +171 -0
  71. package/lib/voice/worker.js +47 -0
  72. package/package.json +61 -4
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The local voice child process: sherpa-onnx speech recognition (SenseVoice),
3
+ * on CPU. It runs apart from DSH so a native crash or
4
+ * a long synthesis never stalls or kills the host. The parent (engine.ts)
5
+ * forks it with advanced IPC serialization, so audio travels as typed arrays.
6
+ */
7
+ import { createRequire } from 'node:module';
8
+ import { join } from 'node:path';
9
+ const require = createRequire(import.meta.url);
10
+ let sherpa;
11
+ let recognizer;
12
+ async function init(options) {
13
+ const started = Date.now();
14
+ sherpa ??= require('sherpa-onnx-node');
15
+ recognizer = await sherpa.OfflineRecognizer.createAsync({
16
+ featConfig: { sampleRate: 16000, featureDim: 80 },
17
+ modelConfig: {
18
+ senseVoice: { model: join(options.asrDir, 'model.int8.onnx'), language: '', useInverseTextNormalization: 1 },
19
+ tokens: join(options.asrDir, 'tokens.txt'),
20
+ numThreads: options.threads,
21
+ provider: 'cpu',
22
+ debug: 0,
23
+ },
24
+ });
25
+ return { loadMs: Date.now() - started };
26
+ }
27
+ async function handle(request) {
28
+ const started = Date.now();
29
+ switch (request.op) {
30
+ case 'init': {
31
+ const { loadMs } = await init(request.init);
32
+ return { id: request.id, ok: true, op: 'init', loadMs };
33
+ }
34
+ case 'asr': {
35
+ if (recognizer === undefined)
36
+ throw new Error('speech recognition is not loaded');
37
+ const stream = recognizer.createStream();
38
+ stream.acceptWaveform({ samples: request.samples, sampleRate: request.sampleRate });
39
+ const result = await recognizer.decodeAsync(stream);
40
+ return { id: request.id, ok: true, op: 'asr', text: result.text.trim(), lang: result.lang ?? '', ms: Date.now() - started };
41
+ }
42
+ }
43
+ }
44
+ process.on('message', (message) => {
45
+ handle(message).then(reply => process.send?.(reply), (error) => process.send?.({ id: message.id, ok: false, error: error.message ?? String(error) }));
46
+ });
47
+ process.on('disconnect', () => process.exit(0));
package/package.json CHANGED
@@ -1,13 +1,70 @@
1
1
  {
2
2
  "name": "dsh-her",
3
- "version": "0.0.1",
4
- "description": "Reserved placeholder for dsh-her — a DeepSeek Harness companion persona plugin by AIcivilization.",
5
- "keywords": ["deepseek-harness", "dsh", "companion", "persona", "roleplay"],
3
+ "version": "0.1.0",
4
+ "description": "A desktop companion for DeepSeek Harness (dsh): she lives on your real desktop (on top of your windows or inside the wallpaper), talks with you by voice and remembers you. · DSH 桌面女友:住在你真正的桌面上,能语音聊天、记得你。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/types/index.d.ts",
6
8
  "license": "MIT",
9
+ "keywords": [
10
+ "deepseek-harness",
11
+ "dsh",
12
+ "dsh-plugin",
13
+ "companion",
14
+ "desktop",
15
+ "voice",
16
+ "persona"
17
+ ],
7
18
  "repository": {
8
19
  "type": "git",
9
20
  "url": "git+https://github.com/AIcivilization/dsh-her.git"
10
21
  },
11
22
  "homepage": "https://github.com/AIcivilization/dsh-her#readme",
12
- "author": "AIcivilization"
23
+ "author": "AIcivilization",
24
+ "files": [
25
+ "lib",
26
+ "cordis.patch.yml",
27
+ "README.md",
28
+ "examples"
29
+ ],
30
+ "scripts": {
31
+ "build": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-client.mjs",
32
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json",
33
+ "test": "node --test --disable-warning=ExperimentalWarning \"tests/*.test.ts\"",
34
+ "voice:models": "node --disable-warning=ExperimentalWarning scripts/fetch-voice-models.ts",
35
+ "voice:bench": "node --disable-warning=ExperimentalWarning scripts/voice-bench.ts",
36
+ "prepack": "npm run build"
37
+ },
38
+ "peerDependencies": {
39
+ "@deepseek-ai/cordis": "^4.0.1",
40
+ "@deepseek-ai/schemastery": "^3.18.1"
41
+ },
42
+ "dependencies": {
43
+ "sherpa-onnx-node": "^1.12.0",
44
+ "ws": "^8.18.0"
45
+ },
46
+ "devDependencies": {
47
+ "@deepseek-ai/cordis": "^4.0.5",
48
+ "@deepseek-ai/schemastery": "^3.18.5",
49
+ "@types/node": "^24.0.0",
50
+ "@types/ws": "^8.5.12",
51
+ "typescript": "^5.9.2",
52
+ "@types/react": "^18.3.31",
53
+ "esbuild": "^0.28.2"
54
+ },
55
+ "engines": {
56
+ "node": ">=22.18"
57
+ },
58
+ "dsh": {
59
+ "bundle": {
60
+ "patch": "./cordis.patch.yml"
61
+ },
62
+ "client": {
63
+ "platform": "web"
64
+ }
65
+ },
66
+ "exports": {
67
+ ".": "./lib/index.js",
68
+ "./client": "./lib/client.js"
69
+ }
13
70
  }