ai_co_discuss 0.4.78 → 0.4.79

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 (44) hide show
  1. package/.agents/skills/discuss-participant/SKILL.md +1 -0
  2. package/.agents/skills/local-tts-setup/SKILL.md +3 -2
  3. package/backend/free_room.py +12 -1
  4. package/backend/message_queue.py +15 -5
  5. package/backend/server.py +20 -3
  6. package/docs/deployment.md +1 -1
  7. package/docs/en/deployment.md +1 -1
  8. package/docs/en/runner.md +2 -0
  9. package/docs/runner.md +3 -1
  10. package/frontend/locales/en/admin.json +38 -11
  11. package/frontend/locales/en/app.json +1 -0
  12. package/frontend/locales/en/backend_worker.json +9 -5
  13. package/frontend/locales/en/discussion.json +3 -2
  14. package/frontend/locales/en/room.json +10 -0
  15. package/frontend/locales/en/settings.json +3 -1
  16. package/package.json +1 -1
  17. package/runner/adapters/claude.mjs +6 -1
  18. package/runner/adapters/cli.mjs +1 -1
  19. package/runner/adapters/codex_bridge.mjs +4 -3
  20. package/runner/adapters/codex_cli.mjs +65 -4
  21. package/runner/adapters/common.mjs +1 -1
  22. package/runner/adapters/profiles.mjs +14 -1
  23. package/runner/admin_cli.mjs +21 -5
  24. package/runner/admin_panel.mjs +56 -13
  25. package/runner/discuss.py +15 -3
  26. package/runner/discussion_launch.mjs +2 -2
  27. package/runner/execution_progress.mjs +7 -3
  28. package/runner/expert_prompts.mjs +8 -5
  29. package/runner/free_runner.mjs +1 -1
  30. package/runner/i18n_en.mjs +10 -6
  31. package/runner/os_users.mjs +15 -3
  32. package/runner/project_files.mjs +6 -5
  33. package/runner/tts_providers.mjs +22 -2
  34. package/web/admin.css +1 -1
  35. package/web/admin.js +3 -3
  36. package/web/app.js +61 -15
  37. package/web/backup.js +1 -1
  38. package/web/i18n.js +4 -4
  39. package/web/icons/custom-api.svg +11 -0
  40. package/web/icons/external-expert.svg +12 -0
  41. package/web/markdown.css +1 -1
  42. package/web/modern.css +1 -1
  43. package/web/modern.js +68 -63
  44. package/web/office/docx.js +3 -3
