dsh-duet 0.1.0 → 0.1.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.
Files changed (42) hide show
  1. package/README.md +15 -16
  2. package/package.json +31 -20
  3. package/{deepseek_harness_voice_audio.mjs → src/client/audio.mjs} +4 -4
  4. package/{deepseek_harness_voice_browser.mjs → src/client/browser.mjs} +41 -20
  5. package/src/client/connection-hint.mjs +43 -0
  6. package/{deepseek_harness_duplex_focus_client/lib/client.js → src/client/entry.js} +15 -15
  7. package/{deepseek_harness_voice_interactions.mjs → src/client/interactions.mjs} +3 -1
  8. package/{deepseek_harness_voice_rpc.mjs → src/client/rpc.mjs} +4 -3
  9. package/{deepseek_harness_duplex_control_plugin.html → src/client/settings.html} +18 -22
  10. package/{deepseek_harness_voice_shortcuts.mjs → src/client/shortcuts.mjs} +1 -1
  11. package/{deepseek_harness_voice_tutorial_adapter.mjs → src/client/tutorial-adapter.mjs} +4 -2
  12. package/{deepseek_harness_voice_tutorial.mjs → src/client/tutorial.mjs} +15 -15
  13. package/src/client/workspaces.mjs +25 -0
  14. package/src/host/assets.mjs +28 -0
  15. package/src/host/environment.mjs +10 -0
  16. package/{deepseek_harness_duplex_control_plugin.mjs → src/host/plugin.mjs} +34 -32
  17. package/{deepseek_harness_voice_proxy.mjs → src/host/proxy.mjs} +17 -13
  18. package/src/host/service-defaults.mjs +12 -0
  19. package/{deepseek_harness_voice_settings.mjs → src/host/settings.mjs} +11 -15
  20. package/{deepseek_harness_voice_trace.mjs → src/host/trace.mjs} +4 -3
  21. package/{deepseek_harness_voice_catalog.mjs → src/shared/catalog.mjs} +15 -4
  22. package/{deepseek_harness_voice_state.mjs → src/shared/state.mjs} +5 -2
  23. /package/{tutorial-audio → assets/tutorial-audio}/broadcast.wav +0 -0
  24. /package/{tutorial-audio → assets/tutorial-audio}/clear.wav +0 -0
  25. /package/{tutorial-audio → assets/tutorial-audio}/edit.wav +0 -0
  26. /package/{tutorial-audio → assets/tutorial-audio}/input.wav +0 -0
  27. /package/{tutorial-audio → assets/tutorial-audio}/manifest.json +0 -0
  28. /package/{tutorial-audio → assets/tutorial-audio}/modes_broadcast.wav +0 -0
  29. /package/{tutorial-audio → assets/tutorial-audio}/modes_interaction.wav +0 -0
  30. /package/{tutorial-audio → assets/tutorial-audio}/reinput.wav +0 -0
  31. /package/{tutorial-audio → assets/tutorial-audio}/send.wav +0 -0
  32. /package/{tutorial-audio → assets/tutorial-audio}/switch.wav +0 -0
  33. /package/{deepseek_harness_duplex_control.patch.yml → config/duet.patch.yml} +0 -0
  34. /package/{deepseek_harness_voice_composer.mjs → src/client/composer.mjs} +0 -0
  35. /package/{deepseek_harness_voice_consent.mjs → src/client/consent.mjs} +0 -0
  36. /package/{deepseek_harness_voice_feedback.mjs → src/client/feedback.mjs} +0 -0
  37. /package/{deepseek_harness_voice_microphone.mjs → src/client/microphone.mjs} +0 -0
  38. /package/{deepseek_harness_voice_tutorial_request.mjs → src/client/tutorial-request.mjs} +0 -0
  39. /package/{deepseek_harness_voice_feedback_files.mjs → src/host/feedback-files.mjs} +0 -0
  40. /package/{deepseek_harness_voice_feedback_store.mjs → src/host/feedback-store.mjs} +0 -0
  41. /package/{deepseek_harness_voice_notices.mjs → src/host/notices.mjs} +0 -0
  42. /package/{deepseek_harness_voice_service_info.mjs → src/host/service-info.mjs} +0 -0
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # duet
2
2
 
3
- duet 将**全双工语音交互模型带入 DeepSeek Harness(DSH)**,让你可以像用语音来使用 DSH。
4
- 它可以边听边说,你不必等它说完再开口:随时插话、补充需求、修改内容,让对话自然接续。
5
- 你可以用语音输入和提交任务、切换会话;任务完成后,dsh-duet 会简要播报结果。除此之外,你还可以跟 dsh-duet 聊聊天。
3
+ **只用语音,就能操作 DeepSeek Harness(DSH)。**
6
4
 
7
- 目前处于**试用阶段**,duet 语音服务无需配置 API Key,即可直接使用。
8
- 通过 DSH 提交任务所使用的模型仍遵循你自己的 DSH 配置与计费。
5
+ duet,意为「二重奏」。这里的 duet 使用全双工语音模型,可以边听边说,
6
+ 让你与 DSH 的交流不必一人一句地等待。
7
+
8
+ 说出需求、修改输入、发送任务、切换会话——把键盘上的操作交给声音。
9
+ 任务完成后,duet 会简短播报结果,让你不用一直盯着屏幕。
10
+
11
+ 你可以随时插话、补充或纠正。处理任务之外,也可以聊聊天。
12
+
13
+ 目前处于**试用阶段**,duet 语音服务可以免费使用。
9
14
 
10
15
  ## 安装
11
16
 
@@ -30,17 +35,14 @@ dsh web
30
35
 
31
36
  ## 使用
32
37
 
33
- 页面上的 **duet** 提供两种模式,浅蓝色表示当前模式;点击另一按钮切换,再点当前按钮关闭。
34
- 默认两个模式都关闭。
38
+ duet 支持两种模式。
35
39
 
