@flowingspring/dsh-voco 0.3.6 → 0.3.7

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.
@@ -5,6 +5,8 @@ import { existsSync } from "node:fs";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  import { loadEnvFile } from "node:process";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { credentialRef } from "@deepseek-ai/dsh-credentials";
9
+ import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
8
10
  import { mkdtemp, readFile, rm } from "node:fs/promises";
9
11
  import { tmpdir } from "node:os";
10
12
  import { EdgeTTS } from "node-edge-tts";
@@ -539,8 +541,10 @@ function errorMessage(error) {
539
541
  /** Silence-gated SiliconFlow cloud ASR with Edge TTS. */
540
542
  const name = "voice-local";
541
543
  const inject = ["voice"];
544
+ const VOICE_LOCAL_SETTINGS_NAMESPACE = settingsNamespace("voice-local");
545
+ const SILICONFLOW_API_KEY_REF = credentialRef("SILICONFLOW_API_KEY");
542
546
  const Config = z.object({
543
- apiKey: z.string(),
547
+ apiKey: z.string().role("secret"),
544
548
  endpoint: z.string().default("https://api.siliconflow.cn/v1/audio/transcriptions"),
545
549
  model: z.string().default("XingChenAGI/XingChenASR-V3.2-Ultra"),
546
550
  interactionMode: z.union(["speech-shell", "frontend-agent"]).default("speech-shell"),
@@ -575,26 +579,34 @@ function loadProjectEnv() {
575
579
  }
576
580
  }
577
581
  function apply(ctx, config = {}) {
578
- loadProjectEnv();
582
+ if (ctx.get("credentials") === void 0) loadProjectEnv();
583
+ let current = () => config;
584
+ installSettingsSection(ctx, VOICE_LOCAL_SETTINGS_NAMESPACE, Config, config, {
585
+ setSource: (source) => {
586
+ current = source;
587
+ },
588
+ onChange: () => {}
589
+ });
579
590
  return ctx.voice.registerProvider({
580
591
  id: "local",
581
592
  available: () => true,
582
593
  connect: async ({ voiceSessionId, emit }) => {
594
+ const active = current();
583
595
  const session = new LocalSession(new NodeSpeechBackend({
584
- apiKey: config.apiKey ?? process.env.SILICONFLOW_API_KEY ?? "",
585
- endpoint: config.endpoint ?? "https://api.siliconflow.cn/v1/audio/transcriptions",
586
- model: config.model ?? "XingChenAGI/XingChenASR-V3.2-Ultra",
587
- requestTimeoutMs: config.requestTimeoutMs ?? 6e4,
588
- inputSampleRate: config.inputSampleRate ?? 16e3,
589
- outputSampleRate: config.outputSampleRate ?? 48e3,
590
- ttsRate: config.ttsRate ?? "+20%",
591
- silenceDurationMs: config.silenceDurationMs ?? 1500,
592
- speechThreshold: config.speechThreshold ?? .015,
593
- minSpeechDurationMs: config.minSpeechDurationMs ?? 250,
594
- preRollMs: config.preRollMs ?? 400,
595
- trailingSilenceMs: config.trailingSilenceMs ?? 200,
596
- maxUtteranceMs: config.maxUtteranceMs ?? 6e4
597
- }), emit, voiceSessionId, config.interactionMode ?? "speech-shell");
596
+ apiKey: await resolveSiliconFlowApiKey(ctx, active),
597
+ endpoint: active.endpoint ?? "https://api.siliconflow.cn/v1/audio/transcriptions",
598
+ model: active.model ?? "XingChenAGI/XingChenASR-V3.2-Ultra",
599
+ requestTimeoutMs: active.requestTimeoutMs ?? 6e4,
600
+ inputSampleRate: active.inputSampleRate ?? 16e3,
601
+ outputSampleRate: active.outputSampleRate ?? 48e3,
602
+ ttsRate: active.ttsRate ?? "+20%",
603
+ silenceDurationMs: active.silenceDurationMs ?? 1500,
604
+ speechThreshold: active.speechThreshold ?? .015,
605
+ minSpeechDurationMs: active.minSpeechDurationMs ?? 250,
606
+ preRollMs: active.preRollMs ?? 400,
607
+ trailingSilenceMs: active.trailingSilenceMs ?? 200,
608
+ maxUtteranceMs: active.maxUtteranceMs ?? 6e4
609
+ }), emit, voiceSessionId, active.interactionMode ?? "speech-shell");
598
610
  try {
599
611
  await session.start();
600
612
  return session;
@@ -605,5 +617,12 @@ function apply(ctx, config = {}) {
605
617
  }
606
618
  });
607
619
  }
620
+ /** Resolve the key per connection so a settings-page write reaches the next attempt. */
621
+ async function resolveSiliconFlowApiKey(ctx, config) {
622
+ if (config.apiKey !== void 0 && config.apiKey.trim() !== "") return config.apiKey;
623
+ const credentials = ctx.get("credentials");
624
+ if (credentials !== void 0) return (await credentials.resolve(SILICONFLOW_API_KEY_REF))?.value ?? "";
625
+ return process.env.SILICONFLOW_API_KEY ?? "";
626
+ }
608
627
  //#endregion
609
- export { Config, LocalSession, NodeSpeechBackend, SiliconFlowAsr, apply, inject, name, pcm16MonoWav };
628
+ export { Config, LocalSession, NodeSpeechBackend, SILICONFLOW_API_KEY_REF, SiliconFlowAsr, VOICE_LOCAL_SETTINGS_NAMESPACE, apply, inject, name, pcm16MonoWav, resolveSiliconFlowApiKey };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
- {
1
+ {
2
2
  "name": "@flowingspring/dsh-voco",
3
3
  "description": "Persistent voice conversations for DSH with cloud speech recognition, Edge TTS, and background Agent delegation",
4
- "version": "0.3.6",
4
+ "version": "0.3.7",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -15,18 +15,18 @@
15
15
  "bugs": {
16
16
  "url": "https://github.com/lgquan/dsh-voco/issues"
17
17
  },
18
- "publishConfig": {
19
- "access": "public"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/lgquan/dsh-voco.git",
24
- "directory": "packages/voice-app"
25
- },
26
- "type": "module",
27
- "main": "lib/index.js",
28
- "types": "lib/types/index.d.ts",
29
- "exports": {
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/lgquan/dsh-voco.git",
24
+ "directory": "packages/voice-app"
25
+ },
26
+ "type": "module",
27
+ "main": "lib/index.js",
28
+ "types": "lib/types/index.d.ts",
29
+ "exports": {
30
30
  ".": {
31
31
  "types": "./lib/types/index.d.ts",
32
32
  "default": "./lib/index.js"
@@ -45,17 +45,17 @@
45
45
  "./voice-web": "./lib/plugins/voice-web.js",
46
46
  "./cordis.patch.yml": "./cordis.patch.yml",
47
47
  "./package.json": "./package.json"
48
- },
49
- "files": [
48
+ },
49
+ "files": [
50
50
  "lib/index.js",
51
51
  "lib/invariant.js",
52
52
  "lib/client.js",
53
53
  "lib/client.js.map",
54
54
  "lib/plugins/*.js",
55
55
  "cordis.patch.yml",
56
- "lib/types/**/*.d.ts"
57
- ],
58
- "license": "MIT",
56
+ "lib/types/**/*.d.ts"
57
+ ],
58
+ "license": "MIT",
59
59
  "dsh": {
60
60
  "bundle": {
61
61
  "patch": "./cordis.patch.yml"
@@ -65,6 +65,8 @@
65
65
  "@deepseek-ai/dsh-client-connection",
66
66
  "@deepseek-ai/dsh-client-locale",
67
67
  "@deepseek-ai/dsh-client-runtime",
68
+ "@deepseek-ai/dsh-client-ui-settings",
69
+ "@deepseek-ai/dsh-client-ui-settings-plugins",
68
70
  "@deepseek-ai/dsh-client-ui-conversation",
69
71
  "@deepseek-ai/dsh-client-ui-layout",
70
72
  "@deepseek-ai/dsh-client-ui-sidebar"
@@ -86,15 +88,19 @@
86
88
  "@deepseek-ai/dsh-client-connection": "^0.1.1-rc.1",
87
89
  "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.1",
88
90
  "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
91
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
92
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
89
93
  "@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.1",
90
94
  "@deepseek-ai/dsh-client-ui-layout": "^0.1.1-rc.1",
91
95
  "@deepseek-ai/dsh-client-ui-sidebar": "^0.1.1-rc.1",
92
96
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.1",
93
97
  "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
94
98
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
99
+ "@deepseek-ai/dsh-credentials": "^0.1.1-rc.2",
95
100
  "@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
96
101
  "@deepseek-ai/dsh-session": "^0.1.1-rc.1",
97
102
  "@deepseek-ai/dsh-session-persistence": "^0.1.1-rc.1",
103
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
98
104
  "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
99
105
  "@deepseek-ai/dsh-tools": "^0.1.1-rc.1",
100
106
  "@deepseek-ai/dsh-workspace": "^0.1.1-rc.1",
@@ -109,27 +115,31 @@
109
115
  "@deepseek-ai/dsh-client-connection": "^0.1.1-rc.1",
110
116
  "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.1",
111
117
  "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
118
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
119
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
112
120
  "@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.1",
113
121
  "@deepseek-ai/dsh-client-ui-layout": "^0.1.1-rc.1",
114
122
  "@deepseek-ai/dsh-client-ui-sidebar": "^0.1.1-rc.1",
115
123
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.1",
116
124
  "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
117
125
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
126
+ "@deepseek-ai/dsh-credentials": "^0.1.1-rc.2",
118
127
  "@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
119
128
  "@deepseek-ai/dsh-session": "^0.1.1-rc.1",
120
129
  "@deepseek-ai/dsh-session-persistence": "^0.1.1-rc.1",
130
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
121
131
  "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
122
132
  "@deepseek-ai/dsh-tools": "^0.1.1-rc.1",
123
133
  "@deepseek-ai/dsh-workspace": "^0.1.1-rc.1",
134
+ "@flowingspring/dsh-client-ui-voice": "workspace:*",
135
+ "@flowingspring/dsh-llm-tool-call-compat": "workspace:*",
136
+ "@flowingspring/dsh-voice": "workspace:*",
137
+ "@flowingspring/dsh-voice-assistant": "workspace:*",
138
+ "@flowingspring/dsh-voice-local": "workspace:*",
139
+ "@flowingspring/dsh-voice-web": "workspace:*",
124
140
  "@types/react": "~18.3.1",
125
141
  "@types/ws": "^8.18.1",
126
142
  "react": "^18.2.0",
127
- "react-dom": "^18.2.0",
128
- "@flowingspring/dsh-voice-local": "0.1.0",
129
- "@flowingspring/dsh-client-ui-voice": "0.1.2",
130
- "@flowingspring/dsh-llm-tool-call-compat": "0.1.0",
131
- "@flowingspring/dsh-voice": "0.1.2",
132
- "@flowingspring/dsh-voice-web": "0.1.2",
133
- "@flowingspring/dsh-voice-assistant": "0.1.2"
143
+ "react-dom": "^18.2.0"
134
144
  }
135
- }
145
+ }