@@ -25,7 +25,7 @@ export default {
25
25
  "已打开:{value1}": "Opened: {value1}",
26
26
  "AI CoDiscuss 讨论服务\n服务目录:{value1}\n已登记 {value2} 个房间\nCtrl+C 停止服务\n": "AI CoDiscuss discussion service\nService folder: {value1}\n{value2} rooms registered\nCtrl+C to stop the service\n",
27
27
  "尚未登记房间;可在另一终端运行 codiscuss service add --config FILE。\n": "No rooms registered yet. Run codiscuss service add --config FILE in another terminal.\n",
28
- "用法:codiscuss admin <命令> [参数](与管理面板的操作一一对应;除启动与退出外,需管理面板正在运行)\n需要管理员权限的步骤(建或删 Windows 用户),在管理员终端或管理员的 SSH 会话里直接执行;否则在电脑桌面上弹出确认。\n\n启动与退出(不需要面板在运行)\n start 启动共议:服务、管理面板与任务栏图标、登录入口与隧道(在桌面会话里启动)\n stop 彻底退出:管理面板与图标、登录入口、隧道、共议服务;托管账号的实例照常运行\n restart stop 后 start\n update [check] 检查更新;不带 check 时安装最新版(面板未运行时先启动)并等待每一步结果\n\n本机\n status [--full] 概览:服务、版本、开机自启、登录入口、托管账号;--full 输出面板的完整状态\n service start|stop|restart 只启停共议服务(网站与讨论服务)\n autostart on|off 登录 Windows 时自动启动\n\n登录入口与访问方式(需打开托管管理)\n entry start|stop 启动或停止登录入口\n entry open|close relay|tunnel 开启或关闭访问方式:线上中转 | 自有域名,两种可同时开启\n entry join <接入码> 用接入码接入线上站点并开启线上中转\n entry connect <站点> <绑定令牌> 只绑定线上站点(管理员远程用),不改访问方式\n entry code [--config <wrangler.jsonc>] [--site <地址>] 在部署线上站点的电脑上生成接入码(不填用上次的)\n entry tunnel <域名> [隧道名] 设置自有域名(Cloudflare 隧道),输出授权链接;域名须已托管在 Cloudflare\n entry tunnel status 查看自有域名设置的进度\n runtime sync 同步隔离账号的程序副本\n\n托管账号\n account list\n account add <名> [--no-isolate] [--no-start] 创建、隔离、初始化 AI 环境、开启入口保护、启动;输出一次性密码。\n 中途失败时解决后重新执行同一命令,从缺少的步骤接着做\n account start|stop|disable|enable|remove|password <名>\n account isolate|unisolate|protect|unprotect <名>\n\n命令行登录(目标 owner 为管理员自己,否则为托管账号名)\n login status <目标> 各程序的登录状态,以及每个程序可用的登录方式\n login set <目标> <claude|codex> <方式> --set 字段=值 ... 如 login set alice claude setup_token --set token=sk-ant-oat01-…\n login start <目标> <程序> <方式> 浏览器登录:输出链接,之后用 login submit 提交授权码或回调地址\n login submit <作业> <文本> / login progress <作业> / login cancel <作业>\n logout <目标> <程序>\n\nAPI 密钥、技能、工作流、系统提示词(目标同上)\n key list <目标> / key add <目标> --base-url <地址> --key <密钥> / key remove <目标> <编号>\n skill library / skill import <文件夹或.zip> / skill delete <名>\n skill list <目标> / skill install <目标> <名>... / skill remove <目标> <名>...\n workflow list <目标> / workflow install <目标>\n prompt get <目标> / prompt set <目标> --file <文件> [--group <键>] 管理员的提示词按组保存(见 prompt get)\n prompt default get / prompt default set --file <文件> 新托管账号的默认系统提示词\n\n结果以 JSON 输出。--data 指定管理员服务目录(默认 ~/.codiscuss)。\n": "Usage: codiscuss admin <command> [arguments] (matches admin panel actions; the panel must be running except for start and stop)\nSteps requiring administrator rights (creating or deleting Windows users) run directly in an administrator terminal or administrator SSH session. Otherwise, approve the prompt on the computer's desktop.\n\nStart and exit (panel need not be running)\n start Start CoDiscuss: service, panel and tray icon, sign-in entry and tunnel (in the desktop session)\n stop Exit panel and tray icon, sign-in entry, tunnel and service; hosted instances keep running\n restart Run stop, then start\n update [check] Check for updates; omit check to install the latest version and wait for results (starts the panel if needed)\n\nLocal\n status [--full] Show service, version, startup, sign-in entry and hosted accounts; --full returns full panel state\n service start|stop|restart Start or stop only the CoDiscuss service (site and discussion service)\n autostart on|off Start automatically at Windows sign-in\n\nSign-in entry and access methods (hosting must be enabled)\n entry start|stop Start or stop the sign-in entry\n entry open|close relay|tunnel Turn an access method on or off: online relay | own domain; both can be on\n entry join <code> Connect to an online site with an access code and turn on the online relay\n entry connect <site> <binding-token> Bind the online site only, without changing the access method (remote admin use)\n entry code [--config <wrangler.jsonc>] [--site <address>] Generate an access code on the deployment computer (defaults to last settings)\n entry tunnel <domain> [tunnel-name] Configure a Cloudflare Tunnel and show the authorization link; domain must be hosted on Cloudflare\n entry tunnel status Show domain setup progress\n runtime sync Sync program copies for isolated accounts\n\nHosted accounts\n account list\n account add <name> [--no-isolate] [--no-start] Create, isolate, initialize AI environment, protect and start; show password once\n On failure, fix the cause and rerun the same command to resume missing steps\n account start|stop|disable|enable|remove|password <name>\n account isolate|unisolate|protect|unprotect <name>\n\nCLI sign-ins (target owner is the admin; otherwise use a hosted account name)\n login status <target> Show each app's sign-in status and available methods\n login set <target> <claude|codex> <method> --set field=value ... e.g. login set alice claude setup_token --set token=sk-ant-oat01-…\n login start <target> <app> <method> Browser sign-in: show a link; use login submit for the authorization code or callback URL\n login submit <job> <text> / login progress <job> / login cancel <job>\n logout <target> <app>\n\nAPI keys, skills, workflows and system prompts (same target convention)\n key list <target> / key add <target> --base-url <address> --key <key> / key remove <target> <id>\n skill library / skill import <folder-or.zip> / skill delete <name>\n skill list <target> / skill install <target> <name>... / skill remove <target> <name>...\n workflow list <target> / workflow install <target>\n prompt get <target> / prompt set <target> --file <file> [--group <key>] Admin prompts are saved by group (see prompt get)\n prompt default get / prompt default set --file <file> Default system prompt for new hosted accounts\n\nResults are JSON. --data sets the admin service folder (default ~/.codiscuss).\n",
28
+ "用法:codiscuss admin <命令> [参数](与管理面板的操作一一对应;除启动与退出外,需管理面板正在运行)\n需要管理员权限的步骤(建或删 Windows 用户),在管理员终端或管理员的 SSH 会话里直接执行;否则在电脑桌面上弹出确认。\n\n启动与退出(不需要面板在运行)\n start 启动共议:服务、管理面板与任务栏图标、登录入口与隧道(在桌面会话里启动)\n stop 彻底退出:管理面板与图标、登录入口、隧道、共议服务;托管账号的实例照常运行\n restart stop 后 start\n update [check] 检查更新;不带 check 时安装最新版(面板未运行时先启动)并等待每一步结果\n\n本机\n status [--full] 概览:服务、版本、开机自启、登录入口、托管账号;--full 输出面板的完整状态\n service start|stop|restart 只启停共议服务(网站与讨论服务)\n autostart on|off 登录 Windows 时自动启动\n\n管理员入口\n site status 本地网页与线上网站的地址\n site connect <站点> [绑定令牌] 绑定线上网站(管理员外出用);在部署该网站的电脑上可不填令牌\n site disconnect 解绑线上网站,已配对的设备不能再连到这台电脑\n\n登录入口与访问方式(需打开托管管理)\n entry start|stop 启动或停止登录入口\n entry open|close relay|tunnel 开启或关闭访问方式:线上网站 | 自有域名,两种可同时开启\n entry join <接入码> 用接入码接入线上站点并开启线上网站\n entry code [--config <wrangler.jsonc>] [--site <地址>] 在部署线上站点的电脑上生成接入码(不填用上次的)\n entry tunnel <域名> [隧道名] 设置自有域名(Cloudflare 隧道),输出授权链接;域名须已托管在 Cloudflare\n entry tunnel status 查看自有域名设置的进度\n runtime sync 同步隔离账号的程序副本\n\n托管账号\n account list\n account add <名> [--no-isolate] [--no-start] 创建、隔离、初始化 AI 环境、开启入口保护、启动;输出一次性密码。\n 中途失败时解决后重新执行同一命令,从缺少的步骤接着做\n account start|stop|disable|enable|remove|password <名>\n account isolate|unisolate|protect|unprotect <名>\n\n命令行登录(目标 owner 为管理员自己,否则为托管账号名)\n login status <目标> 各程序的登录状态,以及每个程序可用的登录方式\n login set <目标> <claude|codex> <方式> --set 字段=值 ... 如 login set alice claude setup_token --set token=sk-ant-oat01-…\n login start <目标> <程序> <方式> 浏览器登录:输出链接,之后用 login submit 提交授权码或回调地址\n login submit <作业> <文本> / login progress <作业> / login cancel <作业>\n logout <目标> <程序>\n\nAPI 密钥、技能、工作流、系统提示词(目标同上)\n key list <目标> / key add <目标> --base-url <地址> --key <密钥> / key remove <目标> <编号>\n skill library / skill import <文件夹或.zip> / skill delete <名>\n skill list <目标> / skill install <目标> <名>... / skill remove <目标> <名>...\n workflow list <目标> / workflow install <目标>\n prompt get <目标> / prompt set <目标> --file <文件> [--group <键>] 管理员的提示词按组保存(见 prompt get)\n prompt default get / prompt default set --file <文件> 新托管账号的默认系统提示词\n\n结果以 JSON 输出。--data 指定管理员服务目录(默认 ~/.codiscuss)。\n": "Usage: codiscuss admin <command> [arguments] (matches admin panel actions; the panel must be running except for start and stop)\nSteps requiring administrator rights (creating or deleting Windows users) run directly in an administrator terminal or administrator SSH session. Otherwise, approve the prompt on the computer's desktop.\n\nStart and exit (panel need not be running)\n start Start CoDiscuss: service, panel and tray icon, sign-in entry and tunnel (in the desktop session)\n stop Exit panel and tray icon, sign-in entry, tunnel and service; hosted instances keep running\n restart Run stop, then start\n update [check] Check for updates; omit check to install the latest version and wait for results (starts the panel if needed)\n\nLocal\n status [--full] Show service, version, startup, sign-in entry and hosted accounts; --full returns full panel state\n service start|stop|restart Start or stop only the CoDiscuss service (site and discussion service)\n autostart on|off Start automatically at Windows sign-in\n\nAdministrator entry\n site status Addresses of the local page and the online site\n site connect <site> [binding token] Bind the online site (to use this computer while away); the token is optional on the computer that deployed the site\n site disconnect Unbind the online site; paired devices can no longer reach this computer\n\nSign-in entry and access methods (hosting must be enabled)\n entry start|stop Start or stop the sign-in entry\n entry open|close relay|tunnel Turn an access method on or off: online site | own domain; both can be on\n entry join <code> Connect to an online site with an access code and turn on the online site\n entry code [--config <wrangler.jsonc>] [--site <address>] Generate an access code on the deployment computer (defaults to last settings)\n entry tunnel <domain> [tunnel-name] Configure a Cloudflare Tunnel and show the authorization link; domain must be hosted on Cloudflare\n entry tunnel status Show domain setup progress\n runtime sync Sync program copies for isolated accounts\n\nHosted accounts\n account list\n account add <name> [--no-isolate] [--no-start] Create, isolate, initialize AI environment, protect and start; show password once\n On failure, fix the cause and rerun the same command to resume missing steps\n account start|stop|disable|enable|remove|password <name>\n account isolate|unisolate|protect|unprotect <name>\n\nCLI sign-ins (target owner is the admin; otherwise use a hosted account name)\n login status <target> Show each app's sign-in status and available methods\n login set <target> <claude|codex> <method> --set field=value ... e.g. login set alice claude setup_token --set token=sk-ant-oat01-…\n login start <target> <app> <method> Browser sign-in: show a link; use login submit for the authorization code or callback URL\n login submit <job> <text> / login progress <job> / login cancel <job>\n logout <target> <app>\n\nAPI keys, skills, workflows and system prompts (same target convention)\n key list <target> / key add <target> --base-url <address> --key <key> / key remove <target> <id>\n skill library / skill import <folder-or.zip> / skill delete <name>\n skill list <target> / skill install <target> <name>... / skill remove <target> <name>...\n workflow list <target> / workflow install <target>\n prompt get <target> / prompt set <target> --file <file> [--group <key>] Admin prompts are saved by group (see prompt get)\n prompt default get / prompt default set --file <file> Default system prompt for new hosted accounts\n\nResults are JSON. --data sets the admin service folder (default ~/.codiscuss).\n",
29
29
  "管理面板没有在运行:在这台电脑的桌面上运行 codiscuss panel open,或从任务栏图标打开": "The admin panel is not running. Run codiscuss panel open on this computer's desktop, or open it from the tray icon.",
30
30
  "管理面板没有响应:在这台电脑的桌面上运行 codiscuss panel open": "The admin panel did not respond. Run codiscuss panel open on this computer's desktop.",
31
31
  "管理面板拒绝了钥匙(面板可能刚重启):稍后重试": "The admin panel rejected the key (it may have just restarted). Try again shortly.",
@@ -86,7 +86,7 @@ export default {
86
86
  "已更新本机技能": "Local skills updated",
87
87
  "已启动本机服务": "Local service started",
88
88
  "已重新启动登录入口": "Sign-in entry restarted",
89
- "入口没有重新启动,在“概览”页“托管”下点“启动”看原因": "The entry did not restart. Click Start under Hosting on the Overview page to see why.",
89
+ "入口没有重新启动,在“概览 → 登录入口 → 托管账号入口”点“启动”看原因": "The entry did not restart. Click Start under Overview → Sign-in entry → Hosted account entry to see why.",
90
90
  "已同步隔离账号的程序副本": "Program copies synced for isolated accounts",
91
91
  "已更新 {value1} 的技能": "Skills updated for {value1}",
92
92
  "已重启 {value1} 的实例": "Instance restarted for {value1}",
@@ -95,7 +95,7 @@ export default {
95
95
  "这个账号开启了入口保护,但入口读不到它的密钥": "This account has entry protection enabled, but the entry cannot read its key",
96
96
  "实例没有按入口保护启动起来(启动失败,或密钥对不上)": "Instance did not start with entry protection (startup failed or the key does not match)",
97
97
  "实例没有启动起来": "Instance did not start",
98
- "还没有安装隔离账号的程序副本,请先在“概览 → 托管 → 程序副本”中同步": "Program copies for isolated accounts are not installed. Sync them under Overview → Hosting → Program copies first.",
98
+ "还没有安装隔离账号的程序副本,请先在“概览 → 登录入口 → 托管账号入口”中同步": "Program copies for isolated accounts are not installed yet. Sync them under Overview → Sign-in entry → Hosted account entry first.",
99
99
  "没有读到结果": "No result received",
100
100
  "技能库里没有 {value1}": "Skill library does not contain {value1}",
101
101
  "未知操作:{value1}": "Unknown action: {value1}",
@@ -104,7 +104,7 @@ export default {
104
104
  "入口保护目前只支持 Windows": "Entry protection currently supports Windows only",
105
105
  "无法确认实例是否在运行(端口没有回应),入口保护没有改动": "Cannot confirm whether the instance is running (port did not respond); entry protection was not changed",
106
106
  "实例没有停下来,入口保护没有改动": "The instance did not stop; entry protection was not changed",
107
- "外网访问已开启,{value1} 未隔离(以你的身份运行),不能启动:请先隔离该账号,或关闭登录入口的线上中转和自有域名": "Remote access is enabled, but {value1} is not isolated (runs as you) and cannot start. Isolate it first, or turn off the sign-in entry's online relay and own domain.",
107
+ "外网访问已开启,{value1} 未隔离(以你的身份运行),不能启动:请先隔离该账号,或关闭登录入口的线上网站和自有域名": "Remote access is enabled, but {value1} is not isolated (runs as you) and cannot start. Isolate it first, or turn off the sign-in entry's online site and own domain.",
108
108
  "启动": "start",
109
109
  "停止": "stop",
110
110
  "实例{value1}失败(退出码 {value2})": "Instance {value1} failed (exit code {value2})",
@@ -131,15 +131,19 @@ export default {
131
131
  "登录入口没有在运行:点上面的“启动”": "The sign-in entry is not running. Click Start above.",
132
132
  "这台电脑还没有接入线上站点:先用接入码接入": "This computer has not connected to an online site. Connect with an access code first.",
133
133
  "还没有设好 Cloudflare 隧道:先点“设置”填写你的域名": "Cloudflare Tunnel is not configured yet. Click Configure and enter your domain first.",
134
- "未隔离的账号正在运行({value1}),它们以你的身份运行,开启线上中转或自有域名前请先停止或隔离": "Accounts without isolation are running ({value1}). They run as you; stop or isolate them before turning on the online relay or your own domain.",
134
+ "未隔离的账号正在运行({value1}),它们以你的身份运行,开启线上网站或自有域名前请先停止或隔离": "Accounts without isolation are running ({value1}). They run as you; stop or isolate them before turning on the online site or your own domain.",
135
135
  "未知的访问方式:{value1}": "Unknown access method: {value1}",
136
+ "v{value1} 刚发布,npm 还在准备安装包,请过几分钟再更新;当前版本和服务没有受影响": "v{value1} was just published and npm is still preparing its package. Try updating again in a few minutes; the current version and services were not affected.",
136
137
  "找不到线上站点的部署配置:填写源码仓库里 .wrangler\\deploy\\wrangler.jsonc 的完整路径": "Online site deployment config not found. Enter the full path to .wrangler\\deploy\\wrangler.jsonc in the source repository.",
137
138
  "站点地址格式不对,例如 https://xxx.pages.dev": "Invalid site address, e.g. https://xxx.pages.dev",
138
139
  "没有生成绑定令牌": "No binding token generated",
139
140
  "接入码不对:应是部署线上站点的电脑上生成的一整串,形如 https://xxx.pages.dev/#codiscuss-bind=…": "Invalid access code. Use the full string generated on the online site's deployment computer, such as https://xxx.pages.dev/#codiscuss-bind=…",
140
141
  "已接入 {value1}": "Connected to {value1}",
141
142
  "入口地址 {value1}": "Entry address: {value1}",
142
- "已开启线上中转": "Online relay turned on",
143
+ "这台电脑已绑定 {value1},请先解绑": "This computer is already bound to {value1}. Unbind it first",
144
+ "这个地址不是共议线上站点:{value1}": "This address is not a CoDiscuss online site: {value1}",
145
+ "托管账号入口的线上网站还开着,请先关闭它": "The hosted accounts' online site is still on. Turn it off first",
146
+ "已开启线上网站": "Online site turned on",
143
147
  "{value1} 没有提供入口地址:请部署线上站点的人在部署配置里设置 ENTRY_URL 并重新发布": "{value1} did not provide an entry address. Ask the site deployer to set ENTRY_URL in the deployment config and redeploy.",
144
148
  "{value1} 不是共议的入口 Worker,或现在连不上": "{value1} is not a CoDiscuss entry Worker, or is currently unreachable",
145
149
  "绑定失败(退出码 {value1})": "Binding failed (exit code {value1})",
@@ -13,11 +13,13 @@
13
13
  */
14
14
  import { spawnSync } from 'node:child_process';
15
15
  import { randomBytes } from 'node:crypto';
16
- import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
16
+ import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
17
17
  import { homedir, tmpdir } from 'node:os';
18
18
  import { basename, dirname, join } from 'node:path';
19
19
  import { fileURLToPath } from 'node:url';
20
20
 
21
+ import { NO_DESKTOP_VARIABLE } from './adapters/profiles.mjs';
22
+
21
23
  const USERS_FILE = 'os-users.json';
22
24
  const USER_PREFIX = 'cd-';
23
25
  // Windows local user names are at most 20 characters.
@@ -463,13 +465,22 @@ export function install_shared_runtime(python_source = '', { run = run_powershel
463
465
  return { installed, missing, warnings };
464
466
  }
465
467
 
466
- /** Which shared programs are installed: { claude, codex, agy, app, python } booleans, and the shared program's version. */
468
+ /** The AI programs the owner upgraded after the shared copy was made: they update themselves, apart from this program. */
469
+ export function outdated_programs(clis = cli_sources()) {
470
+ const modified = path => { try { return statSync(path).mtimeMs; } catch { return 0; } };
471
+ return Object.values(clis).filter(cli => {
472
+ const copy = modified(cli.executable || cli.target);
473
+ return copy > 0 && modified(cli.program || cli.source) > copy;
474
+ }).map(cli => cli.label);
475
+ }
476
+
477
+ /** Which shared programs are installed ({ claude, codex, agy, app, python } booleans), the shared program's version, and which are behind. */
467
478
  export function shared_cli_state() {
468
479
  const paths = shared_paths();
469
480
  let app_version = '';
470
481
  try { app_version = JSON.parse(readFileSync(join(APP_ROOT, 'package.json'), 'utf8')).version; } catch { /* not installed */ }
471
482
  return { ...Object.fromEntries(Object.entries(cli_sources()).map(([key, cli]) => [key, existsSync(cli.executable || cli.target)])),
472
- app: existsSync(paths.local_script), python: existsSync(paths.python), app_version };
483
+ app: existsSync(paths.local_script), python: existsSync(paths.python), app_version, outdated: outdated_programs() };
473
484
  }
474
485
 
475
486
  // ---- The instance of an account with its own Windows user: a scheduled task ----
@@ -573,6 +584,7 @@ export function start_instance_as_user(data, account, service_home, local_script
573
584
  if (-not (Test-Path -LiteralPath $flag)) { exit 0 }
574
585
  $env:DISCUSS_SERVICE_HOME = ${quote(service_home)}
575
586
  $env:Path = ${quote(`${COMMAND_ROOT};`)} + $env:Path
587
+ $env:${NO_DESKTOP_VARIABLE} = '1'
576
588
  ${key_file ? `$env:DISCUSS_ENTRY_KEY_FILE = ${quote(key_file)}\n` : ''}Set-Location -LiteralPath ${quote(service_home)}
577
589
  & ${quote(node)} ${quote(local_script)} run
578
590
  exit $LASTEXITCODE
@@ -2,7 +2,7 @@
2
2
  import { createHash } from 'node:crypto';
3
3
  import { closeSync, fstatSync, openSync, readdirSync, readFileSync, readSync, realpathSync, statSync } from 'node:fs';
4
4
  import { isAbsolute, posix, relative, resolve } from 'node:path';
5
- import { adapter_profile } from './adapters/profiles.mjs';
5
+ import { adapter_capabilities, adapter_profile } from './adapters/profiles.mjs';
6
6
  import { PINYIN_TABLE } from './pinyin_table.mjs';
7
7
 
8
8
  const DIRECTORY_PAGE_SIZE = 200;
@@ -184,12 +184,13 @@ export function outside_directory(config, profile) {
184
184
  /**
185
185
  * Whether the room's directories stay read-only for this member by the software's own limits, not only by its task
186
186
  * text: at 只读 for any software whose levels the runner sets, at 可写 only where a sandbox or the file tools hold
187
- * (`limits_directories`); never for an App, a manual member's own permissions, 自动 or 全放开.
187
+ * (`limits_directories`); never for an App, a manual member's own permissions, 自动, 全放开 or software running without
188
+ * its sandbox here (`no_sandbox`).
188
189
  */
189
190
  export function read_only_enforced(profile) {
190
- const facts = adapter_profile(profile?.adapter);
191
- if (!facts?.access_levels) return false;
192
- return profile.project_access === 'read' || (profile.project_access === 'write' && Boolean(facts.capabilities.limits_directories));
191
+ const facts = adapter_profile(profile?.adapter), capabilities = adapter_capabilities(profile?.adapter);
192
+ if (!facts?.access_levels || capabilities.no_sandbox) return false;
193
+ return profile.project_access === 'read' || (profile.project_access === 'write' && Boolean(capabilities.limits_directories));
193
194
  }
194
195
 
195
196
  /** The room's project root, resolved through links and required to be a folder. */
@@ -55,6 +55,16 @@ const LOCAL_HOST = '127.0.0.1';
55
55
  const LOCAL_KEY_URL = 'http://127.0.0.1/yovoice';
56
56
  const LOCAL_LEGACY_KEY_URL = 'http://127.0.0.1:18765';
57
57
  const LOCAL_MODEL = 'qwen3-tts-customvoice-q8';
58
+ // Optional second model: VoxCPM2 has no built-in speakers, so each voice is a fixed description, and the fixed seed keeps
59
+ // the voice from drifting between the paragraphs of one reading.
60
+ const LOCAL_DESIGN_MODEL = 'voxcpm2-bf16';
61
+ const LOCAL_DESIGN_SEED = 42;
62
+ const LOCAL_DESIGNED_VOICES = {
63
+ voxcpm2_soft_female: '成年女性有声书朗读者,声音柔和沉静,语速偏慢,语调平缓,情绪起伏很小,自然松弛,不表演不夸张',
64
+ voxcpm2_low_female: '中年女性有声书朗读者,声线略低,从容平稳,语速偏慢,语气淡然,情绪起伏很小,不表演不夸张',
65
+ voxcpm2_elderly_male: '六十多岁的老年男性,嗓音低沉略带沙哑,说话很慢,像老人在家里平平淡淡地回忆往事,朴素自然,没有播音腔',
66
+ voxcpm2_middle_aged_male: '五十岁左右的普通中年男性,声音低沉厚实,说话很慢,语气平淡朴实,像和熟人闲聊,没有播音腔,不像短视频解说',
67
+ };
58
68
  const LOCAL_DIR = 'yovoice';
59
69
  const LOCAL_START_MS = 30_000;
60
70
  const LOCAL_POLL_MS = 500;
@@ -127,6 +137,8 @@ const LOCAL_VOICES = [
127
137
  ['Vivian', 'Vivian · 明亮女声'], ['Serena', 'Serena · 温柔女声'], ['Uncle_Fu', 'Uncle Fu · 低沉男声'],
128
138
  ['Dylan', 'Dylan · 北京青年男声'], ['Eric', 'Eric · 成都男声'], ['Ryan', 'Ryan · 英语男声'], ['Aiden', 'Aiden · 美式男声'],
129
139
  ['Ono_Anna', 'Ono Anna · 日语女声'], ['Sohee', 'Sohee · 韩语女声'],
140
+ ['voxcpm2_soft_female', 'VoxCPM2 · 柔和女声 / Soft female'], ['voxcpm2_low_female', 'VoxCPM2 · 低声线女声 / Low female'],
141
+ ['voxcpm2_elderly_male', 'VoxCPM2 · 老年男声 / Elderly male'], ['voxcpm2_middle_aged_male', 'VoxCPM2 · 中年男声 / Middle-aged male'],
130
142
  ];
131
143
  // gpt-4o-mini-tts's built-in voices; the docs call them optimized for English and recommend marin or cedar.
132
144
  const OPENAI_VOICES = [
@@ -314,11 +326,18 @@ export function wav_with_silence(wav, silence_ms) {
314
326
  return result;
315
327
  }
316
328
 
317
- /** Ask the local service for one paragraph; the answer is a 24 kHz mono WAV. */
329
+ /** The generation request for a voice; a designed voice's description replaces the tone instruction. */
330
+ function local_generation(text, speaker, context) {
331
+ const design = LOCAL_DESIGNED_VOICES[speaker];
332
+ if (design) return { text, modelId: LOCAL_DESIGN_MODEL, voxMode: 'design', voiceDescription: design, language: 'zh', seed: LOCAL_DESIGN_SEED };
333
+ return { text, modelId: LOCAL_MODEL, speaker, language: 'zh', ...(context ? { voiceDescription: context } : {}) };
334
+ }
335
+
336
+ /** Ask the local service for one paragraph; the answer is a mono WAV (24 kHz from Qwen3-TTS, 48 kHz from VoxCPM2). */
318
337
  function local_generate({ home, key, text, speaker, context }, request) {
319
338
  return request(`${local_url(home, 'tts')}/v1/generate`, { method: 'POST', redirect: 'error', signal: AbortSignal.timeout(TTS_TIMEOUT_MS),
320
339
  headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
321
- body: JSON.stringify({ text, modelId: LOCAL_MODEL, speaker, language: 'zh', ...(context ? { voiceDescription: context } : {}) }) });
340
+ body: JSON.stringify(local_generation(text, speaker, context)) });
322
341
  }
323
342
 
324
343
  /**
@@ -432,6 +451,7 @@ async function local_once({ home, key, text, speaker, context, silence }, { requ
432
451
  if (response.status === 409) throw new Error('本机语音一直在忙,请稍后再试');
433
452
  if (!response.ok) {
434
453
  const code = (await response.json().catch(() => ({}))).error?.code;
454
+ if (code === '@yovoice.error.modelRequired') throw new Error('这个音色的模型尚未安装:请让本机 AI 按 local-tts-setup 技能安装');
435
455
  throw new Error(`本机语音合成失败(HTTP ${response.status}${code ? ` ${code}` : ''}),请查看 ${join(home, LOCAL_DIR, 'data', 'logs')}`);
436
456
  }
437
457
  const audio = await convert(home, wav_with_silence(Buffer.from(await response.arrayBuffer()), silence));