36
40
  | 按钮 | 模式 | 用途 |
37
41
  | --- | --- | --- |
38
42
  | 喇叭 | 播报模式 | 任务完成后,进行简短的播报 |
39
43
  | 双向箭头 | 交互模式 | 开口操作 DSH、自由聊天,也可以在回复过程中插话 |
40
44
 
41
- 第一次使用可以跟随页面教学,也可以稍后从设置打开。
42
-
43
- ### 支持的语音操作
45
+ ### 目前支持的语音操作
44
46
 
45
47
  | 操作 | 你可以这样说 |
46
48
  | --- | --- |
@@ -53,20 +55,17 @@ dsh web
53
55
  | 重命名会话 | “把当前会话改名为周末安排” |
54
56
  | 分叉会话 | “从当前会话分叉一个新会话” |
55
57
  | 归档会话 | “归档这个会话” |
58
+ | 回答 DSH 的问题 | “选第二个”“用中文就好” |
56
59
  | 自由聊天 | “什么是全双工语音交互?” |
57
60
 
58
- 输入和修改不会自动发送,检查内容后再说“发送”。任务结果会在完成后播报。
59
- 设置页还提供服务通知、教学和文字反馈,关闭语音时也可以为本次体验打分。
60
-
61
61
  ## 麦克风与隐私
62
62
 
63
63
  duet 通过服务器提供语音服务。根据所使用的功能,以下信息会上传至服务器,用于理解语音、执行会话操作、生成回复和语音播报:
64
64
 
65
65
  - 交互模式开启期间,麦克风采集的交互音频。
66
- - 交互所需的会话信息,例如会话标识、名称、运行状态和当前选中的会话。
67
- - 交互所需的输入框内容、任务结果及相关上下文。
66
+ - 交互所需的会话信息,例如会话标识、名称、运行状态和当前会话名称。
67
+ - 交互所需的输入框内容、任务结果。
68
68
 
69
- 关闭交互模式后,会停止采集和上传麦克风音频。
70
69
  请勿在交互中提供密码、密钥等敏感内容。
71
70
 
72
71
  **目前仅支持中文。**
package/package.json CHANGED
@@ -1,27 +1,39 @@
1
1
  {
2
2
  "name": "dsh-duet",
3
- "version": "0.1.0",
4
- "description": "duet: full-duplex voice interaction and task announcements for DeepSeek Harness",
5
- "keywords": ["dsh-plugin", "deepseek-harness", "full-duplex", "voice"],
3
+ "version": "0.1.2",
4
+ "description": "duet(二重奏):只用语音就能操作 DSH,边听边说、随时插话的全双工语音助手。",
5
+ "keywords": [
6
+ "dsh-plugin",
7
+ "deepseek-harness",
8
+ "full-duplex",
9
+ "voice"
10
+ ],
6
11
  "license": "Apache-2.0",
7
- "author": { "name": "YuMS", "email": "yumaoshu@gmail.com" },
8
- "repository": { "type": "git", "url": "https://github.com/YuMS/dsh-duet.git" },
9
- "engines": { "node": "^22.19.0 || >=24.0.0" },
12
+ "author": {
13
+ "name": "YuMS"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/YuMS/dsh-duet.git"
18
+ },
19
+ "engines": {
20
+ "node": "^22.19.0 || >=24.0.0"
21
+ },
10
22
  "scripts": {
11
23
  "test": "node scripts/test.mjs",
12
24
  "check": "node scripts/check-package.mjs",
13
- "test:browser": "node smoke_deepseek_harness_settings_page.mjs && node smoke_harness_tutorial.mjs && node smoke_duet_feedback.mjs",
14
- "test:host": "node scripts/smoke-isolated-host.mjs",
25
+ "test:browser": "node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs",
26
+ "test:host": "node tests/host/isolated-host.mjs",
15
27
  "prepack": "npm run check"
16
28
  },
17
29
  "type": "module",
18
- "main": "./deepseek_harness_duplex_control_plugin.mjs",
30
+ "main": "./src/host/plugin.mjs",
19
31
  "exports": {
20
32
  ".": {
21
- "default": "./deepseek_harness_duplex_control_plugin.mjs"
33
+ "default": "./src/host/plugin.mjs"
22
34
  },
23
35
  "./client": {
24
- "default": "./deepseek_harness_duplex_focus_client/lib/client.js"
36
+ "default": "./src/client/entry.js"
25
37
  },
26
38
  "./package.json": "./package.json"
27
39
  },
@@ -29,25 +41,24 @@
29
41
  "LICENSE",
30
42
  "NOTICE",
31
43
  "HEROICONS-LICENSE.txt",
32
- "deepseek_harness_voice_*.mjs",
33
- "tutorial-audio/*.wav",
34
- "tutorial-audio/manifest.json",
35
- "deepseek_harness_duplex_control.patch.yml",
36
- "deepseek_harness_duplex_control_plugin.mjs",
37
- "deepseek_harness_duplex_control_plugin.html",
38
- "deepseek_harness_duplex_focus_client/lib/client.js"
44
+ "src/",
45
+ "config/",
46
+ "assets/tutorial-audio/"
39
47
  ],
40
48
  "dependencies": {
41
49
  "ws": "^8.18.3"
42
50
  },
