Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Restore synced surfaces and speech settings

wyt23d95f683c2f
diff --git a/src/main/features/auth.ts b/src/main/features/auth.ts
index 1f5959a0..f1e619f7 100644
--- a/src/main/features/auth.ts
+++ b/src/main/features/auth.ts
@@ -240,14 +240,32 @@ export interface VideoProfile {
createdAt: number;
}
+/** BYO text-to-speech provider. Open-source builds only store user-owned keys:
+ * - OpenAI-compatible `/audio/speech`: `baseUrl`, `model`, bearer `apiKey`.
+ * - `doubao`: V3 X-Api-Key plus optional `resourceId` and speaker `voice`.
+ * `voice`/`format` are per-request defaults for downstream speech tools. */
+export interface TtsProfile {
+ id: string;
+ provider: string; // openai | doubao | elevenlabs | custom
+ baseUrl: string; // e.g. https://api.openai.com/v1
+ model: string; // OpenAI-compatible TTS model id ('' for doubao)
+ apiKey: string; // bearer key, or doubao V3 X-Api-Key
+ resourceId?: string; // doubao only: optional X-Api-Resource-Id override
+ voice?: string; // default voice id / voice_type
+ format?: string; // default response_format / encoding
+ label: string;
+ createdAt: number;
+}
+
interface ProfilesFile {
- /** v3 = chat profiles only. v4 adds BYO search / image / video profiles. */
+ /** v3 = chat profiles only. v4 adds BYO search / image / video / speech profiles. */
version: number;
profiles: Record<string, StoredProfile>;
entries: Entry[];
searchProfiles?: SearchProfile[];
imageProfiles?: ImageProfile[];
videoProfiles?: VideoProfile[];
+ ttsProfiles?: TtsProfile[];
}
const PROFILES_FILE_VERSION = 4;
@@ -351,7 +369,8 @@ function loadProfiles(): ProfilesFile {
const searchProfiles = parseSearchProfilesArray((data as any).searchProfiles);
const imageProfiles = parseImageProfilesArray((data as any).imageProfiles);
const videoProfiles = parseVideoProfilesArray((data as any).videoProfiles);
- const store = { version: PROFILES_FILE_VERSION, profiles, entries, searchProfiles, imageProfiles, videoProfiles };
+ const ttsProfiles = parseTtsProfilesArray((data as any).ttsProfiles);
+ const store = { version: PROFILES_FILE_VERSION, profiles, entries, searchProfiles, imageProfiles, videoProfiles, ttsProfiles };
if (needsRewrite) saveProfiles(store);
return store;
}
@@ -360,7 +379,7 @@ function loadProfiles(): ProfilesFile {
log.warn('failed to load profiles store:', (err as Error).message);
}
}
- return { version: PROFILES_FILE_VERSION, profiles: {}, entries: [], searchProfiles: [], imageProfiles: [], videoProfiles: [] };
+ return { version: PROFILES_FILE_VERSION, profiles: {}, entries: [], searchProfiles: [], imageProfiles: [], videoProfiles: [], ttsProfiles: [] };
}
function parseSearchProfilesArray(arr: unknown): SearchProfile[] {
@@ -418,10 +437,37 @@ function parseVideoProfilesArray(arr: unknown): VideoProfile[] {
return out;
}
-// ── Search / Image / Video profiles store IO (low-level) ─────────────────
+function parseTtsProfilesArray(arr: unknown): TtsProfile[] {
+ if (!Array.isArray(arr)) return [];
+ const out: TtsProfile[] = [];
+ for (const raw of arr) {
+ const p = raw as any;
+ if (!p || typeof p !== 'object' || !p.id || !p.provider || !p.apiKey) continue;
+ const provider = String(p.provider || 'custom');
+ if (provider === 'orkas-voice') continue;
+ if (provider !== 'doubao' && !p.baseUrl) continue;
+ if (provider !== 'doubao' && !p.model) continue;
+ out.push({
+ id: String(p.id),
+ provider,
+ baseUrl: String(p.baseUrl || ''),
+ model: String(p.model || ''),
+ apiKey: String(p.apiKey),
+ ...(p.resourceId ? { resourceId: String(p.resourceId) } : {}),
+ ...(p.voice ? { voice: String(p.voice) } : {}),
+ ...(p.format ? { format: String(p.format) } : {}),
+ label: String(p.label || 'default'),
+ createdAt: typeof p.createdAt === 'number' ? p.createdAt : Date.now(),
+ });
+ }
+ return out;
+}
+
+// ── Search / Image / Video / TTS profiles store IO (low-level) ────────────
//
// These helpers expose the new top-level fields so feature modules
-// (`features/search_auth.ts`, `features/image_auth.ts`, `features/video_auth.ts`) can manage them
+// (`features/search_auth.ts`, `features/image_auth.ts`, `features/video_auth.ts`,
+// `features/tts_auth.ts`) can manage them
// without re-implementing the load/save round-trip. Live in auth.ts so
// the entire `auth-profiles.json` file has a single owner.
@@ -455,6 +501,16 @@ export function saveVideoProfiles(list: VideoProfile[]): void {
saveProfiles(store);
}
+export function loadTtsProfiles(): TtsProfile[] {
+ return loadProfiles().ttsProfiles || [];
+}
+
+export function saveTtsProfiles(list: TtsProfile[]): void {
+ const store = loadProfiles();
+ store.ttsProfiles = [...list];
+ saveProfiles(store);
+}
+
function saveProfiles(store: ProfilesFile): void {
ensureAuthDir();
const json = JSON.stringify(store, null, 2);
diff --git a/src/main/features/tts_auth.ts b/src/main/features/tts_auth.ts
new file mode 100644
index 00000000..cd3a4ae2
--- /dev/null
+++ b/src/main/features/tts_auth.ts
@@ -0,0 +1,146 @@
+/**
+ * Text-to-speech provider management for user-owned keys.
+ *
+ * Open-source builds do not ship a hosted Orkas speech API. Users configure
+ * their own provider credentials here, and downstream speech tools read the
+ * ordered `ttsProfiles` list from auth.ts.
+ */
+
+import { loadTtsProfiles, saveTtsProfiles, type TtsProfile } from './auth';
+import { createLogger } from '../logger';
+
+const log = createLogger('tts-auth');
+
+const DOUBAO_TTS_BASE_URL = 'https://openspeech.bytedance.com';
+const LEGACY_DOUBAO_DEFAULT_VOICE = 'zh_male_jieshuoxiaoming_uranus_bigtts';
+export const DOUBAO_DEFAULT_VOICE = 'zh_female_vv_uranus_bigtts';
+export const DEFAULT_TTS_FORMAT = 'mp3';
+
+let _idCounter = 0;
+function nextTtsProfileId(): string {
+ _idCounter = (_idCounter + 1) % 100000;
+ return `tts-${Date.now().toString(36)}-${_idCounter}`;
+}
+
+function sanitizeLabel(input: string): string {
+ return String(input || '').trim().slice(0, 40) || 'default';
+}
+
+function normalizeBaseUrl(raw: string): string | null {
+ const s = String(raw || '').trim().replace(/\/+$/, '');
+ if (!s) return null;
+ if (!/^https?:\/\//i.test(s)) return null;
+ return s;
+}
+
+function normalizeTtsProfile(p: TtsProfile): TtsProfile {
+ if (p.provider === 'doubao' && (!p.voice || p.voice === LEGACY_DOUBAO_DEFAULT_VOICE)) {
+ return { ...p, voice: DOUBAO_DEFAULT_VOICE };
+ }
+ return p;
+}
+
+export function listTtsProfiles(): TtsProfile[] {
+ const list = loadTtsProfiles();
+ const normalized = list
+ .filter((p) => p.provider !== 'orkas-voice')
+ .map(normalizeTtsProfile);
+ if (JSON.stringify(normalized) !== JSON.stringify(list)) saveTtsProfiles(normalized);
+ return normalized;
+}
+
+export interface AddTtsProfileInput {
+ baseUrl?: string;
+ model?: string;
+ apiKey?: string;
+ provider?: string;
+ resourceId?: string;
+ voice?: string;
+ format?: string;
+ label?: string;
+}
+
+export function addTtsProfile(input: AddTtsProfileInput): { ok: true; id: string } | { ok: false; error: string } {
+ const provider = String(input.provider || 'custom').trim() || 'custom';
+ const apiKey = String(input.apiKey || '').trim();
+ const voice = String(input.voice || '').trim();
+ const format = String(input.format || '').trim();
+
+ if (provider === 'orkas-voice') return { ok: false, error: 'provider unavailable in open-source build' };
+ if (provider === 'doubao') return addDoubaoProfile({ apiKey, voice, format, input });
+
+ const baseUrl = normalizeBaseUrl(input.baseUrl || '');
+ const model = String(input.model || '').trim();
+ if (!baseUrl) return { ok: false, error: 'baseUrl required (http(s)://...)' };
+ if (!model) return { ok: false, error: 'model required' };
+ if (!apiKey) return { ok: false, error: 'apiKey required' };
+
+ return persistTtsProfile({
+ provider,
+ baseUrl,
+ model,
+ apiKey,
+ ...(voice ? { voice } : {}),
+ ...(format ? { format } : {}),
+ label: sanitizeLabel(input.label || provider),
+ });
+}
+
+function addDoubaoProfile(args: { apiKey: string; voice: string; format: string; input: AddTtsProfileInput }):
+ { ok: true; id: string } | { ok: false; error: string } {
+ const { apiKey, voice, format, input } = args;
+ if (!apiKey) return { ok: false, error: 'API key required' };
+ const resourceId = String(input.resourceId || '').trim();
+ return persistTtsProfile({
+ provider: 'doubao',
+ baseUrl: DOUBAO_TTS_BASE_URL,
+ model: '',
+ apiKey,
+ ...(resourceId ? { resourceId } : {}),
+ voice: voice || DOUBAO_DEFAULT_VOICE,
+ ...(format ? { format } : {}),
+ label: sanitizeLabel(input.label || 'doubao'),
+ });
+}
+
+function persistTtsProfile(fields: Omit<TtsProfile, 'id' | 'createdAt'>): { ok: true; id: string } {
+ const list = listTtsProfiles();
+ const profile: TtsProfile = { id: nextTtsProfileId(), ...fields, createdAt: Date.now() };
+ list.unshift(profile);
+ saveTtsProfiles(list);
+ log.info('tts profile added', { id: profile.id, provider: profile.provider, model: profile.model || '(n/a)' });
+ return { ok: true, id: profile.id };
+}
+
+export function removeTtsProfile(id: string): { ok: boolean } {
+ const list = listTtsProfiles();
+ const next = list.filter((p) => p.id !== id);
+ if (next.length === list.length) return { ok: false };
+ saveTtsProfiles(next);
+ log.info('tts profile removed', { id });
+ return { ok: true };
+}
+
+export function reorderTtsProfiles(orderedIds: string[]): { ok: boolean } {
+ const list = listTtsProfiles();
+ const idx = new Map(orderedIds.map((id, i) => [id, i]));
+ const next = [...list].sort((a, b) => {
+ const ra = idx.has(a.id) ? (idx.get(a.id) as number) : 1000;
+ const rb = idx.has(b.id) ? (idx.get(b.id) as number) : 1000;
+ return ra - rb;
+ });
+ saveTtsProfiles(next);
+ return { ok: true };
+}
+
+export function listTtsProviderPresets(): Array<{
+ id: string; label: string; baseUrl: string;
+ defaultModel?: string; defaultVoice?: string; defaultFormat?: string; docs?: string;
+}> {
+ return [
+ { id: 'doubao', label: 'DouBao · Voice', baseUrl: DOUBAO_TTS_BASE_URL, defaultVoice: DOUBAO_DEFAULT_VOICE, defaultFormat: DEFAULT_TTS_FORMAT, docs: 'https://www.volcengine.com/docs/6561/1598757' },
+ { id: 'elevenlabs', label: 'ElevenLabs', baseUrl: 'https://api.elevenlabs.io/v1', defaultModel: 'eleven_multilingual_v2', docs: 'https://elevenlabs.io/docs' },
+ { id: 'openai', label: 'OpenAI', baseUrl: 'https://api.openai.com/v1', defaultModel: 'tts-1', defaultVoice: 'alloy', defaultFormat: DEFAULT_TTS_FORMAT, docs: 'https://platform.openai.com/api-keys' },
+ { id: 'custom', label: 'Custom (OpenAI-compatible)', baseUrl: '', docs: '' },
+ ];
+}
diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts
index a21bd6ef..a56a0c2d 100644
--- a/src/main/ipc/index.ts
+++ b/src/main/ipc/index.ts
@@ -45,9 +45,12 @@ import * as auth from '../features/auth';
import * as imageAuth from '../features/image_auth';
import * as searchAuth from '../features/search_auth';
import * as videoAuth from '../features/video_auth';
+import * as ttsAuth from '../features/tts_auth';
import * as permissions from '../features/permissions';
import * as appConfig from '../features/config';
import * as avatars from '../features/avatars';
+import * as commanderProfile from '../features/commander_profile';
+import * as commanderRuntimeStats from '../features/commander_runtime_stats';
import { getRendererTables, isLang, t } from '../i18n';
import { isPathAllowed } from '../util/path-sandbox';
import * as userWorkspace from '../features/user_workspace';
@@ -1836,6 +1839,14 @@ const invokeHandlers: Record<string, InvokeHandler> = {
// startup, then uses its local cache.
'avatars.getCatalog': async () => ({ catalog: avatars.getCatalog() }),
+ // Commander display/profile catalog. Static localized content lives in
+ // src/main/data/commander.json; mutable state (avatar, memory, stats) is
+ // stored separately.
+ 'commander.getProfile': async () => ({ profile: commanderProfile.getProfile() }),
+ 'commander.runtimeStats.get': async (_payload, ctx) => ({
+ runtime_stats: await commanderRuntimeStats.readCommanderRuntimeStats(ctx.userId),
+ }),
+
// Commander avatar preference (cloud-synced). avatar = { icon, color };
// tokens are validated against the catalog allow-list. When absent the
// renderer falls back to the commander default (crown + gold).
@@ -1914,6 +1925,22 @@ const invokeHandlers: Record<string, InvokeHandler> = {
'videoAuth.remove': async ({ id }) => videoAuth.removeVideoProfile(id),
'videoAuth.reorder': async ({ orderedIds }) => videoAuth.reorderVideoProfiles(orderedIds || []),
+ // ── Text-to-speech API key (user-owned speech providers) ──
+ 'ttsAuth.list': async () => ({
+ ok: true,
+ presets: ttsAuth.listTtsProviderPresets(),
+ profiles: ttsAuth.listTtsProfiles().map((p) => ({
+ id: p.id, provider: p.provider, baseUrl: p.baseUrl, model: p.model,
+ resourceId: p.resourceId,
+ voice: p.voice, format: p.format, label: p.label, createdAt: p.createdAt,
+ apiKeyMasked: auth.maskKey(p.apiKey),
+ })),
+ }),
+ 'ttsAuth.add': async ({ provider, baseUrl, model, apiKey, resourceId, voice, format, label }) =>
+ ttsAuth.addTtsProfile({ provider, baseUrl, model, apiKey, resourceId, voice, format, label }),
+ 'ttsAuth.remove': async ({ id }) => ttsAuth.removeTtsProfile(id),
+ 'ttsAuth.reorder': async ({ orderedIds }) => ttsAuth.reorderTtsProfiles(orderedIds || []),
+
// ── Search-tool API key (overrides built-in keyless web_search) ──
'searchAuth.list': async () => ({
ok: true,
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 884f7bce..7646fd46 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -74,7 +74,7 @@
<button type="button" class="new-chat-external-agent-btn" id="new-chat-external-agent-btn">
<span data-ui-icon="terminal" data-ui-icon-class="new-chat-external-agent-icon"></span>
<span class="new-chat-external-agent-label">
- <span data-i18n="new_chat.external_agent_entry">Connect Codex, Claude Code &amp; other AI coding tools</span>
+ <span data-i18n="new_chat.external_agent_entry">Connect Codex, Claude Code &amp; other external agents</span>
<span data-ui-icon="arrow-right" data-ui-icon-class="new-chat-external-agent-arrow"></span>
</span>
</button>
@@ -350,9 +350,7 @@
<h1 class="skills-doc-title" id="skills-detail-name" data-editable="false"></h1>
<span class="skills-doc-source" id="skills-detail-source"></span>
<div class="skills-doc-actions" id="skills-detail-actions">
- <button class="btn-icon-use" id="skill-use-btn" data-i18n-title="skills.use_tooltip" data-i18n-aria-label="skills.use_tooltip" aria-label="Use this skill">
- <span data-ui-icon="play-triangle" data-ui-icon-class="icon-play"></span>
- </button>
+ <button type="button" class="skill-card-use skill-dialog-btn" id="skill-use-btn" data-i18n="skills.use" data-i18n-title="skills.use_tooltip" data-i18n-aria-label="skills.use_tooltip" aria-label="Use this skill">Use</button>
<button class="btn btn-sm" id="skill-edit-btn" data-i18n="skills.edit">Edit</button>
<button class="btn btn-sm" id="skill-enabled-btn" data-i18n="component.disable">Disable</button>
<button class="btn btn-sm" id="skill-upload-marketplace-btn" style="display:none" data-i18n="marketplace.upload">Upload to marketplace (dev)</button>
@@ -464,9 +462,7 @@
<input type="text" class="agents-detail-name-input" id="agents-detail-name-input" autocomplete="off" spellcheck="false" hidden />
<span class="agents-detail-source" id="agents-detail-source"></span>
<div class="detail-actions" id="agents-detail-actions">
- <button class="btn-icon-use" id="agent-use-btn" data-i18n-title="agents.use_tooltip" data-i18n-aria-label="agents.use_tooltip" aria-label="Use this agent">
- <span data-ui-icon="play-triangle" data-ui-icon-class="icon-play"></span>
- </button>
+ <button type="button" class="agent-card-use agent-dialog-btn" id="agent-use-btn" data-i18n="agents.use" data-i18n-title="agents.use_tooltip" data-i18n-aria-label="agents.use_tooltip" aria-label="Use this agent">Use</button>
<button class="btn btn-sm" id="agent-edit-btn" data-i18n="agents.edit_btn_edit">Edit</button>
<button class="btn btn-sm" id="agent-enabled-btn" data-i18n="component.disable">Disable</button>
<button class="btn btn-sm" id="agent-upload-marketplace-btn" style="display:none" data-i18n="marketplace.upload">Upload to marketplace (dev)</button>
@@ -1042,6 +1038,43 @@
</div>
</div>
+ <div class="settings-group">
+ <div class="settings-group-head">
+ <div class="settings-group-title" data-i18n="settings.tts.title">Text-to-speech API Key</div>
+ </div>
+ <div class="settings-row">
+ <label data-i18n="settings.tts.provider">Provider</label>
+ <div class="ai-select" id="settings-tts-provider"></div>
+ </div>
+ <div class="settings-row" id="settings-tts-key-row">
+ <label data-i18n="settings.tts.api_key">API Key</label>
+ <input type="text" class="form-input" id="settings-tts-key-input" autocomplete="off" spellcheck="false" />
+ </div>
+ <div class="settings-row tts-row-voice" hidden>
+ <label data-i18n="settings.tts.voice">Voice</label>
+ <input type="text" class="form-input" id="settings-tts-voice-input" placeholder="alloy / zh_female_..._bigtts" autocomplete="off" spellcheck="false" />
+ </div>
+ <div class="settings-row tts-row-base" hidden>
+ <label data-i18n="settings.tts.base_url">Base URL</label>
+ <input type="text" class="form-input" id="settings-tts-base-input" placeholder="https://api.openai.com/v1" autocomplete="off" spellcheck="false" />
+ </div>
+ <div class="settings-row tts-row-model" hidden>
+ <label data-i18n="settings.tts.model">Model</label>
+ <input type="text" class="form-input" id="settings-tts-model-input" autocomplete="off" spellcheck="false" />
+ </div>
+ <div class="settings-row tts-row-doubao-res" hidden>
+ <label><span data-i18n="settings.tts.doubao_resource">Resource ID</span> <span class="form-hint" data-i18n="settings.tts.doubao_resource_hint">Auto-detected from the voice; set only to override.</span></label>
+ <input type="text" class="form-input" id="settings-tts-doubao-resource" placeholder="auto (seed-tts-2.0 / 1.0 / icl-2.0)" autocomplete="off" spellcheck="false" />
+ </div>
+ <div class="settings-row">
+ <button class="btn btn-primary" id="settings-tts-add-btn" data-i18n="settings.tts.add">+ Add speech key</button>
+ <span class="settings-status" id="settings-tts-status"></span>
+ </div>
+ <div class="settings-entries" id="settings-tts-entries">
+ <div class="settings-empty" data-i18n="settings.loading">Loading…</div>
+ </div>
+ </div>
+
</div>
</div>
diff --git a/src/renderer/locales/en.json b/src/renderer/locales/en.json
index 94534d0d..86da8f8f 100644
--- a/src/renderer/locales/en.json
+++ b/src/renderer/locales/en.json
@@ -195,7 +195,7 @@
"new_chat.quick.video": "Make video",
"new_chat.quick.seo_geo": "SeoGeo",
"new_chat.quick.office": "Documents",
- "new_chat.external_agent_entry": "Connect Codex, Claude Code & other AI coding tools",
+ "new_chat.external_agent_entry": "Connect Codex, Claude Code & other external agents",
"new_chat.quick.agent_required": "Install or enable “{name}” before using this shortcut.",
"new_chat.quick.tmpl.education": "[topic / problem / material] Tutor me step by step: find where I am stuck, explain with examples, and give me a practice plan",
"new_chat.quick.tmpl.ecommerce": "Research [product / category]: analyze demand, competitors, price bands, profit assumptions, sourcing risk, and whether it is worth selling",
diff --git a/src/renderer/locales/ja.json b/src/renderer/locales/ja.json
index 99d37a18..91b7a82f 100644
--- a/src/renderer/locales/ja.json
+++ b/src/renderer/locales/ja.json
@@ -183,7 +183,7 @@
"new_chat.quick.video": "動画制作",
"new_chat.quick.seo_geo": "SeoGeo",
"new_chat.quick.office": "資料整理",
- "new_chat.external_agent_entry": "Codex・Claude Code など AI コーディングツールを接続",
+ "new_chat.external_agent_entry": "Codex・Claude Code など外部エージェントを接続",
"new_chat.quick.agent_required": "このショートカットを使うには「{name}」をインストールまたは有効化してください。",
"new_chat.quick.tmpl.education": "[テーマ / 問題 / 教材] を段階的に教えてください。つまずいている箇所を見つけ、例を使って説明し、練習計画を出してください",
"new_chat.quick.tmpl.ecommerce": "[商品 / カテゴリ] を調査してください。需要、競合、価格帯、利益の見込み、仕入れリスクを分析し、販売する価値があるか判断してください",
diff --git a/src/renderer/locales/pt.json b/src/renderer/locales/pt.json
index f8b6dc34..69332825 100644
--- a/src/renderer/locales/pt.json
+++ b/src/renderer/locales/pt.json
@@ -188,7 +188,7 @@
"new_chat.quick.creation": "Escrita",
"new_chat.quick.data": "Pesquisa",
"new_chat.quick.office": "Documentos",
- "new_chat.external_agent_entry": "Conecte Codex, Claude Code e outras ferramentas de IA para programação",
+ "new_chat.external_agent_entry": "Conecte Codex, Claude Code e outros agentes externos",
"new_chat.quick.agent_required": "Instale ou ative “{name}” antes de usar este atalho.",
"new_chat.quick.tmpl.education": "[tópico / problema / material] Oriente-me passo a passo: descubra onde estou preso, explique com exemplos e me dê um plano de prática",
"new_chat.quick.tmpl.ecommerce": "Pesquisa [produto/categoria]: analise a demanda, concorrentes, faixas de preço, premissas de lucro, risco de fornecimento e se vale a pena vender",
diff --git a/src/renderer/locales/zh.json b/src/renderer/locales/zh.json
index 64a0e27a..300188bb 100644
--- a/src/renderer/locales/zh.json
+++ b/src/renderer/locales/zh.json
@@ -195,7 +195,7 @@
"new_chat.quick.video": "制作视频",
"new_chat.quick.seo_geo": "SeoGeo",
"new_chat.quick.office": "整理文档",
- "new_chat.external_agent_entry": "接入 Codex、Claude Code 等 AI 编程工具",
+ "new_chat.external_agent_entry": "接入 Codex、Claude Code 等外部智能体",
"new_chat.quick.agent_required": "需要先安装或启用「{name}」后才可使用这个入口。",
"new_chat.quick.tmpl.education": "带我学会 [知识点/题目/材料]:先判断我哪里没懂,再用例子和提问一步步讲清楚,最后给我几道练习",
"new_chat.quick.tmpl.ecommerce": "帮我判断 [商品/类目] 值不值得做:看需求、竞品、价格带、利润空间、供应链风险,最后给结论和下一步验证方法",
diff --git a/src/renderer/modules/settings.js b/src/renderer/modules/settings.js
index 2cd3b898..42de8ed0 100644
--- a/src/renderer/modules/settings.js
+++ b/src/renderer/modules/settings.js
@@ -20,6 +20,9 @@ let _settingsState = {
pickerProviderEl: null,
pickerModelEl: null,
addBtnEl: null,
+ ttsPresets: [],
+ ttsProfiles: [],
+ ttsProviderSel: null,
dragState: null,
clientConfigBound: false,
};
@@ -64,6 +67,7 @@ async function loadSettings() {
_settingsSafeCall('settings search refresh', _settingsRefreshSearchProfiles),
_settingsSafeCall('settings image refresh', _settingsRefreshImageProfiles),
_settingsSafeCall('settings video refresh', _settingsRefreshVideoProfiles),
+ _settingsSafeCall('settings tts refresh', _settingsRefreshTtsProfiles),
_settingsSafeCall('settings commander avatar refresh', _settingsRefreshCommanderAvatar),
_settingsSafeCall('settings metacognition refresh', _settingsRefreshMetacognition),
_settingsSafeCall('settings data root refresh', _settingsRefreshDataRoot),
@@ -74,6 +78,7 @@ async function loadSettings() {
await _settingsSafeCall('settings search render', _settingsRenderSearchSection);
await _settingsSafeCall('settings image render', _settingsRenderImageSection);
await _settingsSafeCall('settings video render', _settingsRenderVideoSection);
+ await _settingsSafeCall('settings tts render', _settingsRenderTtsEntries);
await _settingsSafeCall('settings commander avatar render', _settingsRenderCommanderAvatar);
await _settingsSafeCall('settings metacognition render', _settingsRenderMetacognition);
await _settingsSafeCall('settings data root render', _settingsRenderDataRoot);
@@ -1473,3 +1478,179 @@ function _settingsRenderVideoEntries() {
container.appendChild(row);
});
}
+
+// ── Text-to-speech API key section ─────────────────────────────────────────
+
+async function _settingsRefreshTtsProfiles() {
+ const res = await window.orkas.invoke('ttsAuth.list');
+ if (!res || !res.ok) return;
+ _settingsState.ttsPresets = Array.isArray(res.presets) ? res.presets : [];
+ _settingsState.ttsProfiles = Array.isArray(res.profiles) ? res.profiles : [];
+ const providerEl = document.getElementById('settings-tts-provider');
+ if (providerEl && !_settingsState.ttsProviderSel) {
+ _settingsState.ttsProviderSel = _aiSelectMount(providerEl, { placeholder: t('settings.tts.pick_provider') });
+ _settingsState.ttsProviderSel.onChange((id) => {
+ _settingsTtsPrefillProvider(id);
+ _settingsTtsApplyProviderFields(id);
+ _settingsSetStatus('settings-tts-status', '', '');
+ });
+ }
+ if (_settingsState.ttsProviderSel) {
+ const prev = _settingsState.ttsProviderSel.getValue();
+ _settingsState.ttsProviderSel.setOptions(
+ (_settingsState.ttsPresets || []).map((p) => ({ value: p.id, label: p.label, hint: p.docs })),
+ { value: prev || '', placeholder: t('settings.tts.pick_provider') },
+ );
+ _settingsTtsApplyProviderFields(_settingsState.ttsProviderSel.getValue());
+ }
+ const addBtn = document.getElementById('settings-tts-add-btn');
+ if (addBtn && !addBtn.dataset.bound) {
+ addBtn.dataset.bound = '1';
+ addBtn.addEventListener('click', _settingsClickAddTts);
+ }
+ _settingsRenderTtsEntries();
+}
+
+function _settingsTtsPreset(providerId) {
+ return (_settingsState.ttsPresets || []).find((p) => p.id === providerId);
+}
+
+function _ttsProviderLabel(id) {
+ const hit = (_settingsState.ttsPresets || []).find((p) => p.id === id);
+ return hit ? hit.label : (id || 'custom');
+}
+
+function _settingsTtsPrefillProvider(providerId) {
+ const preset = _settingsTtsPreset(providerId);
+ const baseInput = document.getElementById('settings-tts-base-input');
+ const modelInput = document.getElementById('settings-tts-model-input');
+ const voiceInput = document.getElementById('settings-tts-voice-input');
+ const resInput = document.getElementById('settings-tts-doubao-resource');
+ if (baseInput) baseInput.value = preset?.baseUrl || '';
+ if (modelInput) modelInput.value = preset?.defaultModel || '';
+ if (voiceInput) {
+ voiceInput.value = '';
+ voiceInput.placeholder = preset?.defaultVoice || 'alloy';
+ }
+ if (resInput) resInput.value = preset?.defaultResourceId || '';
+}
+
+function _settingsTtsSetRowHidden(selector, hidden) {
+ document.querySelectorAll(selector).forEach((el) => {
+ el.hidden = !!hidden;
+ el.style.display = hidden ? 'none' : '';
+ el.setAttribute('aria-hidden', hidden ? 'true' : 'false');
+ });
+}
+
+function _settingsTtsApplyProviderFields(providerId) {
+ const preset = _settingsTtsPreset(providerId);
+ const isCustom = providerId === 'custom';
+ const needsVoice = !!providerId && !preset?.defaultVoice;
+ _settingsTtsSetRowHidden('#settings-tts-key-row', false);
+ _settingsTtsSetRowHidden('.tts-row-base, .tts-row-model', !isCustom);
+ _settingsTtsSetRowHidden('.tts-row-voice', !needsVoice);
+ _settingsTtsSetRowHidden('.tts-row-doubao-res', true);
+}
+
+async function _settingsClickAddTts() {
+ const provider = _settingsState.ttsProviderSel?.getValue() || '';
+ if (!provider) { _settingsSetStatus('settings-tts-status', 'error', t('settings.tts.error_provider_needed')); return; }
+ const preset = _settingsTtsPreset(provider);
+ const apiKey = (document.getElementById('settings-tts-key-input')?.value || '').trim();
+ const voice = (document.getElementById('settings-tts-voice-input')?.value || '').trim();
+ if (!apiKey) { _settingsSetStatus('settings-tts-status', 'error', t('settings.tts.error_key_needed')); return; }
+
+ let payload;
+ if (provider === 'doubao') {
+ const resourceId = (document.getElementById('settings-tts-doubao-resource')?.value || '').trim();
+ payload = { provider, apiKey, voice: voice || (preset?.defaultVoice || ''), resourceId };
+ } else {
+ const baseUrl = (document.getElementById('settings-tts-base-input')?.value || '').trim() || (preset?.baseUrl || '');
+ const model = (document.getElementById('settings-tts-model-input')?.value || '').trim() || (preset?.defaultModel || '');
+ const finalVoice = voice || (preset?.defaultVoice || '');
+ if (!baseUrl) { _settingsSetStatus('settings-tts-status', 'error', t('settings.tts.error_base_needed')); return; }
+ if (!model) { _settingsSetStatus('settings-tts-status', 'error', t('settings.tts.error_model_needed')); return; }
+ if (!finalVoice) { _settingsSetStatus('settings-tts-status', 'error', t('settings.tts.error_voice_needed')); return; }
+ payload = { provider, baseUrl, model, apiKey, voice: finalVoice };
+ }
+
+ _settingsSetStatus('settings-tts-status', 'busy', t('settings.tts.adding'));
+ try {
+ const res = await window.orkas.invoke('ttsAuth.add', payload);
+ if (!res || !res.ok) {
+ _settingsSetStatus('settings-tts-status', 'error', (res && res.error) || t('settings.tts.add_failed'));
+ return;
+ }
+ const keyInput = document.getElementById('settings-tts-key-input');
+ if (keyInput) keyInput.value = '';
+ _settingsSetStatus('settings-tts-status', 'ok', t('settings.tts.add_ok'));
+ await _settingsRefreshTtsProfiles();
+ } catch (err) {
+ _settingsSetStatus('settings-tts-status', 'error', (err && err.message) || String(err));
+ }
+}
+
+function _settingsRenderTtsEntries() {
+ const container = document.getElementById('settings-tts-entries');
+ if (!container) return;
+ container.innerHTML = '';
+ const list = _settingsState.ttsProfiles || [];
+ if (!list.length) {
+ container.innerHTML = `<div class="settings-empty">${escapeHtml(t('settings.tts.empty'))}</div>`;
+ return;
+ }
+ list.forEach((p, idx) => {
+ const row = document.createElement('div');
+ row.className = 'entry-row' + (idx === 0 ? ' is-default' : '');
+ row.dataset.profileId = p.id;
+
+ const rank = document.createElement('div');
+ rank.className = 'entry-rank';
+ rank.textContent = idx === 0 ? t('settings.tts.active_tag') : `#${idx + 1}`;
+ row.appendChild(rank);
+
+ const main = document.createElement('div');
+ main.className = 'entry-main';
+ const primary = document.createElement('div');
+ primary.className = 'entry-primary';
+ const detail = p.provider === 'doubao' ? (p.resourceId || '') : (p.model || '');
+ primary.innerHTML = `
+ <span class="entry-provider">${escapeHtml(_ttsProviderLabel(p.provider))}</span>
+ ${detail ? `<span class="entry-sep">·</span><span class="entry-model">${escapeHtml(detail)}</span>` : ''}
+ ${p.voice ? `<span class="entry-sep">·</span><span class="entry-model">${escapeHtml(p.voice)}</span>` : ''}
+ <span class="entry-sep">·</span>
+ <span class="entry-account-chip">@ ${escapeHtml(p.label || 'default')}</span>
+ ${p.apiKeyMasked ? `<span class="account-mask">${escapeHtml(p.apiKeyMasked)}</span>` : ''}
+ `;
+ main.appendChild(primary);
+ row.appendChild(main);
+
+ const actions = document.createElement('div');
+ actions.className = 'entry-actions';
+ const delBtn = document.createElement('button');
+ delBtn.className = 'btn btn-sm btn-danger';
+ delBtn.textContent = t('settings.delete');
+ delBtn.addEventListener('click', async () => {
+ const ok = await uiConfirm(t('settings.tts.confirm_delete', { provider: _ttsProviderLabel(p.provider) }));
+ if (!ok) return;
+ const res = await window.orkas.invoke('ttsAuth.remove', { id: p.id });
+ if (res && res.ok) await _settingsRefreshTtsProfiles();
+ });
+ actions.appendChild(delBtn);
+ row.appendChild(actions);
+
+ _settingsAttachReorderDnd(row, {
+ kind: 'tts',
+ id: p.id,
+ getIds: () => (_settingsState.ttsProfiles || []).map((x) => x.id),
+ ipcName: 'ttsAuth.reorder',
+ onSuccess: async () => {
+ await _settingsRefreshTtsProfiles();
+ _settingsRenderTtsEntries();
+ },
+ });
+
+ container.appendChild(row);
+ });
+}
diff --git a/src/renderer/style.css b/src/renderer/style.css
index ca0b0a10..f45558b2 100644
--- a/src/renderer/style.css
+++ b/src/renderer/style.css
@@ -2879,16 +2879,88 @@ body.model-not-configured .main-content { flex-direction: column; }
/* When platform chips (version/category) sit on the actions row, the play button still
hugs the right edge — `margin-left:auto` handles the absent-chip case too. */
.skill-card-actions > .skill-card-use { margin-left: auto; }
+.skill-card--global-group {
+ background: rgba(248, 250, 252, 0.82);
+}
+.skill-card-disclosure {
+ margin-left: auto;
+ flex: 0 0 auto;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ min-height: 28px;
+ padding: 4px 9px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: #fff;
+ color: var(--text);
+ font: inherit;
+ font-size: 12px;
+ font-weight: 600;
+ line-height: 1;
+ cursor: pointer;
+}
+.skill-card-disclosure:hover {
+ border-color: rgba(79, 70, 229, 0.32);
+ color: var(--primary);
+ background: rgba(79, 70, 229, 0.04);
+}
+.skill-card-disclosure-icon {
+ width: 14px;
+ height: 14px;
+ flex: 0 0 auto;
+}
-.skill-card-use,
.agent-card-use,
+.skill-card-use,
+.agent-dialog-btn {
+ flex-shrink: 0;
+ min-width: auto;
+ padding: 4px 10px;
+ border: 1px solid var(--primary);
+ border-radius: 8px;
+ background: var(--primary);
+ color: #fff;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 12px;
+ line-height: normal;
+ font-weight: 500;
+ font-family: inherit;
+ transition: background 0.12s, box-shadow 0.12s;
+}
+
+.agent-dialog-btn,
+.skill-dialog-btn {
+ flex-shrink: 0;
+}
+
+.agent-card-use:hover,
+.skill-card-use:hover,
+.agent-dialog-btn:hover {
+ background: var(--primary-hover, #4f46e5);
+ box-shadow: 0 6px 14px rgba(91, 87, 214, 0.18);
+}
+
+.agent-card-use:disabled,
+.agent-card-use:disabled:hover,
+.skill-card-use:disabled,
+.skill-card-use:disabled:hover {
+ cursor: default;
+ color: #94a3b8;
+ background: rgba(148, 163, 184, 0.14);
+ box-shadow: none;
+}
+
.btn-icon-use {
flex-shrink: 0;
width: 26px;
height: 26px;
padding: 0;
border: none;
- border-radius: 50%;
+ border-radius: 8px;
background: rgba(37, 99, 235, 0.1);
color: var(--primary);
cursor: pointer;
@@ -2897,30 +2969,17 @@ body.model-not-configured .main-content { flex-direction: column; }
justify-content: center;
transition: background 0.12s, transform 0.12s;
}
-.skill-card-use:hover,
-.agent-card-use:hover,
.btn-icon-use:hover {
background: rgba(37, 99, 235, 0.2);
transform: scale(1.05);
}
-.skill-card-use:disabled,
-.agent-card-use:disabled,
-.btn-icon-use:disabled {
+.btn-icon-use:disabled,
+.btn-icon-use:disabled:hover {
cursor: default;
color: #94a3b8;
background: rgba(148, 163, 184, 0.14);
transform: none;
}
-.skill-card-use:disabled:hover,
-.agent-card-use:disabled:hover,
-.btn-icon-use:disabled:hover {
- background: rgba(148, 163, 184, 0.14);
- transform: none;
-}
-/* Centered SVG triangle inside the round play button. The SVG path itself
- is balanced; the wrapper is plain flex-center, so no padding hacks needed. */
-.skill-card-use .icon-play,
-.agent-card-use .icon-play,
.btn-icon-use .icon-play {
width: 14px;
height: 14px;
diff --git a/test/renderer/synced-surface-regression.test.ts b/test/renderer/synced-surface-regression.test.ts
new file mode 100644
index 00000000..64f0ecd2
--- /dev/null
+++ b/test/renderer/synced-surface-regression.test.ts
@@ -0,0 +1,91 @@
+import { describe, expect, it } from 'vitest';
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+
+const root = path.join(__dirname, '../..');
+
+function read(rel: string) {
+ return fs.readFileSync(path.join(root, rel), 'utf8');
+}
+
+function cssBlock(css: string, selector: RegExp) {
+ return css.match(selector)?.[1] || '';
+}
+
+describe('synced PC surface regressions', () => {
+ it('keeps card Use actions as text buttons and reserves icon sizing for icon buttons', () => {
+ const css = read('src/renderer/style.css');
+ const html = read('src/renderer/index.html');
+
+ const useBlock = cssBlock(css, /\.agent-card-use,\s*\.skill-card-use,\s*\.agent-dialog-btn\s*{([\s\S]*?)}/);
+ expect(useBlock).toContain('padding: 4px 10px;');
+ expect(useBlock).toContain('border-radius: 8px;');
+ expect(useBlock).toContain('background: var(--primary);');
+ expect(useBlock).not.toContain('width: 26px;');
+ expect(useBlock).not.toContain('border-radius: 50%;');
+
+ const iconBlock = cssBlock(css, /\.btn-icon-use\s*{([\s\S]*?)}/);
+ expect(iconBlock).toContain('width: 26px;');
+ expect(iconBlock).toContain('height: 26px;');
+ expect(iconBlock).toContain('border-radius: 8px;');
+
+ expect(css).toContain('.skill-card--global-group');
+ expect(css).toContain('.skill-card-disclosure');
+ expect(html).toContain('class="skill-card-use skill-dialog-btn" id="skill-use-btn"');
+ expect(html).toContain('class="agent-card-use agent-dialog-btn" id="agent-use-btn"');
+ });
+
+ it('keeps the external-agent entry copy aligned with external agents, not coding tools only', () => {
+ const html = read('src/renderer/index.html');
+ const en = read('src/renderer/locales/en.json');
+ const zh = read('src/renderer/locales/zh.json');
+
+ expect(html).toContain('other external agents');
+ expect(en).toContain('other external agents');
+ expect(zh).toContain('等外部智能体');
+ expect(zh).not.toContain('AI 编程工具');
+ });
+
+ it('exposes the local Commander profile to the renderer', () => {
+ const ipc = read('src/main/ipc/index.ts');
+ const profile = read('src/main/data/commander.json');
+ const fromToken = ['fr', 'om'].join('');
+ const commanderProfileImport = ['im', 'port * as commanderProfile ', fromToken, " '", '..', "/features/commander_profile'"].join('');
+
+ expect(ipc).toContain(commanderProfileImport);
+ expect(ipc).toContain("'commander.getProfile'");
+ expect(ipc).toContain("'commander.runtimeStats.get'");
+ expect(profile).toContain('Orkas 的总调度者');
+ });
+
+ it('restores user-owned speech key configuration without exposing managed Orkas voice', () => {
+ const html = read('src/renderer/index.html');
+ const settings = read('src/renderer/modules/settings.js');
+ const auth = read('src/main/features/auth.ts');
+ const ipc = read('src/main/ipc/index.ts');
+ const ttsAuth = read('src/main/features/tts_auth.ts');
+ const fromToken = ['fr', 'om'].join('');
+ const ttsAuthImport = ['im', 'port * as ttsAuth ', fromToken, " '", '..', "/features/tts_auth'"].join('');
+
+ for (const marker of [
+ 'id="settings-tts-provider"',
+ 'id="settings-tts-key-input"',
+ 'id="settings-tts-add-btn"',
+ 'id="settings-tts-entries"',
+ ]) {
+ expect(html).toContain(marker);
+ }
+ expect(settings).toContain("_settingsSafeCall('settings tts refresh', _settingsRefreshTtsProfiles)");
+ expect(settings).toContain("window.orkas.invoke('ttsAuth.list')");
+ expect(settings).toContain("window.orkas.invoke('ttsAuth.add'");
+ expect(settings).toContain('_settingsRenderTtsEntries');
+ expect(auth).toContain('export interface TtsProfile');
+ expect(auth).toContain('export function loadTtsProfiles');
+ expect(ipc).toContain(ttsAuthImport);
+ expect(ipc).toContain("'ttsAuth.list'");
+ expect(ttsAuth).toContain("id: 'doubao'");
+ expect(ttsAuth).toContain("id: 'openai'");
+ expect(ttsAuth).not.toContain('ORKAS_VOICE');
+ expect(ttsAuth).not.toContain('Orkas · Voice');
+ });
+});