@lincyaw/workbench 0.2.0-rc.101 → 0.2.0-rc.102

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/workbench",
3
- "version": "0.2.0-rc.101",
3
+ "version": "0.2.0-rc.102",
4
4
  "description": "Presmium's workbench panels in React (the documents, a document edited on its rendered page with comments and version history) with the workspace service's client and the preview protocol's workbench side; @lincyaw/dsh places them in presmium studio (experimental)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -55,8 +55,8 @@
55
55
  "@tiptap/pm": "3.32.0",
56
56
  "katex": "0.18.10",
57
57
  "react-resizable-panels": "4.14.5",
58
- "@lincyaw/design": "1.0.0-rc.101",
59
- "@lincyaw/kernel": "1.0.0-rc.101"
58
+ "@lincyaw/design": "1.0.0-rc.102",
59
+ "@lincyaw/kernel": "1.0.0-rc.102"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": "^18.3.1",
@@ -67,6 +67,6 @@
67
67
  "@types/react-dom": "18.3.7",
68
68
  "react": "^18.3.1",
69
69
  "react-dom": "^18.3.1",
70
- "@lincyaw/compiler": "1.0.0-rc.101"
70
+ "@lincyaw/compiler": "1.0.0-rc.102"
71
71
  }
72
72
  }
@@ -2,9 +2,9 @@ import type { Locale } from './messages.ts'
2
2
 