43
- "devDependencies": { "playwright": "1.58.2" },
51
+ "devDependencies": {
52
+ "playwright": "1.58.2"
53
+ },
44
54
  "dsh": {
45
55
  "bundle": {
46
- "patch": "./deepseek_harness_duplex_control.patch.yml"
56
+ "patch": "./config/duet.patch.yml"
47
57
  },
48
58
  "client": {
49
59
  "inject": [
50
60
  "@deepseek-ai/dsh-api-session-controller",
61
+ "@deepseek-ai/dsh-api-workspace-controller",
51
62
  "@deepseek-ai/dsh-client-ui-session",
52
63
  "@deepseek-ai/dsh-client-ui-conversation"
53
64
  ],
@@ -1,7 +1,7 @@
1
- import { microphoneConstraints } from './deepseek_harness_voice_microphone.mjs?v=0.1.0'
1
+ import { microphoneConstraints } from './microphone.mjs?v=0.1.2'
2
2
 
3
3
  /** Browser-owned microphone and PCM playback. No microphone is requested in tts_only. */
4
- export class VoiceAudio {
4
+ export class DuetAudio {
5
5
  constructor() {
6
6
  this.context = null
7
7
  this.stream = null
@@ -48,14 +48,14 @@ export class VoiceAudio {
48
48
  for(const x of a){this.sum+=x;this.count++;this.phase+=16000;
49
49
  if(this.phase>=sampleRate){this.phase-=sampleRate;const v=Math.max(-1,Math.min(1,this.sum/this.count));this.pcm[this.offset++]=v<0?v*32768:v*32767;this.sum=0;this.count=0;
50
50
  if(this.offset===1280){this.port.postMessage(this.pcm.buffer,[this.pcm.buffer]);this.pcm=new Int16Array(1280);this.offset=0;}}}return true;}}
51
- registerProcessor('duplex-voice-capture',Capture)`
51
+ registerProcessor('duet-audio-capture',Capture)`
52
52
  if (!this.captureLoaded) {
53
53
  const url = URL.createObjectURL(new Blob([code], { type: 'text/javascript' }))
54
54
  try { await this.context.audioWorklet.addModule(url); this.captureLoaded = true } finally { URL.revokeObjectURL(url) }
55
55
  }
56
56
  if (epoch !== this.epoch) { stream.getTracks().forEach(t => t.stop()); return }
57
57
  this.source = this.context.createMediaStreamSource(stream)
58
- this.capture = new AudioWorkletNode(this.context, 'duplex-voice-capture')
58
+ this.capture = new AudioWorkletNode(this.context, 'duet-audio-capture')
59
59
  this.capture.port.onmessage = e => { if (epoch === this.epoch) send(e.data) }
60
60
  this.mute = this.context.createGain()
61
61
  this.mute.gain.value = 0
@@ -1,21 +1,23 @@
1
- import { VoiceState, PLUGIN_VERSION } from './deepseek_harness_voice_state.mjs?v=0.1.0'
2
- import { VoiceAudio } from './deepseek_harness_voice_audio.mjs?v=0.1.0'
3
- import { HarnessRPCExecutor } from './deepseek_harness_voice_rpc.mjs?v=0.1.0'
4
- import { composerAccess, observeComposer, focusedSession } from './deepseek_harness_voice_composer.mjs?v=0.1.0'
5
- import { mountTutorial } from './deepseek_harness_voice_tutorial.mjs?v=0.1.0'
6
- import { tutorialAdapter } from './deepseek_harness_voice_tutorial_adapter.mjs?v=0.1.0'
7
- import { mountRating } from './deepseek_harness_voice_feedback.mjs?v=0.1.0'
8
- import { createAudioUploadConsent } from './deepseek_harness_voice_consent.mjs?v=0.1.0'
9
- import { bindVoiceShortcuts } from './deepseek_harness_voice_shortcuts.mjs?v=0.1.0'
10
- import { nativeInteractions } from './deepseek_harness_voice_interactions.mjs?v=0.1.0'
1
+ import { DuetState, PLUGIN_VERSION } from '../shared/state.mjs?v=0.1.2'
2
+ import { DuetAudio } from './audio.mjs?v=0.1.2'
3
+ import { HarnessRPCExecutor } from './rpc.mjs?v=0.1.2'
4
+ import { composerAccess, observeComposer, focusedSession } from './composer.mjs?v=0.1.2'
5
+ import { mountTutorial } from './tutorial.mjs?v=0.1.2'
6
+ import { tutorialAdapter } from './tutorial-adapter.mjs?v=0.1.2'
7
+ import { mountRating } from './feedback.mjs?v=0.1.2'
8
+ import { createAudioUploadConsent } from './consent.mjs?v=0.1.2'
9
+ import { bindDuetShortcuts } from './shortcuts.mjs?v=0.1.2'
10
+ import { nativeInteractions } from './interactions.mjs?v=0.1.2'
11
+ import { mountConnectionHint } from './connection-hint.mjs?v=0.1.2'
12
+ import { workspaceIssue, requireWorkspace, browserSessionCatalog } from './workspaces.mjs?v=0.1.2'
11
13
 
12
- export function mountVoice(ctx) {
13
- const audio = new VoiceAudio()
14
+ export function mountDuet(ctx) {
15
+ const audio = new DuetAudio()
14
16
  const audioConsent = createAudioUploadConsent()
15
17
  let disposed = false, controls, toastTimer, pollRunning = false, cursor = null, resultEpoch = null
16
18
  const labels = new Map()
17
19
  let clientTraceId = null, diagnosticCount = 0
18
- let tutorial, teaching, ratingPanel
20
+ let tutorial, teaching, ratingPanel, connectionHint
19
21
  const diagnostic = data => {
20
22
  if (++diagnosticCount > 100) return
21
23
  const bounded = Object.fromEntries(Object.entries(data).map(([k, v]) => [k, typeof v === 'string' ? v.slice(0, 4000) : v]))
@@ -29,6 +31,7 @@ export function mountVoice(ctx) {
29
31
  window.addEventListener('error', pageError)
30
32
  window.addEventListener('unhandledrejection', pageError)
31
33
  const notice = (text, { upgrade = false } = {}) => {
34
+ connectionHint?.dismiss()
32
35
  if (upgrade) { ratingPanel?.dispose(); ratingPanel = null }
33
36
  const toast = controls?.querySelector('[role=status]')
34
37
  if (!toast) return
@@ -74,8 +77,10 @@ export function mountVoice(ctx) {
74
77
  const mark = controls.querySelector('[data-duet-mark]')
75
78
  mark.style.color = state.ready ? '#7fd6a6' : '#ed9b35'
76
79
  mark.title = state.ready ? '语音已连接' : '语音未连接'
80
+ connectionHint?.update({ mode: state.mode, ready: state.ready, teaching: Boolean(tutorial?.active) })
77
81
  }
78
82
  const connect = (mode, receive) => {
83
+ requireWorkspace(ctx)
79
84
  if (!audioConsent.granted()) throw Error('data_upload_consent_required')
80
85
  clientTraceId = crypto.randomUUID(); diagnosticCount = 0
81
86
  const connectionTraceId = clientTraceId
@@ -89,7 +94,7 @@ export function mountVoice(ctx) {
89
94
  const composer = composerAccess(ctx, id => labels.get(id) || id)
90
95
  const interactions = nativeInteractions(ctx)
91
96
  const rpc = new HarnessRPCExecutor(send, fetch, report, async (request, signal) =>
92
- (await interactions(request, signal)) ?? composer.execute(request, signal))
97
+ (await interactions(request, signal)) ?? composer.execute(request, signal), rows => browserSessionCatalog(ctx, rows))
93
98
  const connection = {
94
99
  feedbackTicket: null,
95
100
  send,
@@ -116,6 +121,7 @@ export function mountVoice(ctx) {
116
121
  // Establish/renew the host-signed anonymous cookie before the WS handshake.
117
122
  const identity=await fetch('/duplex-control/api/voice/config',{credentials:'same-origin',cache:'no-store'})
118
123
  if(!identity.ok)throw Error('voice_config_unavailable')
124
+ requireWorkspace(ctx)
119
125
  if(closed)return
120
126
  const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:'
121
127
  ws = new WebSocket(`${protocol}//${location.host}/duplex-control/voice/ws?mode=${mode}&plugin_version=${PLUGIN_VERSION}&client_trace_id=${connectionTraceId}`)
@@ -190,15 +196,15 @@ export function mountVoice(ctx) {
190
196
  } else queueMicrotask(() => receive({ type: 'error', code: 'voice_lock_unavailable' }))
191
197
  return connection
192
198
  }
193
- const state = new VoiceState({ connect, changed: draw, notice })
199
+ const state = new DuetState({ connect, changed: draw, notice })
194
200
  const mount = () => {
195
- const entry = document.getElementById('dsh-duplex-control-entry')
196
- if (!entry || document.getElementById('dsh-duplex-voice-controls')) return
201
+ const entry = document.getElementById('dsh-duet-entry')
202
+ if (!entry || document.getElementById('dsh-duet-controls')) return
197
203
  controls = document.createElement('div')
198
- controls.id = 'dsh-duplex-voice-controls'
204
+ controls.id = 'dsh-duet-controls'
199
205
  controls.style.cssText = 'display:flex;gap:4px;position:relative;padding:6px 8px;align-items:center;margin:4px 8px;max-width:100%'
200
206
  const style = document.createElement('style')
201
- style.textContent = '@keyframes duet-connecting-snake{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}} #dsh-duplex-voice-controls [data-connecting-ring]{position:absolute;inset:0;pointer-events:none} #dsh-duplex-voice-controls [data-connecting-ring] svg{display:block;width:100%;height:100%;overflow:visible} #dsh-duplex-voice-controls [data-connecting-ring] rect{fill:none;stroke:#ed9b35;stroke-width:2;stroke-linecap:round;stroke-dasharray:28 72;animation:duet-connecting-snake 1.6s linear infinite!important} #dsh-duplex-voice-controls [data-connecting-ring][hidden]{display:none}'
207
+ style.textContent = '@keyframes duet-connecting-snake{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}} #dsh-duet-controls [data-connecting-ring]{position:absolute;inset:0;pointer-events:none} #dsh-duet-controls [data-connecting-ring] svg{display:block;width:100%;height:100%;overflow:visible} #dsh-duet-controls [data-connecting-ring] rect{fill:none;stroke:#ed9b35;stroke-width:2;stroke-linecap:round;stroke-dasharray:28 72;animation:duet-connecting-snake 1.6s linear infinite!important} #dsh-duet-controls [data-connecting-ring][hidden]{display:none}'
202
208
  controls.append(style)
203
209
  const parent = entry.parentElement
204
210
  parent.insertBefore(controls, entry)
@@ -223,8 +229,17 @@ export function mountVoice(ctx) {
223
229
  button.append(ring)
224
230
  button.onclick = () => {
225
231
  if (tutorial?.active) { notice('请先结束教学,再切换模式。'); return }
232
+ const requestedMode = kind === 'mic' ? 'online' : 'tts_only'
233
+ const checkWorkspace = () => {
234
+ if (state.mode === requestedMode) return true // Closing is always allowed.
235
+ const issue = workspaceIssue(ctx)
236
+ if (issue) { state.fail(issue); return false }
237
+ return true
238
+ }
239
+ if (!checkWorkspace()) return
226
240
  const activate = () => {
227
241
  if (disposed || tutorial?.active) return
242
+ if (!checkWorkspace()) return
228
243
  // Unlock playback inside user activation, before any network await.
229
244
  const enabling = kind === 'mic' ? state.mode !== 'online' : state.mode !== 'tts_only'
230
245
  if (enabling) void audio.prepare().catch(() => state.fail('audio_permission_denied'))
@@ -257,10 +272,12 @@ export function mountVoice(ctx) {
257
272
  toast.hidden = true
258
273
  toast.style.cssText = 'position:absolute;bottom:100%;left:0;z-index:9999;min-width:180px;max-width:280px;background:#252c38;color:white;padding:10px;border-radius:8px;font-size:12px;box-shadow:0 3px 18px #0005'
259
274
  controls.append(toast)
275
+ connectionHint?.dispose()
276
+ connectionHint = mountConnectionHint(controls)
260
277
  draw(state)
261
278
  }
262
279
  mount()
263
- const stopShortcuts = bindVoiceShortcuts(kind => controls?.querySelector(`[data-voice=${kind}]`)?.click())
280
+ const stopShortcuts = bindDuetShortcuts(kind => controls?.querySelector(`[data-voice=${kind}]`)?.click())
264
281
  const observer = new MutationObserver(mount)
265
282
  observer.observe(document.body, { subtree: true, childList: true })
266
283
 
@@ -276,6 +293,9 @@ export function mountVoice(ctx) {
276
293
  try {
277
294
  const [catalog, completed, health] = await Promise.all([api('sessions'), api(`results?after=${cursor ?? 0}&limit=100`), api('health')])
278
295
  if (disposed) return
296
+ catalog.sessions = browserSessionCatalog(ctx, catalog.sessions)
297
+ const issue = workspaceIssue(ctx)
298
+ if (issue === 'workspace_required' && state.mode !== 'off') state.fail(issue)
279
299
  for (const s of catalog.sessions) labels.set(s.session_id, s.label)
280
300
  const bootstrap = cursor === null || resultEpoch !== health.focus_epoch
281
301
  resultEpoch = health.focus_epoch
@@ -333,6 +353,7 @@ export function mountVoice(ctx) {
333
353
  tutorial?.dispose()
334
354
  audioConsent.cancel()
335
355
  ratingPanel?.dispose()
356
+ connectionHint?.dispose()
336
357
  clearInterval(timer); clearInterval(progress); clearTimeout(toastTimer)
337
358
  document.removeEventListener('visibilitychange', visibility)
338
359
  window.removeEventListener('error', pageError)
@@ -0,0 +1,43 @@
1
+ /** A brief, non-modal invitation after the microphone is actually ready. */
2
+ export function mountConnectionHint(controls, { duration = 8000 } = {}) {
3
+ const hint = document.createElement('div')
4
+ hint.dataset.duetConnectionHint = ''
5
+ hint.setAttribute('role', 'status')
6
+ hint.setAttribute('aria-live', 'polite')
7
+ hint.hidden = true
8
+ hint.style.cssText = 'position:absolute;bottom:calc(100% + 10px);left:0;z-index:9998;box-sizing:border-box;width:268px;max-width:calc(100vw - 32px);padding:12px 15px;border:1px solid #a5d8f4;border-radius:12px;background:#eff9ff;color:#163c56;font:13px/1.65 system-ui,sans-serif;box-shadow:0 8px 28px #153e6524;pointer-events:none'
9
+ hint.textContent = '连接成功,可以试试对我说“你好”。'
10
+ const arrow = document.createElement('span')
11
+ arrow.setAttribute('aria-hidden', 'true')
12
+ arrow.style.cssText = 'position:absolute;bottom:-6px;width:10px;height:10px;transform:rotate(45deg);background:#eff9ff;border-right:1px solid #a5d8f4;border-bottom:1px solid #a5d8f4'
13
+ hint.append(arrow)
14
+ controls.append(hint)
15
+ let wasReady = false, timer, disposed = false
16
+ const hide = () => { hint.hidden = true; clearTimeout(timer) }
17
+ const dismiss = event => { if (event.type !== 'keydown' || event.key === 'Escape') hide() }
18
+ controls.addEventListener('pointerdown', dismiss)
19
+ document.addEventListener('keydown', dismiss)
20
+ return {
21
+ dismiss: hide,
22
+ update({ mode, ready, teaching = false }) {
23
+ if (disposed) return
24
+ const active = mode === 'online' && ready
25
+ if (!active || teaching) hide()
26
+ if (active && !wasReady && !teaching) {
27
+ const button = controls.querySelector('[data-voice=mic]')
28
+ arrow.style.left = `${Math.max(16, Math.min(244, (button?.offsetLeft || 32) + (button?.offsetWidth || 30) / 2 - 5))}px`
29
+ hint.hidden = false
30
+ clearTimeout(timer)
31
+ timer = setTimeout(hide, duration)
32
+ }
33
+ wasReady = active
34
+ },
35
+ dispose() {
36
+ disposed = true
37
+ hide()
38
+ controls.removeEventListener('pointerdown', dismiss)
39
+ document.removeEventListener('keydown', dismiss)
40
+ hint.remove()
41
+ },
42
+ }
43
+ }
@@ -5,7 +5,7 @@ window.__ModuleLoader__.load({
5
5
  const exports = module.exports
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" })
7
7
 
8
- const inject = ["sessions", "conversation", "uiSession"]
8
+ const inject = ["sessions", "conversation", "uiSession", "workspaces"]
9
9
 
10
10
  function apply(ctx) {
11
11
  const focusedSession = () => {
@@ -31,13 +31,13 @@ window.__ModuleLoader__.load({
31
31
  ctx.effect(() => {
32
32
  let active = true
33
33
  let dispose
34
- import('/duplex-control/deepseek_harness_voice_browser.mjs?v=0.1.0').then(module => {
35
- if (active) dispose = module.mountVoice(ctx)
36
- }).catch(error => console.warn('Duplex voice controls could not load:', error))
34
+ import('/duet/assets/client/browser.mjs?v=0.1.2').then(module => {
35
+ if (active) dispose = module.mountDuet(ctx)
36
+ }).catch(error => console.warn('duet controls could not load:', error))
37
37
  return () => { active = false; dispose?.() }
38
- }, 'duplex-voice-client: three-state microphone and playback controls')
38
+ }, 'duet-client: three-state microphone and playback controls')
39
39
  ctx.effect(() => {
40
- const entryId = "dsh-duplex-control-entry"
40
+ const entryId = "dsh-duet-entry"
41
41
 
42
42
  const mountEntry = () => {
43
43
  if (document.getElementById(entryId) !== null) return
@@ -49,7 +49,7 @@ window.__ModuleLoader__.load({
49
49
  const entry = document.createElement("span")
50
50
  entry.id = entryId
51
51
  entry.setAttribute("aria-label", "duet")
52
- entry.setAttribute("data-duplex-surface", "control-entry")
52
+ entry.setAttribute("data-duet-surface", "control-entry")
53
53
  entry.style.textDecoration = "none"
54
54
  entry.style.marginBottom = "4px"
55
55
 
@@ -68,7 +68,7 @@ window.__ModuleLoader__.load({
68
68
  observer.disconnect()
69
69
  document.getElementById(entryId)?.remove()
70
70
  }
71
- }, "duplex-control-client: mount main page entry")
71
+ }, "duet-client: mount main page entry")
72
72
 
73
73
  ctx.effect(() => {
74
74
  if (typeof BroadcastChannel === "undefined") return () => {}
@@ -136,7 +136,7 @@ window.__ModuleLoader__.load({
136
136
  }
137
137
 
138
138
  return () => channel.close()
139
- }, "duplex-control-client: bridge current composer")
139
+ }, "duet-client: bridge current composer")
140
140
 
141
141
  ctx.effect(() => {
142
142
  const controller = new AbortController()
@@ -298,7 +298,7 @@ window.__ModuleLoader__.load({
298
298
  // rather than spinning if a browser/host upgrade is staggered.
299
299
  succeeded = payload.long_poll_supported === true
300
300
  } catch (error) {
301
- if (!controller.signal.aborted) console.warn("duplex composer RPC failed:", error)
301
+ if (!controller.signal.aborted) console.warn("duet composer RPC failed:", error)
302
302
  } finally {
303
303
  pollRunning = false
304
304
  if (!controller.signal.aborted) {
@@ -321,7 +321,7 @@ window.__ModuleLoader__.load({
321
321
  window.removeEventListener?.('pageshow', resume)
322
322
  if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', resume)
323
323
  }
324
- }, "duplex-control-client: bridge server composer RPC")
324
+ }, "duet-client: bridge server composer RPC")
325
325
 
326
326
  ctx.effect(() => {
327
327
  const controller = new AbortController()
@@ -361,7 +361,7 @@ window.__ModuleLoader__.load({
361
361
  })
362
362
  if (response.ok) observeEpoch((await response.json()).focus_epoch)
363
363
  } catch (error) {
364
- if (!controller.signal.aborted) console.warn("duplex heartbeat failed:", error)
364
+ if (!controller.signal.aborted) console.warn("duet heartbeat failed:", error)
365
365
  } finally {
366
366
  heartbeatRunning = false
367
367
  }
@@ -393,7 +393,7 @@ window.__ModuleLoader__.load({
393
393
  lastPublishedSession = sessionId
394
394
  } while (publishPending)
395
395
  } catch (error) {
396
- if (!controller.signal.aborted) console.warn("duplex selection publish failed:", error)
396
+ if (!controller.signal.aborted) console.warn("duet selection publish failed:", error)
397
397
  } finally {
398
398
  publishRunning = false
399
399
  }
@@ -426,7 +426,7 @@ window.__ModuleLoader__.load({
426
426
  else ctx.sessions.open(focus.session_id)
427
427
  lastRevision = focus.revision
428
428
  } catch (error) {
429
- if (!controller.signal.aborted) console.warn("duplex focus sync failed:", error)
429
+ if (!controller.signal.aborted) console.warn("duet focus sync failed:", error)
430
430
  } finally {
431
431
  pollRunning = false
432
432
  }
@@ -456,7 +456,7 @@ window.__ModuleLoader__.load({
456
456
  window.removeEventListener?.('pageshow', onVisibilityChange)
457
457
  unsubscribe()
458
458
  }
459
- }, "duplex-focus-client: synchronize host and browser focus")
459
+ }, "duet-client: synchronize host and browser focus")
460
460
  }
461
461
 
462
462
  exports.apply = apply
@@ -1,7 +1,9 @@
1
1
  /** Use the same pending objects as DSH's clickable question/approval cards. */
2
2
  export function nativeInteractions(ctx) {
3
3
  const firstSeen = new WeakMap()
4
- const pending = () => [...ctx.uiSession.pendingInteractions.getSnapshot().values()]
4
+ const pending = () => ctx.uiSession.sessionStatus
5
+ ? [...ctx.uiSession.sessionStatus.getSnapshot().values()].map(row => row.pendingInteraction).filter(Boolean)
6
+ : [...ctx.uiSession.pendingInteractions.getSnapshot().values()]
5
7
  const publicValue = value => {
6
8
  if (!firstSeen.has(value)) firstSeen.set(value, Date.now() / 1000)
7
9
  return { id: value.key, session_id: value.sessionId, created_at: firstSeen.get(value),
@@ -1,5 +1,5 @@
1
1
  /** Reverse RPC executes on this authenticated DSH origin, never a supplied URL. */
2
- import { orderSessionCatalog, readWorkspaceView } from './deepseek_harness_voice_catalog.mjs'
2
+ import { orderSessionCatalog, readWorkspaceView } from '../shared/catalog.mjs'
3
3
  const MAX_BYTES = 256_000
4
4
  const READ = /^\/api\/(?:health|sessions|jobs|results|interactions|composer\/focused|sessions\/[A-Za-z0-9_-]+\/composer)$/
5
5
  const WRITE = /^\/api\/(?:sessions\/[A-Za-z0-9_-]+\/(?:composer\/submit|activate|rename|fork)|interactions\/(?:(?:question|approval)(?::|%3[Aa]))?[A-Za-z0-9_-]+\/respond)$/
@@ -20,12 +20,13 @@ export function validateRPC(request) {
20
20
  }
21
21
 
22
22
  export class HarnessRPCExecutor {
23
- constructor(send, fetchImpl = fetch, diagnostic = () => {}, localComposer = null) {
23
+ constructor(send, fetchImpl = fetch, diagnostic = () => {}, localComposer = null, catalogOrder = rows => orderSessionCatalog(rows, readWorkspaceView())) {
24
24
  // Native Window.fetch rejects an RPCExecutor receiver (Illegal invocation).
25
25
  // Call the captured function plainly, not as an instance method.
26
26
  this.send = send; this.fetch = (...args) => fetchImpl(...args); this.closed = false
27
27
  this.diagnostic = diagnostic
28
28
  this.localComposer = localComposer
29
+ this.catalogOrder = catalogOrder
29
30
  this.connectionId = null; this.seen = new Map(); this.retired = new Set(); this.controllers = new Set()
30
31
  }
31
32
 
@@ -84,7 +85,7 @@ export class HarnessRPCExecutor {
84
85
  if (response.status === 200 && request.path === '/api/sessions' && Array.isArray(body.sessions)) {
85
86
  // Both startup prompt and nth_N resolution read this same browser-local
86
87
  // order, including manual drag order; archived rows cannot consume ranks.
87
- body.sessions = orderSessionCatalog(body.sessions, readWorkspaceView())
88
+ body.sessions = this.catalogOrder(body.sessions)
88
89
  }
89
90
  return { ...envelope, status: response.status, body }
90
91
  } catch (error) {
@@ -58,7 +58,7 @@
58
58
  button.secondary { background:#2c3b33;color:#dcebe3 }
59
59
  details { border-top:1px solid #303d36;margin-top:24px;padding-top:20px }
60
60
  summary { cursor:pointer;color:#c2d6c9;font-size:13px;user-select:none }
61
- #saveVoice { width:auto;min-width:150px;margin-top:12px }
61
+ #saveDuet { width:auto;min-width:150px;margin-top:12px }
62
62
  .section-note { color:#92a69b;font-size:13px;line-height:1.8;margin:0 0 18px }
63
63
  footer { font-size:12px;color:#71867a;display:flex;justify-content:space-between;margin-top:28px }
64
64
  @media(max-width:600px) { main{padding:32px 18px}.cards{grid-template-columns:1fr}.panel{padding:20px}h1{font-size:42px} }
@@ -76,7 +76,7 @@
76
76
  <h2>连接概览</h2>
77
77
  <p class="section-note">选择一种语音模式,点击当前模式即可关闭。</p>
78
78
  <div class="cards">
79
- <div class="metric"><small>当前模式</small><strong id="voiceConnection">全部关闭</strong></div>
79
+ <div class="metric"><small>当前模式</small><strong id="duetConnection">全部关闭</strong></div>
80
80
  <div class="metric"><small>服务配置</small><strong id="authState">检查中</strong></div>
81
81
  <div class="metric"><small>插件版本</small><strong id="pluginVersion">检查中</strong></div>
82
82
  <div class="metric"><small>双工模型</small><strong id="duplexModel" style="font-size:16px;overflow-wrap:anywhere">检查中</strong></div>
@@ -85,9 +85,7 @@
85
85
  <details id="advancedConnection"><summary>连接配置</summary>
86
86
  <label for="backendUrl">服务地址</label>
87
87
  <input id="backendUrl" type="url" placeholder="wss://服务地址/ws?protocol=realtime_v2" autocomplete="off">
88
- <label for="authToken">访问密钥</label>
89
- <input id="authToken" type="password" placeholder="请输入访问密钥" autocomplete="new-password" spellcheck="false">
90
- <div class="row"><button id="saveVoice" disabled>保存连接配置</button></div>
88
+ <div class="row"><button id="saveDuet" disabled>保存连接配置</button></div>
91
89
  <div id="settingsMessage" role="status" style="margin-top:10px"></div>
92
90
  </details>
93
91
  </section>
@@ -215,11 +213,11 @@
215
213
  if (!health.browser_client_connected) {
216
214
  card.classList.add("disconnected");
217
215
  $("connectionTitle").textContent = "DSH 主页面未连接";
218
- $("connectionDetail").textContent = debugEnabled ? `请打开或刷新 DSH 主页面;Duplex 当前选择:${sessionLabel(health.active_session_id)}` : '请回到 DSH 页面开启语音模式。';
216
+ $("connectionDetail").textContent = debugEnabled ? `请打开或刷新 DSH 主页面;duet 当前选择:${sessionLabel(health.active_session_id)}` : '请回到 DSH 页面开启语音模式。';
219
217
  } else if (!health.browser_focus_matches) {
220
218
  card.classList.add("mismatch");
221
219
  $("connectionTitle").textContent = "正在连接 DSH 会话";
222
- $("connectionDetail").textContent = debugEnabled ? `Duplex:${sessionLabel(health.active_session_id)} · DSH:${sessionLabel(health.browser_focus_session_id)} · 最近心跳 ${age?.toFixed(1)} 秒前` : '';
220
+ $("connectionDetail").textContent = debugEnabled ? `duet:${sessionLabel(health.active_session_id)} · DSH:${sessionLabel(health.browser_focus_session_id)} · 最近心跳 ${age?.toFixed(1)} 秒前` : '';
223
221
  } else {
224
222
  card.classList.add("connected");
225
223
  $("connectionTitle").textContent = "DSH 主页面已连接";
@@ -294,7 +292,7 @@
294
292
  };
295
293
  $("refresh").onclick = async () => Promise.all([loadSessions(), loadJobs()]);
296
294
  async function refresh() { try { await Promise.all([loadSessions(), loadJobs(), loadConnectionStatus()]); } catch (error) { showMessage(error.message, true); } }
297
- async function loadVoiceConfig(fill = false) {
295
+ async function loadDuetConfig(fill = false) {
298
296
  const config = await api('/voice/config');
299
297
  const info = await api('/voice/service-info').catch(() => ({status:'unavailable'}));
300
298
  $('duplexModel').textContent = info.status === 'ok' ? info.models.duplex : '暂不可用';
@@ -304,15 +302,13 @@
304
302
  if (fill) {
305
303
  settingsRevision = config.revision;
306
304
  $('backendUrl').value = config.backend_url || '';
307
- $('authToken').value = '';
308
- $('authToken').placeholder = config.token_placeholder;
309
305
  }
310
306
  const c = config.connection || {};
311
307
  $('duetMark').style.color = c.online || c.tts_only ? '#7fd6a6' : '#ed9b35';
312
- $('voiceConnection').textContent = c.online ? '交互模式' : c.tts_only ? '播报模式' : c.connecting ? '正在连接' : '未开启';
308
+ $('duetConnection').textContent = c.online ? '交互模式' : c.tts_only ? '播报模式' : c.connecting ? '正在连接' : '未开启';
313
309
  $('authState').textContent = config.backend_url ? '已配置' : '待配置';
314
310
  $('pluginVersion').textContent = config.plugin_version || '—';
315
- $('saveVoice').disabled = false;
311
+ $('saveDuet').disabled = false;
316
312
  $('submitFeedback').disabled = feedbackSubmitting || config.feedback_enabled !== true;
317
313
  if(config.feedback_enabled !== true)$('feedbackStatus').textContent = '反馈暂时不可用,请稍后再试。';
318
314
  else if($('feedbackStatus').textContent.startsWith('正在检查') || $('feedbackStatus').textContent.startsWith('反馈暂时'))$('feedbackStatus').textContent = '';
@@ -334,14 +330,14 @@
334
330
  } catch(error){$('feedbackStatus').textContent='提交失败,内容已保留,请稍后重试。'}
335
331
  finally{feedbackSubmitting=false;$('submitFeedback').disabled=false;$('feedbackText').disabled=false}
336
332
  };
337
- $('saveVoice').onclick = async () => {
338
- $('saveVoice').disabled = true;
333
+ $('saveDuet').onclick = async () => {
334
+ $('saveDuet').disabled = true;
339
335
  try {
340
- await api('/voice/config', {method:'PUT', headers:{'Content-Type':'application/json','X-Duplex-Settings':'1'}, body:JSON.stringify({backend_url:$('backendUrl').value.trim(), auth_token:$('authToken').value, revision:settingsRevision})});
336
+ await api('/voice/config', {method:'PUT', headers:{'Content-Type':'application/json','X-Duplex-Settings':'1'}, body:JSON.stringify({backend_url:$('backendUrl').value.trim(), revision:settingsRevision})});
341
337
  $('settingsMessage').textContent = '配置已保存;如需语音,请在 DSH 主页面重新打开。';
342
- await loadVoiceConfig(true);
338
+ await loadDuetConfig(true);
343
339
  } catch (error) { $('settingsMessage').textContent = debugEnabled ? `保存失败:${error.message}` : '保存失败,请稍后重试。'; }
344
- finally { $('saveVoice').disabled = false; }
340
+ finally { $('saveDuet').disabled = false; }
345
341
  };
346
342
  async function loadNotices() {
347
343
  const target = $('announcements');
@@ -360,7 +356,7 @@
360
356
  } catch { target.textContent = '服务通知暂时不可用。'; }
361
357
  }
362
358
  async function initialize() {
363
- await loadVoiceConfig(true);
359
+ await loadDuetConfig(true);
364
360
  if (debugEnabled) {
365
361
  await refresh();
366
362
  composerRequest('composer/get').then(composer => showComposer(composer)).catch(() => {});
@@ -370,20 +366,20 @@
370
366
  }
371
367
  $('openTutorial').onclick = async () => {
372
368
  try {
373
- const {requestTutorial} = await import('/duplex-control/deepseek_harness_voice_tutorial_request.mjs?v=0.1.0');
369
+ const {requestTutorial} = await import('/duet/assets/client/tutorial-request.mjs?v=0.1.2');
374
370
  requestTutorial(localStorage);
375
371
  $('tutorialStatus').textContent = '请回到 DSH 页面继续教学。';
376
372
  } catch { $('tutorialStatus').textContent = '暂时无法打开教学,请允许浏览器存储后重试。'; }
377
373
  };
378
374
  initialize().catch(error => { $('settingsMessage').textContent = debugEnabled ? `配置读取失败:${error.message}` : '暂时无法加载设置,请刷新重试。'; });
379
- setInterval(() => { loadVoiceConfig().catch(() => { $('voiceConnection').textContent = '语音连接信息不可用'; }); }, 2000);
375
+ setInterval(() => { loadDuetConfig().catch(() => { $('duetConnection').textContent = '语音连接信息不可用'; }); }, 2000);
380
376
  void loadNotices();
381
377
  setInterval(loadNotices, 60000);
382
- import('/duplex-control/deepseek_harness_voice_shortcuts.mjs?v=0.1.0').then(({mountShortcutSettings}) => {
378
+ import('/duet/assets/client/shortcuts.mjs?v=0.1.2').then(({mountShortcutSettings}) => {
383
379
  const dispose = mountShortcutSettings({speaker:$('speakerShortcut'),mic:$('micShortcut'),clearSpeaker:$('clearSpeakerShortcut'),clearMic:$('clearMicShortcut'),status:$('shortcutStatus')});
384
380
  window.addEventListener('pagehide', e => {if(!e.persisted)dispose()}, {once:true});
385
381
  }).catch(() => { $('shortcutStatus').textContent = '暂时无法加载快捷键设置,请刷新重试。'; });
386
- import('/duplex-control/deepseek_harness_voice_microphone.mjs?v=0.1.0').then(({mountMicrophoneSettings}) => {
382
+ import('/duet/assets/client/microphone.mjs?v=0.1.2').then(({mountMicrophoneSettings}) => {
387
383
  const dispose = mountMicrophoneSettings({select:$('microphoneDevice'),refresh:$('refreshMicrophones'),status:$('microphoneStatus')});
388
384
  window.addEventListener('pagehide', dispose, {once:true});
389
385
  }).catch(() => { $('microphoneStatus').textContent = '暂时无法加载麦克风设置,请刷新重试。'; });