ai_co_discuss 0.4.35 → 0.4.37
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/docs/runner.md +1 -1
- package/package.json +1 -1
- package/runner/account_env.mjs +2 -1
- package/runner/admin_panel.mjs +68 -7
- package/web/admin.css +1 -1
- package/web/admin.js +13 -13
- package/web/modern.js +2 -2
package/docs/runner.md
CHANGED
|
@@ -41,7 +41,7 @@ codiscuss setup
|
|
|
41
41
|
|
|
42
42
|
不选项目目录时,房间使用**草稿空间**:程序在草稿空间里为这个房间单独建一个文件夹(房间名加短编号)并作为它的项目目录,成员生成的文件存在这里,“文件”页可以浏览,成员也可以设为可写。草稿空间默认在服务目录旁(`~/.codiscuss-workspace`)。房间画的图除了作为附件随消息发出,成员对项目目录可写时、或房间在草稿空间时,还会在该目录的 `images/` 下留一份。
|
|
43
43
|
|
|
44
|
-
Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有“桌面快捷方式”:还没有时默认勾选“创建‘共议’快捷方式”,已有时显示为“重新生成”、默认不勾(非交互运行不创建);也可随时运行 `codiscuss launcher` 生成或重新生成。它会生成“共议”程序,桌面和开始菜单各有一个快捷方式,双击即可启动服务并打开网站。服务运行时任务栏右下角有共议图标:左键打开**管理面板**(也可运行 `codiscuss panel`),右键可打开共议、重启或关闭服务。管理面板分两页:“概览”显示本机服务状态(可启动、重启、停止)、检查并安装新版本(同时更新你的房间技能)、开关“登录 Windows
|
|
44
|
+
Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有“桌面快捷方式”:还没有时默认勾选“创建‘共议’快捷方式”,已有时显示为“重新生成”、默认不勾(非交互运行不创建);也可随时运行 `codiscuss launcher` 生成或重新生成。它会生成“共议”程序,桌面和开始菜单各有一个快捷方式,双击即可启动服务并打开网站。服务运行时任务栏右下角有共议图标:左键打开**管理面板**(也可运行 `codiscuss panel`),右键可打开共议、重启或关闭服务。管理面板分两页:“概览”显示本机服务状态(可启动、重启、停止)、检查并安装新版本(同时更新你的房间技能)、开关“登录 Windows 时自动启动”;“账号”页左侧选账号,“管理员”里管理你自己的 Claude Code / Codex / Antigravity 登录(可直接登录、切换方式、退出;Claude Code 推荐 Setup Token)、API 密钥和已安装的技能(可从技能库添加);面板只能在这台电脑上打开。第一次需要在“设置 → 个性化 → 任务栏 → 其他系统托盘图标”里打开“共议”,图标才会常驻任务栏。
|
|
45
45
|
|
|
46
46
|
给别人开账号用这台电脑上的 AI 时,在 setup 的“安装配置”里勾选“托管管理”(或加 `--hosting`,`--no-hosting` 关闭;选择会记住),面板会多出“托管账号”页:
|
|
47
47
|
- 点“新建账号”,填账号名,默认“隔离”(给它一个独立的 Windows 用户,电脑会弹出一次管理员确认);向导会一次装好它要用的程序、房间技能、系统提示词和随包工作流,并启动它的网站,最后显示一次密码。
|
package/package.json
CHANGED
package/runner/account_env.mjs
CHANGED
|
@@ -113,7 +113,8 @@ function describe(folder) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function status() {
|
|
116
|
-
|
|
116
|
+
// Hidden folders (Codex keeps its own under .system) are not skills of this account.
|
|
117
|
+
const skills = existsSync(SKILLS_DIR) ? readdirSync(SKILLS_DIR, { withFileTypes: true }).filter(entry => (entry.isDirectory() || entry.isSymbolicLink()) && !entry.name.startsWith('.'))
|
|
117
118
|
.map(entry => ({ name: entry.name, discussion: SKILLS.includes(entry.name), description: describe(join(SKILLS_DIR, entry.name)) })) : [];
|
|
118
119
|
return { skills, prompt: existsSync(PROMPT) ? readFileSync(PROMPT, 'utf8') : '', layout: layout_status() };
|
|
119
120
|
}
|
package/runner/admin_panel.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { spawn, spawnSync } from 'node:child_process';
|
|
|
11
11
|
import { randomBytes } from 'node:crypto';
|
|
12
12
|
import { closeSync, copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, openSync, realpathSync, readdirSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
13
13
|
import http from 'node:http';
|
|
14
|
-
import { tmpdir } from 'node:os';
|
|
14
|
+
import { homedir, tmpdir } from 'node:os';
|
|
15
15
|
import { dirname, extname, join, resolve } from 'node:path';
|
|
16
16
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
17
17
|
import { parseArgs } from 'node:util';
|
|
@@ -20,6 +20,7 @@ import { account_home, add_account, data_home, entry_settings, entry_status, ins
|
|
|
20
20
|
instance_key, set_account_disabled, set_account_protected, start_entry, stop_entry } from '../gateway/gateway.mjs';
|
|
21
21
|
import { verified_connection } from './entry_client.mjs';
|
|
22
22
|
import { API_PROVIDERS, save_api_key } from './discussion_api.mjs';
|
|
23
|
+
import { STT_PROVIDERS, TTS_PROVIDERS } from './tts_providers.mjs';
|
|
23
24
|
import { apply_login, cancel_login, LOGIN_METHODS, login_progress, login_status, logout, start_login, submit_login } from './cli_login.mjs';
|
|
24
25
|
import { create_os_user, install_shared_runtime, instance_key_file, place_instance_key, read_os_users, remove_os_user, run_as_user, shared_cli_state, shared_executables, shared_paths,
|
|
25
26
|
start_instance_as_user } from './os_users.mjs';
|
|
@@ -105,8 +106,8 @@ export function newer_version(a, b) {
|
|
|
105
106
|
/** Run a command to its end, failing with the last of its output. */
|
|
106
107
|
function run_command(command, args) {
|
|
107
108
|
return new Promise((done, fail) => {
|
|
108
|
-
//
|
|
109
|
-
const child = spawn(command, args, {
|
|
109
|
+
// No shell: an unquoted path with a space (C:\Program Files\nodejs\node.exe) would be cut at the space.
|
|
110
|
+
const child = spawn(command, args, { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
110
111
|
let output = '';
|
|
111
112
|
child.stdout.on('data', chunk => { output = (output + chunk).slice(-4000); });
|
|
112
113
|
child.stderr.on('data', chunk => { output = (output + chunk).slice(-4000); });
|
|
@@ -372,6 +373,46 @@ function owner_env(action, request = {}, folders = {}) {
|
|
|
372
373
|
} finally { rmSync(job, { recursive: true, force: true }); }
|
|
373
374
|
}
|
|
374
375
|
|
|
376
|
+
// The owner's system prompts: one file per program, often hard links to one file (the layout account_env.mjs sets up).
|
|
377
|
+
const OWNER_PROMPTS = [['claude', 'Claude Code', ['.claude', 'CLAUDE.md']], ['codex', 'Codex', ['.codex', 'AGENTS.md']],
|
|
378
|
+
['agy', 'Antigravity', ['.gemini', 'config', 'AGENTS.md']]];
|
|
379
|
+
|
|
380
|
+
/** A file's identity, the same for its hard links; '' when it does not exist. */
|
|
381
|
+
function file_id(path) {
|
|
382
|
+
try { const stat = statSync(path, { bigint: true }); return `${stat.dev}:${stat.ino}`; } catch { return ''; }
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* The owner's system prompts, grouped by file: hard links to one file form one group, edited once. Each group is
|
|
387
|
+
* { key, programs: [{ key, label, path }], exists, text }; `key` is the first program's, for saving.
|
|
388
|
+
*/
|
|
389
|
+
export function owner_prompts(home = homedir()) {
|
|
390
|
+
const groups = [];
|
|
391
|
+
for (const [key, label, parts] of OWNER_PROMPTS) {
|
|
392
|
+
const path = join(home, ...parts), id = file_id(path);
|
|
393
|
+
const group = id && groups.find(item => item.id === id);
|
|
394
|
+
const shown = join('~', ...parts);
|
|
395
|
+
if (group) { group.programs.push({ key, label, path: shown }); continue; }
|
|
396
|
+
groups.push({ id, key, programs: [{ key, label, path: shown }], exists: Boolean(id), text: id ? readFileSync(path, 'utf8') : '' });
|
|
397
|
+
}
|
|
398
|
+
return groups.map(({ id: _id, ...group }) => group);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Save one of the owner's system prompts in place, which keeps its hard links. `original` is the text the page read: a
|
|
403
|
+
* file changed since (edited elsewhere) is refused rather than overwritten.
|
|
404
|
+
*/
|
|
405
|
+
export function save_owner_prompt(key, text, original, home = homedir()) {
|
|
406
|
+
const entry = OWNER_PROMPTS.find(([name]) => name === key);
|
|
407
|
+
if (!entry) throw new Error(`未知程序:${key}`);
|
|
408
|
+
const path = join(home, ...entry[2]);
|
|
409
|
+
const current = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
|
410
|
+
if (current !== String(original ?? '')) throw Object.assign(new Error('文件已在别处被修改,请重新读取后再编辑'), { status: 409 });
|
|
411
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
412
|
+
writeFileSync(path, String(text ?? ''));
|
|
413
|
+
return owner_prompts(home);
|
|
414
|
+
}
|
|
415
|
+
|
|
375
416
|
function owner_skills(data, { install = [], remove = [] } = {}) {
|
|
376
417
|
return owner_env('skills', { remove }, library_folders(data, install));
|
|
377
418
|
}
|
|
@@ -437,6 +478,18 @@ function run_instance(data, name, command) {
|
|
|
437
478
|
const KEY_FILE = /^[a-f0-9-]{36}\.json$/i;
|
|
438
479
|
|
|
439
480
|
/** The keys saved in an instance, newest first, with only the last characters of each key. */
|
|
481
|
+
/**
|
|
482
|
+
* What a saved key is for when it belongs to a speech service, read from its address: the speech services keep their keys
|
|
483
|
+
* in the same folder as the model API keys. Returns { label, uses: ['语音朗读' | '语音识别'], local } or null.
|
|
484
|
+
*/
|
|
485
|
+
export function key_use(base_url) {
|
|
486
|
+
const root = String(base_url || '').replace(/\/+$/, '');
|
|
487
|
+
const match = list => list.find(item => [item.key_base_url, item.legacy_key_base_url].some(url => url && url.replace(/\/+$/, '') === root));
|
|
488
|
+
const speak = match(TTS_PROVIDERS), listen = match(STT_PROVIDERS), provider = speak || listen;
|
|
489
|
+
if (!provider) return null;
|
|
490
|
+
return { label: provider.local ? '本机语音服务' : provider.label, uses: [speak && '语音朗读', listen && '语音识别'].filter(Boolean), local: Boolean(provider.local) };
|
|
491
|
+
}
|
|
492
|
+
|
|
440
493
|
export function list_keys(service) {
|
|
441
494
|
const directory = join(service, 'api-keys');
|
|
442
495
|
if (!existsSync(directory)) return [];
|
|
@@ -444,7 +497,8 @@ export function list_keys(service) {
|
|
|
444
497
|
const path = join(directory, name);
|
|
445
498
|
try {
|
|
446
499
|
const saved = JSON.parse(readFileSync(path, 'utf8'));
|
|
447
|
-
return { ref: name.slice(0, -5), base_url: saved.base_url, managed: saved.managed === true, tail: String(saved.api_key || '').slice(-4), time: statSync(path).mtimeMs
|
|
500
|
+
return { ref: name.slice(0, -5), base_url: saved.base_url, managed: saved.managed === true, tail: String(saved.api_key || '').slice(-4), time: statSync(path).mtimeMs,
|
|
501
|
+
speech: key_use(saved.base_url) };
|
|
448
502
|
} catch { return null; }
|
|
449
503
|
}).filter(Boolean).sort((left, right) => right.time - left.time);
|
|
450
504
|
}
|
|
@@ -485,7 +539,7 @@ function cookie(request, name) {
|
|
|
485
539
|
*/
|
|
486
540
|
export function create_panel({ data, key, port, ops = {}, sessions = new Set() }) {
|
|
487
541
|
const op = { list_accounts, add_account, reset_password, set_account_disabled, remove_account, run_instance, create_os_user, remove_os_user,
|
|
488
|
-
login_status, apply_login, logout, start_login, login_progress, submit_login, cancel_login, install_runtime, prepare_account, account_env, account_skills, owner_env, owner_skills, shared_cli_state,
|
|
542
|
+
login_status, apply_login, logout, start_login, login_progress, submit_login, cancel_login, install_runtime, prepare_account, account_env, account_skills, owner_env, owner_skills, owner_prompts, save_owner_prompt, shared_cli_state,
|
|
489
543
|
save_api_key, list_keys, remove_key, use_shared_programs, service_overview, run_owner_service, latest_version, begin_update,
|
|
490
544
|
autostart_enabled, set_autostart, entry_overview, start_entry, stop_entry, protect_account, start_verified, hand_over: () => {}, ...ops };
|
|
491
545
|
const hosts = new Set([`127.0.0.1:${port}`, `localhost:${port}`]);
|
|
@@ -534,6 +588,8 @@ export function create_panel({ data, key, port, ops = {}, sessions = new Set() }
|
|
|
534
588
|
if (section === 'owner') {
|
|
535
589
|
if (method === 'GET' && name === 'env') return op.owner_env('status');
|
|
536
590
|
if (method === 'POST' && name === 'env' && action === 'skills') return op.owner_skills(data, { install: body.install || [], remove: body.remove || [] });
|
|
591
|
+
if (method === 'GET' && name === 'prompts') return op.owner_prompts();
|
|
592
|
+
if (method === 'POST' && name === 'prompts') return op.save_owner_prompt(String(body.key || ''), body.text, body.original);
|
|
537
593
|
if (method === 'GET' && name === 'keys') return op.list_keys(data);
|
|
538
594
|
if (method === 'POST' && name === 'keys' && action === 'remove') { op.remove_key(data, String(body.ref || '')); return { ok: true }; }
|
|
539
595
|
if (method === 'POST' && name === 'keys') return op.save_api_key(data, { base_url: body.base_url, api_key: body.api_key });
|
|
@@ -624,7 +680,7 @@ export function create_panel({ data, key, port, ops = {}, sessions = new Set() }
|
|
|
624
680
|
response.end(readFileSync(file));
|
|
625
681
|
} catch (error) {
|
|
626
682
|
if (response.headersSent) response.destroy();
|
|
627
|
-
else send_json(response, 400, { error: error.message });
|
|
683
|
+
else send_json(response, error.status || 400, { error: error.message });
|
|
628
684
|
}
|
|
629
685
|
});
|
|
630
686
|
}
|
|
@@ -776,7 +832,12 @@ function open_panel_window(data, url, look_first = true) {
|
|
|
776
832
|
function launch_panel_window(data, url) {
|
|
777
833
|
const edge = EDGE_PATHS.find(path => existsSync(path));
|
|
778
834
|
if (!edge) return open_browser(url);
|
|
779
|
-
|
|
835
|
+
const profile = join(data, 'panel-window');
|
|
836
|
+
// Edge keeps the size and place the owner left the window at (app_window_placement), but --window-size overrides it,
|
|
837
|
+
// so the default size is given only until Edge has kept one.
|
|
838
|
+
let placed = false;
|
|
839
|
+
try { placed = readFileSync(join(profile, 'Default', 'Preferences'), 'utf8').includes('"app_window_placement"'); } catch { placed = false; }
|
|
840
|
+
spawn(edge, [`--app=${url}`, `--user-data-dir=${profile}`, ...(placed ? [] : [`--window-size=${WINDOW_SIZE}`]), '--no-first-run', '--no-default-browser-check', '--lang=zh-CN', '--disable-features=Translate,msTranslate'],
|
|
780
841
|
{ detached: true, stdio: 'ignore', windowsHide: false }).unref();
|
|
781
842
|
}
|
|
782
843
|
|