3
3
  const zh = {
4
4
  trim: '录音区间', captionReview: '字幕尚未按裁剪后的录音对齐,请核对。',
5
- title: '原音频', source: '本步原音', choose: '选择已保存音频', removedAudio: '原音频已移除', adopt: '采用为本步配音', adopted: '已采用', retryAdoption: '重试采用', cancelAdoption: '取消采用', adoptionSourceChanged: '文稿已更新,请重试。', adoptionFailed: '无法采用这段音频,请重试。', start: '开始录音', stop: '停止录音', cancel: '取消', cancelTake: '放弃本次录音', rerecord: '重新录音',
6
- audition: '试听', stopAudition: '停止试听', save: '保存为音频素材', saving: '正在保存原音…', retry: '重试', discard: '放弃候选',
7
- ready: '原音候选 · 尚未保存', imported: '已保存为音频素材', requesting: '正在等待麦克风许可', recording: '正在录音', stopping: '正在完成录音…',
5
+ title: '原音频', source: '本步原音', choose: '选择已保存音频', removedAudio: '原音频已移除', adopt: '用作配音', adopted: '已采用', retryAdoption: '重试采用', cancelAdoption: '取消采用', adoptionSourceChanged: '文稿已更新,请重试。', adoptionFailed: '无法采用这段音频,请重试。', start: '开始录音', stop: '停止录音', cancel: '取消', cancelTake: '放弃录音', rerecord: '重新录音',
6
+ audition: '试听', stopAudition: '停止试听', save: '保存音频', saving: '正在保存原音…', retry: '重试', discard: '放弃候选',
7
+ ready: '原音候选 · 尚未保存', imported: '已保存音频', requesting: '正在等待麦克风许可', recording: '正在录音', stopping: '正在完成录音…',
8
8
  cancelSave: '取消保存', currentSource: '文稿尚未保存,请先完成当前输入。', saveFailed: '无法保存原音。录音已保留,请重试。',
9
9
  discardTitle: '放弃这份原音?', discardHint: '未保存的录音将被删除,已保存的音频素材不受影响。', keep: '保留原音',
10
10
  failures: {
@@ -23,8 +23,8 @@ const zh = {
23
23
  type Messages = typeof zh
24
24
  const en: Messages = {
25
25
  trim: 'Recording range', captionReview: 'Captions are not aligned to the trimmed recording. Review them.',
26
- title: 'Original audio', source: 'Original audio for this step', choose: 'Choose Saved Audio', removedAudio: 'Original audio was removed', adopt: 'Use as Step Voiceover', adopted: 'Applied', retryAdoption: 'Retry', cancelAdoption: 'Cancel', adoptionSourceChanged: 'The document changed. Retry.', adoptionFailed: 'Couldn’t use this audio. Try again.', start: 'Start Recording', stop: 'Stop Recording', cancel: 'Cancel', cancelTake: 'Discard This Recording', rerecord: 'Record Again',
27
- audition: 'Play Sample', stopAudition: 'Stop Sample', save: 'Save as Audio Asset', saving: 'Saving original audio…', retry: 'Retry', discard: 'Discard Candidate',
26
+ title: 'Original audio', source: 'Original audio for this step', choose: 'Choose Saved Audio', removedAudio: 'Original audio was removed', adopt: 'Use Voiceover', adopted: 'Applied', retryAdoption: 'Retry', cancelAdoption: 'Cancel', adoptionSourceChanged: 'The document changed. Retry.', adoptionFailed: 'Couldn’t use this audio. Try again.', start: 'Start Recording', stop: 'Stop Recording', cancel: 'Cancel', cancelTake: 'Discard Recording', rerecord: 'Record Again',
27
+ audition: 'Play Sample', stopAudition: 'Stop Sample', save: 'Save Audio', saving: 'Saving original audio…', retry: 'Retry', discard: 'Discard Candidate',
28
28
  ready: 'Original audio candidate · Not saved', imported: 'Saved as an audio asset', requesting: 'Waiting for microphone permission', recording: 'Recording', stopping: 'Finishing recording…',
29
29
  cancelSave: 'Cancel', currentSource: 'Finish and save the current document input first.', saveFailed: 'Couldn’t save the original audio. The recording is kept; try again.',
30
30
  discardTitle: 'Discard this original audio?', discardHint: 'The recording that is not saved will be deleted. Saved audio assets are kept.', keep: 'Keep Original Audio',
@@ -20,7 +20,7 @@ export type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'>
20
20
  export type ControlDensity = 'compact' | 'regular' | 'touch'
21
21
  export type ControlProps = { density?: ControlDensity, loading?: boolean }
22
22
 
23
- export const PmButton = forwardRef<HTMLButtonElement, ButtonProps & ControlProps & { variant?: ButtonVariant, small?: boolean, icon?: IconName }>(function PmButton({ variant = 'default', small, density = small ? 'compact' : 'regular', loading, icon, type = 'button', className, children, disabled, ...rest }, ref) {
23
+ export const PmButton = forwardRef<HTMLButtonElement, ButtonProps & ControlProps & { variant?: ButtonVariant, small?: boolean, icon?: IconName }>(function PmButton({ variant = 'default', small, density = 'compact', loading, icon, type = 'button', className, children, disabled, ...rest }, ref) {
24
24
  return (
25
25
  <button {...rest} ref={ref} type={type} data-density={density} aria-busy={loading || undefined} disabled={disabled || loading || rest['aria-disabled'] === true || rest['aria-disabled'] === 'true'} className={cls('pm-ui-button', variant !== 'default' && `pm-ui-button--${variant}`, className)}>
26
26
  <span className={cls('pm-ui-button__content', !icon && loading !== undefined && 'pm-ui-button__content--loading-text')}>{(icon || loading !== undefined) && <span aria-hidden="true" className={cls('pm-ui-button__icon', loading && 'pm-ui-loading')}>{loading ? <PmIcon name="loading" /> : icon && <PmIcon name={icon} />}</span>}{children}</span>
@@ -39,7 +39,7 @@ export function PmTooltip({ label, shortcut, children }: { label: string, shortc
39
39
  )
40
40
  }
41
41
 
42
- export const PmIconButton = forwardRef<HTMLButtonElement, ButtonProps & ControlProps & { icon: IconName, label: string, hint?: string, shortcut?: string, small?: boolean, tooltip?: boolean }>(function PmIconButton({ icon, label, hint, shortcut, small, tooltip = true, density = small ? 'compact' : 'regular', loading, className, disabled, ...rest }, ref) {
42
+ export const PmIconButton = forwardRef<HTMLButtonElement, ButtonProps & ControlProps & { icon: IconName, label: string, hint?: string, shortcut?: string, small?: boolean, tooltip?: boolean }>(function PmIconButton({ icon, label, hint, shortcut, small, tooltip = true, density = 'compact', loading, className, disabled, ...rest }, ref) {
43
43
  const button = <button {...rest} ref={ref} type="button" data-density={density} aria-label={label} aria-busy={loading || undefined} disabled={disabled || loading || rest['aria-disabled'] === true || rest['aria-disabled'] === 'true'} className={cls('pm-ui-icon-button', className)}>
44
44
  <span className={cls('pm-ui-button__content', loading && 'pm-ui-loading')}><PmIcon name={loading ? 'loading' : icon} /></span>
45
45
  </button>
@@ -1,12 +1,12 @@
1
1
  export const CAPTION_TIMING_MESSAGES = {
2
2
  'zh-CN': {
3
- title: '手动字幕时间', open: '设置字幕时间', cancel: '取消', done: '完成', apply: '应用', automatic: '使用自动时间', split: '按换行分段',
3
+ title: '手动字幕时间', open: '字幕时间', cancel: '取消', done: '完成', apply: '应用', automatic: '自动时间', split: '按换行分段',
4
4
  start: '开始(秒)', end: '结束(秒)', step: '本步骤 · 时间从步骤起点计算', invalid: '时间须递增且不超出本步骤。',
5
5
  loading: '正在加载字幕时间…', prepare: '请先准备当前步骤。', unavailable: '当前步骤的字幕时间不可用。', changed: '讲稿或音频已变化。', recheck: '再次检查', saved: '字幕时间已保存到当前步骤。',
6
6
  failed: '无法确认字幕时间已保存。输入已保留,请重试。', storageFailed: '无法备份字幕时间,请保持此页面打开。', discard: '放弃修改', limit: '本次最多设置 32 段。', segment: (n: number) => `字幕 ${n}`,
7
7
  },
8
8
  en: {
9
- title: 'Manual Caption Timing', open: 'Set Caption Times', cancel: 'Cancel', done: 'Done', apply: 'Apply', automatic: 'Use Automatic Times', split: 'Split at Line Breaks',
9
+ title: 'Manual Caption Timing', open: 'Caption Timing', cancel: 'Cancel', done: 'Done', apply: 'Apply', automatic: 'Auto Timing', split: 'Split at Line Breaks',
10
10
  start: 'Start (seconds)', end: 'End (seconds)', step: 'Current step · Times start at the step boundary', invalid: 'Times must increase and fit inside this step.',
11
11
  loading: 'Loading caption times…', prepare: 'Prepare the current step first.', unavailable: 'Caption timing is unavailable for this step.', changed: 'The script or audio has changed.', recheck: 'Check Again', saved: 'Caption times saved to this step.',
12
12
  failed: 'Couldn’t confirm that caption times were saved. Your input is kept; try again.', storageFailed: 'Couldn’t back up caption times. Keep this page open.', discard: 'Discard Changes', limit: 'Set no more than 32 segments at once.', segment: (n: number) => `Caption ${n}`,
package/src/index.ts CHANGED
@@ -37,3 +37,6 @@ export { connectAuthoringWindow } from './authoring-window.ts'
37
37
  export { connectAgentActivity } from './agent-activity.ts'
38
38
  export { AgentActivityBar } from './AgentActivityBar.tsx'
39
39
  export { SHORTCUTS } from './shortcuts.ts'
40
+
41
+ export { McpSettingsPanel } from './panels/McpSettingsPanel.tsx'
42
+ export { MCP_SETTINGS_MESSAGES } from './mcp-settings-messages.ts'
@@ -0,0 +1,37 @@
1
+ const zh = {
2
+ title: 'MCP 连接', description: '让 AI 连接当前工作区,操作会实时显示在应用中。',
3
+ transport: '连接方式', stdio: 'stdio(推荐)', http: 'HTTP',
4
+ stdioHint: 'AI 客户端按需启动连接,无需预留端口。与桌面应用共享同一个工作区服务。',
5
+ httpHint: '为外部 AI 开启本机 HTTP 连接。更改端口不会改变编辑器地址。',
6
+ local: '这些配置用于运行 Presmium 的这台电脑。远程使用时,请在 AI 所在电脑安装 Presmium 后配置 stdio,或通过受保护的转发使用 HTTP。',
7
+ port: '端口', portHint: '填 0 自动分配可用端口;也可填写 1–65535 的固定端口。',
8
+ address: '当前连接地址', save: '应用', saved: '配置已应用。', loading: '正在加载连接配置…',
9
+ copyConfig: '复制配置', copyPrompt: '复制提示词', copied: '已复制。',
10
+ output: '复制内容', manualCopy: '无法自动复制,请从下面的文本框手动复制。',
11
+ unavailable: '暂时无法读取连接配置,请重试。', retry: '重试', failed: '配置未能应用,当前连接仍可使用。',
12
+ portBusy: '该端口无法使用,请选择其他端口,或填 0 自动分配。',
13
+ conflict: '配置已在其他窗口更新,请重新读取后再修改。', invalid: '请输入 0–65535 的整数端口。',
14
+ noCommand: '当前服务没有可用的本机启动命令,请使用 HTTP 连接。',
15
+ applyFirst: '先应用修改,再复制与当前连接一致的配置。',
16
+ prompt: '请帮我为当前 AI 客户端配置 Presmium MCP。保留已有 MCP 服务,只新增或更新名为 presmium 的连接;先找到客户端的官方配置格式,将下面的通用 MCP 配置转换后写入,再验证连接和读取工作区。不要扩大操作权限,也不要提交凭据。工作区:{root}。',
17
+ httpPrompt: '使用 Streamable HTTP,地址:{url}。在运行 Presmium 的本机读取 {stateFile},仅使用其中 token 字段作为 Authorization: Bearer 的值,不要使用 launcherToken。不要把凭据输出到对话或提交到仓库。此地址需要 Presmium 工作区服务运行;服务重启后如端口或访问令牌变化,请重新读取配置。',
18
+ }
19
+ const en: typeof zh = {
20
+ title: 'MCP Connection', description: 'Connect AI to this workspace and see its actions live in the app.',
21
+ transport: 'Transport', stdio: 'stdio (recommended)', http: 'HTTP',
22
+ stdioHint: 'The AI client starts its connection on demand without reserving a port. It shares the workspace service with the desktop app.',
23
+ httpHint: 'Enable a local HTTP connection for external AI clients. Changing its port leaves the editor address unchanged.',
24
+ local: 'These settings are for the computer running Presmium. For remote use, install Presmium on the AI client computer for stdio, or use protected forwarding for HTTP.',
25
+ port: 'Port', portHint: 'Use 0 to choose an available port, or 1–65535 for a fixed port.',
26
+ address: 'Current endpoint', save: 'Apply', saved: 'Settings applied.', loading: 'Loading connection settings…',
27
+ copyConfig: 'Copy Config', copyPrompt: 'Copy Prompt', copied: 'Copied.',
28
+ output: 'Copy Content', manualCopy: 'Automatic copying failed. Copy the text below manually.',
29
+ unavailable: 'Connection settings are unavailable. Please retry.', retry: 'Retry', failed: 'Settings could not be applied. The current connection remains available.',
30
+ portBusy: 'This port is unavailable. Choose another port or use 0 to assign one automatically.',
31
+ conflict: 'Another window updated these settings. Reload before editing.', invalid: 'Enter an integer port from 0 to 65535.',
32
+ noCommand: 'This service has no local launch command. Use HTTP instead.',
33
+ applyFirst: 'Apply your changes before copying the current connection configuration.',
34
+ prompt: 'Configure Presmium MCP for this AI client. Preserve existing MCP servers and only add or update the connection named presmium. Find the official client configuration format, adapt the generic MCP configuration below, save it, then verify the connection and read the workspace. Do not broaden permissions or save credentials in the repository. Workspace: {root}.',
35
+ httpPrompt: 'Use Streamable HTTP at {url}. On the computer running Presmium, read {stateFile} and use only its token field as Authorization: Bearer; never use launcherToken. Do not print credentials in the chat or save them in the repository. The Presmium workspace service must be running. If the port or token changes after a restart, read the settings again.',
36
+ }
37
+ export const MCP_SETTINGS_MESSAGES = { 'zh-CN': zh, en }
@@ -382,7 +382,7 @@ function DocumentToolbar({ narrow, presentButton, framed, onBack, actions, aside
382
382
  <SaveStatus />
383
383
  <span className="pmw-spacer" />
384
384
  {!narrow && <>
385
- {capabilities?.production !== false && <PmToolbarButton asChild><PmButton small icon="arrange" loading={changingView} disabled={busy || !hasStep} onClick={onProduction}>{p.title}</PmButton></PmToolbarButton>}
385
+ {capabilities?.production !== false && <PmToolbarButton asChild><PmButton small icon="arrange" loading={changingView} disabled={busy || !hasStep} onClick={onProduction}>{t.video}</PmButton></PmToolbarButton>}
386
386
  {capabilities?.narration !== false && <PmToolbarButton asChild><PmIconButton small icon="captions" label={t.documentNarration} hint={t.documentNarrationHint} aria-pressed={aside === 'narration'} disabled={!hasStep} onClick={() => onAside('narration')} /></PmToolbarButton>}
387
387
  </>}
388
388
  {!compactCommands && <PmToolbarButton asChild><PmIconButton small icon="comment" label={commentsLabel} aria-pressed={aside === 'comments'} onClick={() => onAside('comments')} /></PmToolbarButton>}
@@ -0,0 +1,84 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+ import type { McpConnectionSettings } from '@lincyaw/kernel'
3
+ import { PmButton, PmCard, PmInput, PmNotice, PmPanelHeader, PmSelect, PmTextarea } from '../components.tsx'
4
+ import { useWorkbench, useWorkbenchState } from '../context.tsx'
5
+ import { MCP_SETTINGS_MESSAGES } from '../mcp-settings-messages.ts'
6
+ import { WorkspaceServerError } from '../workspace-client.ts'
7
+
8
+ export function McpSettingsPanel() {
9
+ const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), t = MCP_SETTINGS_MESSAGES[locale]
10
+ const [settings, setSettings] = useState<McpConnectionSettings>(), [transport, setTransport] = useState<'stdio' | 'http'>('stdio'), [port, setPort] = useState('0')
11
+ const [busy, setBusy] = useState(false), [failure, setFailure] = useState<string>(), [status, setStatus] = useState<string>(), [output, setOutput] = useState('')
12
+ const owner = useRef(true), request = useRef<AbortController>()
13
+ const accept = (value: McpConnectionSettings) => { setSettings(value); setTransport(value.transport); setPort(String(value.port)); setOutput('') }
14
+ const load = async () => {
15
+ request.current?.abort(); const controller = new AbortController(); request.current = controller
16
+ setBusy(true); setFailure(undefined); setStatus(undefined)
17
+ try {
18
+ if (!workbench.client.readMcpSettings) throw new Error('unsupported')
19
+ const value = await workbench.client.readMcpSettings(controller.signal)
20
+ if (owner.current && !controller.signal.aborted) accept(value)
21
+ } catch { if (owner.current && !controller.signal.aborted) setFailure(t.unavailable) }
22
+ finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
23
+ }
24
+ useEffect(() => { owner.current = true; void load(); return () => { owner.current = false; request.current?.abort() } }, [workbench])
25
+ const dirty = settings && (transport !== settings.transport || Number(port) !== settings.port)
26
+ const valid = /^\d+$/.test(port) && Number(port) <= 65535
27
+ const save = async () => {
28
+ if (!settings || !valid || !workbench.client.changeMcpSettings) return
29
+ request.current?.abort(); const controller = new AbortController(); request.current = controller
30
+ setBusy(true); setFailure(undefined); setStatus(undefined); setOutput('')
31
+ try {
32
+ const value = await workbench.client.changeMcpSettings({ revision: settings.revision, transport, port: Number(port) }, controller.signal)
33
+ if (owner.current && !controller.signal.aborted) { accept(value); setStatus(t.saved) }
34
+ } catch (error) {
35
+ if (owner.current && !controller.signal.aborted) {
36
+ const code = error instanceof WorkspaceServerError ? error.answer.error : undefined
37
+ setFailure(code === 'mcp-port-unavailable' ? t.portBusy : code === 'mcp-settings-conflict' ? t.conflict : t.failed)
38
+ }
39
+ } finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
40
+ }
41
+ const copy = async (prompt: boolean) => {
42
+ if (!settings || dirty || !workbench.client.exportMcpSettings || !workbench.client.readMcpSettings) return
43
+ setBusy(true); setFailure(undefined); setStatus(undefined)
44
+ request.current?.abort(); const controller = new AbortController(); request.current = controller
45
+ try {
46
+ const fresh = await workbench.client.readMcpSettings(controller.signal)
47
+ if (!owner.current || controller.signal.aborted) return
48
+ accept(fresh)
49
+ const content = prompt ? t.prompt.replace('{root}', fresh.root) + '\n\n' + (fresh.transport === 'stdio'
50
+ ? JSON.stringify({ mcpServers: { presmium: fresh.stdio } }, null, 2)
51
+ : t.httpPrompt.replace('{url}', fresh.url ?? '').replace('{stateFile}', fresh.stateFile))
52
+ : JSON.stringify(await workbench.client.exportMcpSettings(fresh.revision, controller.signal), null, 2)
53
+ if (!owner.current || controller.signal.aborted) return
54
+ setOutput(content)
55
+ try { await navigator.clipboard.writeText(content); if (owner.current) setStatus(t.copied) }
56
+ catch { if (owner.current) setStatus(t.manualCopy) }
57
+ } catch (error) { if (owner.current && !controller.signal.aborted) setFailure(error instanceof WorkspaceServerError && error.answer.error === 'mcp-settings-conflict' ? t.conflict : t.failed) }
58
+ finally { if (owner.current && !controller.signal.aborted) setBusy(false) }
59
+ }
60
+ const ready = settings && !dirty && (settings.transport === 'stdio' ? settings.stdio : settings.url)
61
+ return <section className="pmw-speech-settings pm-ui" aria-label={t.title}>
62
+ <PmPanelHeader title={t.title} />
63
+ <div className="pmw-speech-settings__content">
64
+ <p>{t.description}</p>
65
+ {!settings && busy && <PmNotice>{t.loading}</PmNotice>}
66
+ {failure && <PmNotice tone="danger">{failure} <PmButton small disabled={busy} onClick={() => void load()}>{t.retry}</PmButton></PmNotice>}
67
+ {status && <PmNotice tone="accent">{status}</PmNotice>}
68
+ {settings && <PmCard><div className="pmw-speech-settings__fields">
69
+ <PmSelect label={t.transport} hint={transport === 'stdio' ? t.stdioHint : t.httpHint} value={transport} disabled={busy} onChange={event => { setTransport(event.target.value as 'stdio' | 'http'); setStatus(undefined); setOutput('') }}>
70
+ <option value="stdio" disabled={!settings.stdio}>{t.stdio}</option><option value="http">{t.http}</option>
71
+ </PmSelect>
72
+ {!settings.stdio && <PmNotice>{t.noCommand}</PmNotice>}
73
+ {transport === 'http' && <PmInput label={t.port} hint={t.portHint} error={valid ? undefined : t.invalid} inputMode="numeric" value={port} disabled={busy} onChange={event => { setPort(event.target.value); setStatus(undefined); setOutput('') }} />}
74
+ {settings.url && <PmInput label={t.address} value={settings.url} readOnly />}
75
+ {settings.issue && <PmNotice tone="danger">{t.portBusy}</PmNotice>}
76
+ <div className="pmw-speech-settings__actions"><PmButton small variant="accent" disabled={busy || !valid || !dirty && !settings.issue} onClick={() => void save()}>{t.save}</PmButton></div>
77
+ </div></PmCard>}
78
+ <p>{t.local}</p>
79
+ {dirty && <PmNotice>{t.applyFirst}</PmNotice>}
80
+ <div className="pmw-speech-settings__actions"><PmButton small variant="ghost" icon="copy" disabled={busy || !ready} onClick={() => void copy(false)}>{t.copyConfig}</PmButton><PmButton small variant="ghost" icon="sparkle" disabled={busy || !ready} onClick={() => void copy(true)}>{t.copyPrompt}</PmButton></div>
81
+ {output && <PmTextarea label={t.output} readOnly rows={10} value={output} onFocus={event => event.target.select()} />}
82
+ </div>
83
+ </section>
84
+ }
@@ -53,7 +53,7 @@ export function SpeechSettingsPanel() {
53
53
  {settings && <p>{t.source[settings.source]}</p>}
54
54
  <PmInput type="password" label={t.key} hint={t.keyHint} placeholder={settings?.configured ? t.keySaved : t.keyPlaceholder} value={key} disabled={disabled} autoComplete="new-password" spellCheck={false} maxLength={8192} onChange={event => { dirty.current = Boolean(event.target.value.trim() || appId.trim()); setKey(event.target.value); setStatus(undefined) }} />
55
55
  <PmInput label={t.appId} hint={t.appIdHint} placeholder={settings?.appIdConfigured ? t.keySaved : t.appIdPlaceholder} value={appId} disabled={disabled} autoComplete="off" inputMode="numeric" spellCheck={false} maxLength={32} onChange={event => { dirty.current = Boolean(event.target.value.trim() || key.trim()); setAppId(event.target.value); setStatus(undefined) }} />
56
- <div className="pmw-speech-settings__actions"><PmButton variant="accent" loading={busy} disabled={disabled || !key.trim() && !settings?.configured} onClick={() => void save()}>{t.save}</PmButton><PmButton disabled={busy || loading || dirty.current} onClick={() => void load(true)}>{t.check}</PmButton></div>
56
+ <div className="pmw-speech-settings__actions"><PmButton small variant="accent" loading={busy} disabled={disabled || !key.trim() && !settings?.configured} onClick={() => void save()}>{t.save}</PmButton><PmButton small variant="ghost" disabled={busy || loading || dirty.current} onClick={() => void load(true)}>{t.check}</PmButton></div>
57
57
  </div></PmCard>
58
58
  <PmNotice>{t.verification}</PmNotice>
59
59
  <p>{t.privacy}</p>
@@ -6,14 +6,14 @@ const zh = {
6
6
  key: '语音密钥', keyPlaceholder: '输入 API Key 或 Access Token', keySaved: '已配置,留空保留',
7
7
  keyHint: '使用语音 API Key,或与 App ID 配套的 Access Token。',
8
8
  appId: 'App ID(可选)', appIdPlaceholder: '使用 API Key 时留空', appIdHint: '使用 Access Token 时填写对应 App ID;不需要 Secret Key。输入新的密钥且留空此项时,使用 API Key。',
9
- console: '打开语音控制台',
9
+ console: '服务控制台',
10
10
  source: { saved: '使用本机保存的密钥', environment: '使用启动环境中的密钥', none: '尚未配置密钥' },
11
11
  configured: '已配置,尚未验证服务权限', unconfigured: '未配置',
12
12
  verification: '检查配置仅检查已保存的本机设置,服务权限在播放或试听时验证。请先开通语音合成服务;播放会按需生成并缓存配音,可能产生服务费用。',
13
13
  privacy: '密钥仅保存在本机此工作区的服务配置中,不写入讲义。',
14
- check: '检查配置', save: '保存', saved: '语音服务已保存,无需重启。', checked: '本机配置可用。请通过试听验证服务权限。',
15
- remove: '清除已保存密钥', removeTitle: '清除语音服务密钥', removeHint: '清除本机保存的密钥后恢复启动环境中的配置;讲稿、音色选择和已有配音保留。', cancel: '取消',
16
- cleared: '已清除本机保存的密钥。', retry: '重新加载', loading: '正在加载语音服务设置…',
14
+ check: '检查', save: '保存', saved: '语音服务已保存,无需重启。', checked: '本机配置可用。请通过试听验证服务权限。',
15
+ remove: '清除密钥', removeTitle: '清除语音服务密钥', removeHint: '清除本机保存的密钥后恢复启动环境中的配置;讲稿、音色选择和已有配音保留。', cancel: '取消',
16
+ cleared: '已清除本机保存的密钥。', retry: '重试', loading: '正在加载语音服务设置…',
17
17
  unavailable: '无法读取语音服务设置,请重试。', invalid: '请输入有效的语音密钥和对应 App ID。',
18
18
  conflict: '设置已在别处更新。当前输入已保留,请重新加载后再保存。', busy: '设置正在被更新,请稍后重试。',
19
19
  failed: '无法保存语音服务设置。当前输入已保留,请重试。',
@@ -31,7 +31,7 @@ export const SPEECH_SETTINGS_MESSAGES: Record<Locale, typeof zh> = {
31
31
  configured: 'Configured; service permissions not verified', unconfigured: 'Not configured',
32
32
  verification: 'Checking configuration checks saved local settings. Playback or a sample verifies service permissions. Enable speech synthesis first; playback generates and caches missing voiceover and may incur service charges.',
33
33
  privacy: 'The key stays in this workspace’s service settings on this machine, outside the document.',
34
- check: 'Check Configuration', save: 'Save', saved: 'Voice service saved. No restart is needed.', checked: 'Local settings are available. Play a sample to verify service permissions.',
34
+ check: 'Check', save: 'Save', saved: 'Voice service saved. No restart is needed.', checked: 'Local settings are available. Play a sample to verify service permissions.',
35
35
  remove: 'Clear Saved Key', removeTitle: 'Clear Voice Service Key', removeHint: 'Clearing the saved key restores the launch environment configuration. Scripts, voice choices, and generated audio are kept.', cancel: 'Cancel',
36
36
  cleared: 'The saved key was cleared.', retry: 'Reload', loading: 'Reading voice service settings…',
37
37
  unavailable: 'Couldn’t read voice service settings. Try again.', invalid: 'Enter a valid speech key and matching App ID.',
@@ -31,21 +31,21 @@ const zh = {
31
31
  auditionFailed: '无法试听,请重试。音色设置未更改。',
32
32
  pauseUnavailable: '预览尚不支持暂停播放,暂时无法试听。请重新加载文稿。',
33
33
  pauseTimeout: '无法确认播放已暂停,请重试。',
34
- changed: '文稿或音色设置已更新。草稿已保留,请按当前步骤重新检查应用范围。',
34
+ changed: '文稿或音色设置已更新。草稿已保留,请重新检查范围。',
35
35
  draftRecovered: '已恢复尚未应用的音色设置草稿,请检查范围后应用。', recoveryFailed: '无法在此浏览器保留音色草稿,请在关闭前应用或复制设置。',
36
- recheck: '按当前步骤重新检查', scope: '应用范围', scopes: { step: '当前步骤', steps: '所选步骤', page: '当前页', document: '整份文稿' },
36
+ recheck: '重新检查', scope: '应用范围', scopes: { step: '当前步骤', steps: '所选步骤', page: '当前页', document: '整份文稿' },
37
37
  selectedSteps: '选择步骤', step: (page: number, step: number) => `第 ${page} 页,步骤 ${step}`,
38
38
  selected: (count: number) => `已选择 ${count} 个步骤`, inherit: '使用继承的音色', inheritHint: '改用最近的页面或文稿默认音色。',
39
39
  pageScript: (page: number) => `第 ${page} 页,关联讲稿(按页生成)`,
40
40
  replace: '已有覆盖', preserve: '保留独立设置', replaceAll: '替换独立设置',
41
41
  counts: (updated: number, preserved: number) => `将更新 ${updated} 个步骤,保留 ${preserved} 个独立设置。`,
42
- check: '检查应用范围', checking: '正在检查应用范围…', apply: '应用设置', saved: '音色设置已保存。', cachedPreview: '本次使用已有配音缓存。', clearDefault: '清除文稿默认音色',
42
+ check: '检查范围', checking: '正在检查范围…', apply: '应用', saved: '音色设置已保存。', cachedPreview: '本次使用已有配音缓存。', clearDefault: '清除默认音色',
43
43
  rate: '语速', rateInvalid: (min: number, max: number) => `请输入 ${min}–${max} 之间的数值。`, style: '朗读风格', styleDefault: '服务默认',
44
44
  cueStep: '此讲稿包含跨步骤提示,暂不支持单独覆盖音色。可设置页面或文稿默认音色。',
45
45
  disclosure: (provider: string, local: boolean) => local ? `本次在本机通过 ${provider} 合成。` : `本次将所示讲稿发送至 ${provider} 合成配音。`,
46
- confirmPreview: '确认并试听', sampleText: '标准示例文本', source: '声音来源', previewHint: '确认后播放已有缓存或请求合成;选择音色本身不会生成配音。',
46
+ confirmPreview: '试听', sampleText: '标准示例文本', source: '声音来源', previewHint: '确认后播放已有缓存或请求合成;选择音色本身不会生成配音。',
47
47
  refreshing: '正在加载配音状态…', refresh: '刷新状态', missingOnly: '只生成缺失与需要更新的片段',
48
- confirmGenerate: '确认并生成', cancelJob: '取消生成', oldVersion: '较早文稿版本', noScript: '当前范围没有可生成的讲稿。',
48
+ confirmGenerate: '生成配音', cancelJob: '取消生成', oldVersion: '较早文稿版本', noScript: '当前范围没有可生成的讲稿。',
49
49
  statuses: { ready: '可播放', missing: '需要生成', blocked: '暂不可生成', empty: '没有讲稿' },
50
50
  jobs: { queued: '等待生成', running: '正在生成', cancelling: '正在取消', cancelled: '已取消', done: '已完成', failed: '生成失败', stale: '文稿已更新' },
51
51
  progress: (done: number, total: number, failed: number) => `已完成 ${done} / ${total}${failed ? `,失败 ${failed}` : ''}`,
@@ -89,19 +89,19 @@ const en: VoiceMessages = {
89
89
  pauseTimeout: 'Couldn’t confirm that playback paused. Try again.',
90
90
  changed: 'The document or voice settings changed. Your draft is kept; check the scope again for the current step.',
91
91
  draftRecovered: 'Your draft voice settings were recovered. Check the scope before applying them.', recoveryFailed: 'Voice drafts can’t be kept in this browser. Apply or copy your settings before closing.',
92
- recheck: 'Check Again for Current Step', scope: 'Apply to', scopes: { step: 'Current step', steps: 'Selected steps', page: 'Current page', document: 'Entire document' },
92
+ recheck: 'Recheck', scope: 'Apply to', scopes: { step: 'Current step', steps: 'Selected steps', page: 'Current page', document: 'Entire document' },
93
93
  selectedSteps: 'Select Steps', step: (page, step) => `Page ${page}, step ${step}`, selected: count => `${count} steps selected`,
94
94
  pageScript: page => `Page ${page}, linked script (generate by page)`,
95
95
  inherit: 'Use Inherited Voice', inheritHint: 'Use the nearest page or document default voice.',
96
96
  replace: 'Existing overrides', preserve: 'Keep independent settings', replaceAll: 'Replace independent settings',
97
97
  counts: (updated, preserved) => `${updated} steps will update; ${preserved} independent settings will be kept.`,
98
- check: 'Check Scope', checking: 'Checking scope…', apply: 'Apply Settings', saved: 'Voice settings saved.', cachedPreview: 'This preview uses an existing voiceover cache.', clearDefault: 'Clear Document Default Voice',
98
+ check: 'Check Scope', checking: 'Checking scope…', apply: 'Apply', saved: 'Voice settings saved.', cachedPreview: 'This preview uses an existing voiceover cache.', clearDefault: 'Clear Default Voice',
99
99
  rate: 'Speaking rate', rateInvalid: (min, max) => `Enter a number between ${min} and ${max}.`, style: 'Reading style', styleDefault: 'Service default',
100
100
  cueStep: 'This script has cues across steps. A step voice override is not supported yet; set a page or document default instead.',
101
101
  disclosure: (provider, local) => local ? `The voiceover is generated on this device with ${provider}.` : `The script shown is sent to ${provider} to generate the voiceover.`,
102
- confirmPreview: 'Confirm and Play Sample', sampleText: 'Standard sample text', source: 'Voice source', previewHint: 'After you confirm, a saved voiceover plays or a new one is generated. Choosing a voice doesn’t generate voiceover.',
102
+ confirmPreview: 'Play Sample', sampleText: 'Standard sample text', source: 'Voice source', previewHint: 'After you confirm, a saved voiceover plays or a new one is generated. Choosing a voice doesn’t generate voiceover.',
103
103
  refreshing: 'Loading voiceover status…', refresh: 'Refresh Status', missingOnly: 'Generate only missing clips and clips that need updating',
104
- confirmGenerate: 'Confirm and Generate', cancelJob: 'Cancel Generating', oldVersion: 'Earlier document version', noScript: 'There is no script to generate in this scope.',
104
+ confirmGenerate: 'Generate', cancelJob: 'Cancel Generating', oldVersion: 'Earlier document version', noScript: 'There is no script to generate in this scope.',
105
105
  statuses: { ready: 'Playable', missing: 'Needs generation', blocked: 'Unavailable', empty: 'No script' },
106
106
  jobs: { queued: 'Queued', running: 'Generating', cancelling: 'Canceling', cancelled: 'Canceled', done: 'Completed', failed: 'Generation failed', stale: 'Document changed' },
107
107
  progress: (done, total, failed) => `${done} / ${total} completed${failed ? `; ${failed} failed` : ''}`,
@@ -1,3 +1,4 @@
1
+ import type { McpConnectionSettings, McpConnectionChange } from '@lincyaw/kernel'
1
2
  import type { ProjectOperation, ProjectPlan, ProjectPlanRequest, ProjectApply, ProjectApplied } from '@lincyaw/kernel'
2
3
  import type { PreviewEventSubscription } from '@lincyaw/kernel'
3
4
  import type { SpeechSettingsAnswer, SpeechSettingsChange } from '@lincyaw/kernel'
@@ -65,6 +66,9 @@ export interface WorkspaceCapabilities {
65
66
  }
66
67
 
67
68
  export interface WorkspaceClient {
69
+ readMcpSettings?(signal?: AbortSignal): Promise<McpConnectionSettings>
70
+ changeMcpSettings?(change: McpConnectionChange, signal?: AbortSignal): Promise<McpConnectionSettings>
71
+ exportMcpSettings?(revision: string, signal?: AbortSignal): Promise<unknown>
68
72
  subscribeAgentActivity?(received: (snapshot: import('@lincyaw/kernel').AgentActivitySnapshot) => void, failed: () => void): () => void
69
73
  readSpeechSettings?(signal?: AbortSignal): Promise<SpeechSettingsAnswer>
70
74
  changeSpeechSettings?(change: SpeechSettingsChange, signal?: AbortSignal): Promise<SpeechSettingsAnswer>
@@ -401,6 +405,9 @@ export function workspaceClient(base = 'api/presmium/', subscription?: Workspace
401
405
  subscribeDocument: (document, changed, failed) => subscribe(url('document/events', document), 'document', changed, failed),
402
406
  readPageDeletion: (document, section) => call(url('pages/delete', document, { section })),
403
407
  deletePage: (document, request) => post(url('pages/delete', document), request),
408
+ readMcpSettings: signal => call(url('mcp-settings'), { signal }),
409
+ changeMcpSettings: (change, signal) => post(url('mcp-settings'), change, signal),
410
+ exportMcpSettings: (revision, signal) => post(url('mcp-settings'), { action: 'export', revision }, signal),
404
411
  readSpeechSettings: signal => call(url('speech-settings'), { signal }),
405
412
  changeSpeechSettings: (change, signal) => post(url('speech-settings'), change, signal),
406
413
  readVoiceCatalog: (document, engine, lang, signal) => call(url('voice-catalog', document, { ...engine ? { engine } : {}, ...lang ? { lang } : {} }), { signal }),