ai_co_discuss 0.6.2 → 0.6.4
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/.agents/skills/discuss-host/references/room.md +1 -1
- package/.agents/skills/discuss-participant/references/situations.md +1 -1
- package/.agents/skills/screen-acceptance/SKILL.md +1 -1
- package/backend/room_search.py +21 -6
- package/docs/en/guide/cli.md +2 -1
- package/docs/en/guide/external-members.md +3 -1
- package/docs/en/guide/members.md +1 -1
- package/docs/en/guide/rooms.md +8 -8
- package/docs/en/guide/steward.md +3 -3
- package/docs/en/guide/workflows.md +1 -0
- package/docs/en/guide/working.md +2 -2
- package/docs/guide/cli.md +2 -1
- package/docs/guide/external-members.md +3 -1
- package/docs/guide/members.md +1 -1
- package/docs/guide/rooms.md +8 -8
- package/docs/guide/steward.md +3 -3
- package/docs/guide/workflows.md +1 -0
- package/docs/guide/working.md +2 -2
- package/frontend/locales/en/core.json +2 -0
- package/frontend/locales/en/discussion.json +24 -1
- package/frontend/locales/en/room.json +4 -0
- package/frontend/locales/en/steward.json +2 -2
- package/package.json +2 -1
- package/runner/adapters/profiles.mjs +1 -1
- package/runner/codiscuss.mjs +1 -0
- package/runner/discuss.py +3 -1
- package/runner/discussion_launch.mjs +151 -54
- package/runner/external_client.mjs +29 -9
- package/runner/free_runner.mjs +22 -19
- package/runner/i18n_en.mjs +6 -4
- package/runner/image_service.mjs +17 -10
- package/runner/moss_windows.mjs +4 -4
- package/runner/steward.mjs +22 -19
- package/runner/steward_proactive.mjs +30 -5
- package/web/app.js +23 -1
- package/web/backup.js +1 -1
- package/web/i18n.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +90 -90
|
@@ -18,6 +18,7 @@ import { adapter_capabilities, adapter_profile, API_PROVIDERS, lockdown_support
|
|
|
18
18
|
import { correctable_refusals, external_task_text, MAX_REFUSAL_RETRIES, refusal_retry_prompt, TASK_SUBCOMMANDS } from './expert_prompts.mjs';
|
|
19
19
|
import { atomic_json } from './files.mjs';
|
|
20
20
|
import { t } from './i18n.mjs';
|
|
21
|
+
import { model_catalog_reader } from './model_catalog.mjs';
|
|
21
22
|
import { mirror_pin, mirror_proposal, mirror_pull, mirror_rm, mirror_status } from './patch_mirror.mjs';
|
|
22
23
|
|
|
23
24
|
export const WAKES = ['auto', 'ask'];
|
|
@@ -411,14 +412,26 @@ export async function member_api(home, id, method, path, body, deps = {}) {
|
|
|
411
412
|
|
|
412
413
|
// ---- Local commands ----
|
|
413
414
|
|
|
414
|
-
function check_ai(input) {
|
|
415
|
+
function check_ai(home, input) {
|
|
415
416
|
const adapter = String(input.adapter || '');
|
|
416
417
|
const profile = adapter_profile(adapter);
|
|
417
418
|
// The AI reaches the other room only through this computer's codiscuss (a CLI) or this module (the model API's room
|
|
418
419
|
// and repo tools); App windows do neither.
|
|
419
420
|
if (!['cli', 'api'].includes(profile?.kind)) throw failure('ai_unsupported', '外部成员只能派命令行软件(如 Claude Code)或模型 API');
|
|
420
421
|
// An external member takes no prompt of its own (user 2026-11-25): it answers in another person's room by that room's rules.
|
|
421
|
-
|
|
422
|
+
const model = String(input.model || '');
|
|
423
|
+
const service_tier = input.service_tier === undefined ? '' : input.service_tier;
|
|
424
|
+
if (typeof service_tier !== 'string' || (service_tier && !profile.service_tiers?.includes(service_tier))) {
|
|
425
|
+
throw failure('ai_speed_unsupported', '所选软件不支持该速度档位');
|
|
426
|
+
}
|
|
427
|
+
if (model && service_tier && service_tier !== 'default') {
|
|
428
|
+
const software = software_profile(home, { adapter, model });
|
|
429
|
+
const entry = model_catalog_reader(home)({ ...software, adapter })?.find(item => item.id === model);
|
|
430
|
+
if (Array.isArray(entry?.service_tiers) && !entry.service_tiers.includes(service_tier)) {
|
|
431
|
+
throw failure('ai_model_speed_unsupported', '所选模型不支持该速度档位');
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return { adapter, model, effort: String(input.effort || ''), ...(profile.service_tiers ? { service_tier } : {}) };
|
|
422
435
|
}
|
|
423
436
|
|
|
424
437
|
/** The saved model API this AI runs on, as `[participant name, settings]`; empty when this computer has none. */
|
|
@@ -485,7 +498,7 @@ export async function lend(home, { id, duration }, deps = {}) {
|
|
|
485
498
|
/** Accept an invitation: check the computer's fingerprint when the link carries one, redeem with a new key, keep the record. */
|
|
486
499
|
export async function join_invite(home, input, deps = {}) {
|
|
487
500
|
const invite = parse_invite(input.invite, input);
|
|
488
|
-
const ai = check_ai(input);
|
|
501
|
+
const ai = check_ai(home, input);
|
|
489
502
|
const expires_at = lend_until(input.duration || '1h', deps.now?.() ?? Date.now());
|
|
490
503
|
// A conversation this computer's software already holds, picked to carry its context into the room.
|
|
491
504
|
const session_id = String(input.session_id || '');
|
|
@@ -746,7 +759,12 @@ export async function invited_command(home, action, input = {}, deps = {}) {
|
|
|
746
759
|
}
|
|
747
760
|
if (action === 'invited-join') return join_invite(home, input, deps);
|
|
748
761
|
if (action === 'invited-trust') return set_trust(home, input);
|
|
749
|
-
if (action === 'invited-ai') return change_record(home, id, (record, now, store) => {
|
|
762
|
+
if (action === 'invited-ai') return change_record(home, id, (record, now, store) => {
|
|
763
|
+
const ai = { ...record.ai, ...input };
|
|
764
|
+
if (input.adapter !== undefined && !adapter_profile(ai.adapter)?.service_tiers && input.service_tier === undefined) delete ai.service_tier;
|
|
765
|
+
record.ai = check_ai(home, ai);
|
|
766
|
+
return { record: record_view(record, store) };
|
|
767
|
+
});
|
|
750
768
|
if (action === 'invited-pause') return change_record(home, id, (record, now, store) => { record.paused = input.paused !== false; return { record: record_view(record, store) }; });
|
|
751
769
|
if (action === 'invited-approve') return approve(home, input);
|
|
752
770
|
if (action === 'invited-refuse') return refuse_approval(home, input, deps);
|
|
@@ -878,6 +896,7 @@ async function start_run(home, record, execution, { confined, software, end, res
|
|
|
878
896
|
// 不受限 means the AI works on this computer as usual (全放开): a sandbox would run its commands as another Windows
|
|
879
897
|
// account, which cannot open the record's credential (DPAPI, current user), so its `codiscuss` calls would all fail.
|
|
880
898
|
const profile = { adapter: record.ai.adapter, ...software, model: record.ai.model || software.model || '', effort: record.ai.effort, cwd: workdir, project_access: confined ? 'read' : 'full',
|
|
899
|
+
...(adapter_profile(record.ai.adapter)?.service_tiers ? { service_tier: record.ai.service_tier ?? '' } : {}),
|
|
881
900
|
// No own prompt, not even one left in an older record or in this software's local settings.
|
|
882
901
|
system_prompt: '' };
|
|
883
902
|
const log_path = join(base, `external-${execution.id}.log`);
|
|
@@ -1183,10 +1202,10 @@ function print_record(record) {
|
|
|
1183
1202
|
const HELP = () => t(`外部房间(本机 AI 作为外部成员参加另一台电脑上的房间)
|
|
1184
1203
|
|
|
1185
1204
|
用法:
|
|
1186
|
-
codiscuss join <链接|配对码> [--site 站点] [--machine 电脑编号] --adapter 软件 [--model M] [--effort E] [--session 会话] [--duration 1h|today|3d]
|
|
1205
|
+
codiscuss join <链接|配对码> [--site 站点] [--machine 电脑编号] --adapter 软件 [--model M] [--effort E] [--service-tier TIER] [--session 会话] [--duration 1h|today|3d]
|
|
1187
1206
|
codiscuss invited list
|
|
1188
1207
|
codiscuss invited trust ID auto|ask [--unconfined|--confined]
|
|
1189
|
-
codiscuss invited ai ID [--adapter 软件] [--model M] [--effort E]
|
|
1208
|
+
codiscuss invited ai ID [--adapter 软件] [--model M] [--effort E] [--service-tier TIER]
|
|
1190
1209
|
codiscuss invited pause ID | resume ID
|
|
1191
1210
|
codiscuss invited lend ID 1h|today|3d
|
|
1192
1211
|
codiscuss invited approve ID 待确认编号 | refuse ID 待确认编号
|
|
@@ -1199,7 +1218,7 @@ const HELP = () => t(`外部房间(本机 AI 作为外部成员参加另一台
|
|
|
1199
1218
|
借出时间:加入时用 --duration 选择(默认 1h),之后用 lend 从现在起重新计算,最长 3 天。
|
|
1200
1219
|
--session 续接这个软件已有的会话(带着原上下文加入)。
|
|
1201
1220
|
同意后由本机服务唤醒 AI,请保持 codiscuss 服务运行。加 --json 输出 JSON。
|
|
1202
|
-
`);
|
|
1221
|
+
`) + t('速度:--service-tier default(标准)、priority(Fast)或 ultrafast;用 --service-tier= 跟随软件,省略则保留。') + '\n';
|
|
1203
1222
|
|
|
1204
1223
|
const REPO_HELP = () => t(`只读查看任务授权的项目(本机受限只读任务或外部成员)
|
|
1205
1224
|
|
|
@@ -1218,7 +1237,7 @@ const REPO_HELP = () => t(`只读查看任务授权的项目(本机受限只
|
|
|
1218
1237
|
export async function external_main(command, args, { home, deps = {}, write = text => process.stdout.write(text), read_stdin = () => readFileSync(0, 'utf8') } = {}) {
|
|
1219
1238
|
const service = home || (await import('./discussion_service.mjs')).service_home();
|
|
1220
1239
|
const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
|
|
1221
|
-
site: { type: 'string' }, machine: { type: 'string' }, adapter: { type: 'string' }, model: { type: 'string' }, effort: { type: 'string' },
|
|
1240
|
+
site: { type: 'string' }, machine: { type: 'string' }, adapter: { type: 'string' }, model: { type: 'string' }, effort: { type: 'string' }, 'service-tier': { type: 'string' },
|
|
1222
1241
|
session: { type: 'string' }, duration: { type: 'string' },
|
|
1223
1242
|
label: { type: 'string' }, json: { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
|
|
1224
1243
|
unconfined: { type: 'boolean' }, confined: { type: 'boolean' },
|
|
@@ -1241,7 +1260,8 @@ export async function external_main(command, args, { home, deps = {}, write = te
|
|
|
1241
1260
|
return out(await repo_command(service, op, options, access, deps));
|
|
1242
1261
|
}
|
|
1243
1262
|
if (values.help || (command === 'invited' && !positionals.length) || (command === 'join' && !positionals.length)) return write(HELP());
|
|
1244
|
-
const ai = { ...(values.adapter ? { adapter: values.adapter } : {}), ...(values.model !== undefined ? { model: values.model } : {}),
|
|
1263
|
+
const ai = { ...(values.adapter ? { adapter: values.adapter } : {}), ...(values.model !== undefined ? { model: values.model } : {}),
|
|
1264
|
+
...(values.effort !== undefined ? { effort: values.effort } : {}), ...(values['service-tier'] !== undefined ? { service_tier: values['service-tier'] } : {}) };
|
|
1245
1265
|
let result;
|
|
1246
1266
|
if (command === 'join') result = await join_invite(service, { invite: positionals[0], site: values.site, machine: values.machine, label: values.label, ...(values.session ? { session_id: values.session } : {}), ...(values.duration ? { duration: values.duration } : {}), ...ai }, deps);
|
|
1247
1267
|
else {
|
package/runner/free_runner.mjs
CHANGED
|
@@ -20,14 +20,14 @@ import { record_wakeup_text } from './wakeup_text.mjs';
|
|
|
20
20
|
import { cwd_key } from './file_diff.mjs';
|
|
21
21
|
import { capture_workspace, commit_workspace_checkpoint, diff_workspace, discard_workspace } from './workspace_worker.mjs';
|
|
22
22
|
import { cleanup_room_checkpoints, inspect_checkpoint_root, observe_checkpoint_write, restore_rewound_checkpoints } from './file_checkpoint.mjs';
|
|
23
|
-
import {
|
|
23
|
+
import { correctable_refusals, free_task_text, HOST_MODEL_RULE_HEADING, HOST_MODEL_RULE_REPLACED, HOST_MODEL_RULE_REVOKED, HOST_STRATEGY_HEADING, HOST_STRATEGY_REVOKED, MAX_REFUSAL_RETRIES, PROMPTS_REPLACED, PROMPTS_REVOKED, refusal_retry_prompt, restart_resume_prompt, runs_commands, runs_read_commands, system_text, TASK_SUBCOMMANDS } from './expert_prompts.mjs';
|
|
24
24
|
import { host_skill_digest } from './discussion_skills.mjs';
|
|
25
25
|
import { entry_access, owner_key_file, site_fetch } from './entry_client.mjs';
|
|
26
26
|
import { ATTACHMENT_MAX_BYTES, CACHE_HEARTBEAT_MS, create_cache_lease, download_cached_attachment, drop_cache_lease, touch_cache_lease } from './attachment_cache.mjs';
|
|
27
27
|
import { atomic_json } from './files.mjs';
|
|
28
28
|
import { cached_model_default, MODEL_CACHE_MS, model_catalog_reader, unknown_model } from './model_catalog.mjs';
|
|
29
29
|
import { t, with_channel_locale } from './i18n.mjs';
|
|
30
|
-
import { image_settings } from './image_service.mjs';
|
|
30
|
+
import { image_settings, native_image_platforms } from './image_service.mjs';
|
|
31
31
|
import { outside_directory, project_html_kind, read_only_enforced, room_directories, room_directory_entries } from './project_files.mjs';
|
|
32
32
|
import { DELIVERED_GRACE_SECONDS, named_deliverable_paths } from './share_shared.mjs';
|
|
33
33
|
import { SessionDriver } from './session_driver.mjs';
|
|
@@ -669,23 +669,20 @@ function task_room_roster(config, room, protection, runtime) {
|
|
|
669
669
|
|
|
670
670
|
/** Describe the enabled image paths without disclosing provider settings or granting host actions. */
|
|
671
671
|
function task_image(config, member, room_members, protection, cli) {
|
|
672
|
-
|
|
673
|
-
const mode = ['codex', 'both'].includes(config.image_mode) ? config.image_mode : 'api';
|
|
674
|
-
const image = mode === 'codex' ? null : image_settings(config.api_home);
|
|
672
|
+
const image = config.image_generation && config.image_mode !== 'codex' ? image_settings(config.api_home) : null;
|
|
675
673
|
const api = image?.configured
|
|
676
674
|
? { model: image.model, catalog: image.catalog, limits: image.limits, command: `${cli} launch image --file REQUEST.json` } : null;
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
can_invite: member.role === 'host' && !protection && host_allowed(config, HOST_ACTION_ITEMS.invite),
|
|
687
|
-
};
|
|
675
|
+
const specialist_members = room_members
|
|
676
|
+
.filter(item => item.status === 'active' && item.access !== 'external'
|
|
677
|
+
&& capabilities_of(config.participants[item.name]?.adapter).native_image_gen)
|
|
678
|
+
.map(item => item.label || item.name);
|
|
679
|
+
const platforms = native_image_platforms(config.api_home);
|
|
680
|
+
const can_invite = Boolean(platforms.length && member.role === 'host' && !protection && host_allowed(config, HOST_ACTION_ITEMS.invite));
|
|
681
|
+
const subscription = platforms.length || specialist_members.length ? {
|
|
682
|
+
specialist_members, can_invite, ...(can_invite ? { invite_platforms: platforms } : {}),
|
|
683
|
+
} : null;
|
|
688
684
|
if (!api && !subscription) return null;
|
|
685
|
+
const mode = api && subscription ? 'both' : api ? 'api' : 'codex';
|
|
689
686
|
return { mode, ...(api ? { model: api.model, command: api.command, api } : {}), ...(subscription ? { subscription } : {}) };
|
|
690
687
|
}
|
|
691
688
|
|
|
@@ -722,7 +719,12 @@ export function free_task_files(config, member, execution, binding, { session =
|
|
|
722
719
|
}))];
|
|
723
720
|
const readable_directories = [...extra_directories, ...attachment_directories.map(path => ({ path, access: 'read' }))];
|
|
724
721
|
const window_memory = config.cwd && (config.steward || config.steward_private || config.moss_window) ? steward_memory_path(config.cwd) : '';
|
|
725
|
-
|
|
722
|
+
// The adapters build their command allow rules from extra_commands, so every command added to subcommands below
|
|
723
|
+
// must be listed here too, or a restricted software refuses it (MOSS Direct messages could not run channel send).
|
|
724
|
+
const steward_commands = config.steward || config.steward_private ? ['channel send', 'room dispatches',
|
|
725
|
+
...(config.steward ? ['launch experience-moss'] : []), 'launch host-control create-room', 'launch host-control room-post', ...MEMORY_COMMANDS] : [];
|
|
726
|
+
const extra_commands = config.moss_window ? { extra_commands: GROUP_EXTRA_COMMANDS }
|
|
727
|
+
: steward_commands.length ? { extra_commands: steward_commands } : {};
|
|
726
728
|
// The expert this member plays keeps its own knowledge, which only it may write (its project access stays as set).
|
|
727
729
|
const knowledge_directory = member_knowledge(config.api_home, member.name, workflow, room_directories(config), profile);
|
|
728
730
|
const inbox = Boolean(adapter?.into_window?.(profile, binding));
|
|
@@ -730,7 +732,8 @@ export function free_task_files(config, member, execution, binding, { session =
|
|
|
730
732
|
const steward_window = config.moss_window ? 'group' : config.steward_private ? 'private' : config.steward ? 'main' : '';
|
|
731
733
|
const readonly_knowledge = read_only_knowledge(config, knowledge_directory);
|
|
732
734
|
const cli = process.platform === 'win32' ? adapter?.windows_command || 'codiscuss.cmd' : 'codiscuss';
|
|
733
|
-
const image =
|
|
735
|
+
const image = config.steward || config.steward_private || config.moss_window ? null
|
|
736
|
+
: task_image(config, member, room_members, protection, cli);
|
|
734
737
|
const model_member = member.role === 'host' && room_members.find(item => is_model_specialist(config, item) && item.status === 'active');
|
|
735
738
|
atomic_json(access_path, { ...entry_access(), site: config.site, room: config.room, member: member.name, token: config.members[member.name].token,
|
|
736
739
|
...(config.steward ? { steward: true } : {}),
|
|
@@ -890,7 +893,7 @@ export function free_task_files(config, member, execution, binding, { session =
|
|
|
890
893
|
tripo_configured: Boolean(config.model_generation && model_configured(config.api_home)) } } : {}),
|
|
891
894
|
...(image ? { image } : {}),
|
|
892
895
|
cli, subcommands: config.moss_window ? ['room view', 'message list', 'message view', 'message post', 'question', ...GROUP_EXTRA_COMMANDS]
|
|
893
|
-
:
|
|
896
|
+
: [...TASK_SUBCOMMANDS, ...steward_commands],
|
|
894
897
|
...(bound_access ? { access_env: 'DISCUSS_ACCESS_FILE' } : { access_file: access_path }),
|
|
895
898
|
instructions });
|
|
896
899
|
const strategy = member.role === 'host' ? host_strategy : '';
|
package/runner/i18n_en.mjs
CHANGED
|
@@ -211,6 +211,7 @@ export default {
|
|
|
211
211
|
"标准速度": "Standard",
|
|
212
212
|
"所选软件不支持该速度档位": "The selected software does not support this speed tier",
|
|
213
213
|
"所选模型不支持该速度档位": "The selected model does not support this speed tier",
|
|
214
|
+
'速度:--service-tier default(标准)、priority(Fast)或 ultrafast;用 --service-tier= 跟随软件,省略则保留。': 'Speed: use --service-tier default (Standard), priority (Fast), or ultrafast. Use --service-tier= to follow the software, or omit the option to keep the current setting.',
|
|
214
215
|
"model --member M --service-tier T 可单独调速,不改模型或强度;invite --name 平台 --service-tier T 可指定新成员速度。支持时可填 default(standard)、priority(fast)、ultrafast;空值跟随软件。用 --list 查询支持范围。": "Use model --member M --service-tier T to change speed without changing the model or effort, and invite --name PLATFORM --service-tier T to set speed for a new member. Where supported, use default (standard), priority (fast), or ultrafast. An empty value follows the software. Use --list to see what is supported.",
|
|
215
216
|
"请回离开的成员会保留原配置,请去掉 --model、--effort 和 --service-tier;先请回,再用 host-control model 调整。": "Returning members keep their settings. Omit --model, --effort, and --service-tier, bring the member back, then make changes with host-control model.",
|
|
216
217
|
"须有一位本机唤醒的主持人才能指定 --host-service-tier。": "Setting --host-service-tier requires a locally launched host.",
|
|
@@ -426,7 +427,7 @@ export default {
|
|
|
426
427
|
'清空窗口对话:codiscuss steward clear --window main|private|CHANNEL:CHAT --confirm': 'Clear a window conversation: codiscuss steward clear --window main|private|CHANNEL:CHAT --confirm',
|
|
427
428
|
'清空 MOSS 对话前须用 --confirm 确认': 'Use --confirm to clear the MOSS conversation.',
|
|
428
429
|
'MOSS 私信': 'MOSS Direct messages',
|
|
429
|
-
'私信设置:codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --project-access read|auto --skills SKILL,...]': 'Direct messages settings: codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --project-access read|auto --skills SKILL,...]',
|
|
430
|
+
'私信设置:codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --project-access read|auto --skills SKILL,...]': 'Direct messages settings: codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --project-access read|auto --skills SKILL,...]',
|
|
430
431
|
'此窗口不能通过命令行更改本机平台。': 'This window cannot change the local platform through the command line.',
|
|
431
432
|
'当前 MOSS 软件不支持群窗口所需的工具收窄。': 'The selected MOSS software does not support the tool restrictions required for group windows.',
|
|
432
433
|
'群委托房间只能使用该房间的专用目录。': 'A group task room can use only its dedicated workspace.',
|
|
@@ -459,7 +460,7 @@ export default {
|
|
|
459
460
|
'只能删除已存档的 MOSS 房间': 'Only archived MOSS rooms can be deleted.',
|
|
460
461
|
'steward 查看、配置或请求MOSS': 'steward View, configure, or ask MOSS',
|
|
461
462
|
'--create-rooms 只能指定 on 或 off': '--create-rooms must be on or off',
|
|
462
|
-
'开始新会话:codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL]': 'Start a new session: codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL]',
|
|
463
|
+
'开始新会话:codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL] [--service-tier TIER]': 'Start a new session: codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL] [--service-tier TIER]',
|
|
463
464
|
'请先打开 MOSS 对话,再开始新会话': 'Open the MOSS conversation before starting a new session',
|
|
464
465
|
'你在本会话中的项目权限已从 {from} 改为 {to}(见任务文件的 project_access)。本会话里之前被拒或做不了的操作,按新权限重新判断,需要时直接再试。': 'Your project access in this session changed from {from} to {to} (see project_access in the task file). Judge anything refused or not possible earlier in this session again under the new access, and retry it when needed.',
|
|
465
466
|
'你在本会话中的项目权限已从 {from} 降为 {to}(见任务文件的 project_access)。本会话里之前能做的操作现在可能会被拒,按新权限重新判断。': 'Your project access in this session was lowered from {from} to {to} (see project_access in the task file). Operations that worked earlier in this session may now be refused; judge them again under the new access.',
|
|
@@ -487,7 +488,7 @@ export default {
|
|
|
487
488
|
'MOSS 只能向同站点未存档项目房间的主持人发消息': 'MOSS can only message hosts of unarchived project rooms on the same site',
|
|
488
489
|
'此房间无权执行操作 {action}': 'This room is not permitted to run {action}',
|
|
489
490
|
'MOSS 无权管理工作流': 'MOSS is not allowed to manage workflows',
|
|
490
|
-
'用法:codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm': 'Usage: codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm',
|
|
491
|
+
'用法:codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm': 'Usage: codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm',
|
|
491
492
|
"找不到所引用的通知,这条回复没有发回房间。": "The quoted notice was not found, so this reply was not sent to a room.",
|
|
492
493
|
"飞书": "Feishu",
|
|
493
494
|
"在飞书中打开与应用机器人的私聊,发送这组绑定码。": "Open a private chat with the app bot in Feishu and send this binding code.",
|
|
@@ -1299,7 +1300,7 @@ export default {
|
|
|
1299
1300
|
"{member} 的操作被本机权限规则拒绝,未提交本次回答": "An operation of {member} was refused by this computer's permission rules; no answer was submitted for this run",
|
|
1300
1301
|
"外部成员只能读本房间消息与概况、提交自己的回答": "An external member can only read this room's messages and overview and submit its own answer",
|
|
1301
1302
|
" 对方已结束你的成员资格({reason})": " The other side ended your membership ({reason})",
|
|
1302
|
-
"外部房间(本机 AI 作为外部成员参加另一台电脑上的房间)\n\n用法:\n codiscuss join <链接|配对码> [--site 站点] [--machine 电脑编号] --adapter 软件 [--model M] [--effort E] [--session 会话] [--duration 1h|today|3d]\n codiscuss invited list\n codiscuss invited trust ID auto|ask [--unconfined|--confined]\n codiscuss invited ai ID [--adapter 软件] [--model M] [--effort E]\n codiscuss invited pause ID | resume ID\n codiscuss invited lend ID 1h|today|3d\n codiscuss invited approve ID 待确认编号 | refuse ID 待确认编号\n codiscuss invited leave ID\n codiscuss invited remove ID\n codiscuss invited room ID\n\n被点名时:auto 直接回答;ask 每次先问你。\n本机权限:默认按只读档在空目录里参与对方房间(可查公开网页,不读写本机项目);--unconfined 不受限,可读写本机文件与运行命令。\n借出时间:加入时用 --duration 选择(默认 1h),之后用 lend 从现在起重新计算,最长 3 天。\n--session 续接这个软件已有的会话(带着原上下文加入)。\n同意后由本机服务唤醒 AI,请保持 codiscuss 服务运行。加 --json 输出 JSON。\n": "External rooms (this computer's AI joins a room on another computer as an external member)\n\nUsage:\n codiscuss join <link|pairing code> [--site SITE] [--machine COMPUTER_ID] --adapter SOFTWARE [--model M] [--effort E] [--session SESSION] [--duration 1h|today|3d]\n codiscuss invited list\n codiscuss invited trust ID auto|ask [--unconfined|--confined]\n codiscuss invited ai ID [--adapter SOFTWARE] [--model M] [--effort E]\n codiscuss invited pause ID | resume ID\n codiscuss invited lend ID 1h|today|3d\n codiscuss invited approve ID APPROVAL_ID | refuse ID APPROVAL_ID\n codiscuss invited leave ID\n codiscuss invited remove ID\n codiscuss invited room ID\n\nWhen named: auto answers at once; ask asks you each time.\nLocal access: by default it joins in read-only mode inside an empty workspace (public web allowed, no local project files); --unconfined lifts that so it can read/write local files and run commands.\nLoan time: choose it with --duration when joining (1h by default); lend later restarts it from now, three days at most.\n--session resumes a conversation this software already holds (joining with its context).\nThe local service wakes the AI after you approve; keep the codiscuss service running. Add --json for JSON output.\n",
|
|
1303
|
+
"外部房间(本机 AI 作为外部成员参加另一台电脑上的房间)\n\n用法:\n codiscuss join <链接|配对码> [--site 站点] [--machine 电脑编号] --adapter 软件 [--model M] [--effort E] [--service-tier TIER] [--session 会话] [--duration 1h|today|3d]\n codiscuss invited list\n codiscuss invited trust ID auto|ask [--unconfined|--confined]\n codiscuss invited ai ID [--adapter 软件] [--model M] [--effort E] [--service-tier TIER]\n codiscuss invited pause ID | resume ID\n codiscuss invited lend ID 1h|today|3d\n codiscuss invited approve ID 待确认编号 | refuse ID 待确认编号\n codiscuss invited leave ID\n codiscuss invited remove ID\n codiscuss invited room ID\n\n被点名时:auto 直接回答;ask 每次先问你。\n本机权限:默认按只读档在空目录里参与对方房间(可查公开网页,不读写本机项目);--unconfined 不受限,可读写本机文件与运行命令。\n借出时间:加入时用 --duration 选择(默认 1h),之后用 lend 从现在起重新计算,最长 3 天。\n--session 续接这个软件已有的会话(带着原上下文加入)。\n同意后由本机服务唤醒 AI,请保持 codiscuss 服务运行。加 --json 输出 JSON。\n": "External rooms (this computer's AI joins a room on another computer as an external member)\n\nUsage:\n codiscuss join <link|pairing code> [--site SITE] [--machine COMPUTER_ID] --adapter SOFTWARE [--model M] [--effort E] [--service-tier TIER] [--session SESSION] [--duration 1h|today|3d]\n codiscuss invited list\n codiscuss invited trust ID auto|ask [--unconfined|--confined]\n codiscuss invited ai ID [--adapter SOFTWARE] [--model M] [--effort E] [--service-tier TIER]\n codiscuss invited pause ID | resume ID\n codiscuss invited lend ID 1h|today|3d\n codiscuss invited approve ID APPROVAL_ID | refuse ID APPROVAL_ID\n codiscuss invited leave ID\n codiscuss invited remove ID\n codiscuss invited room ID\n\nWhen named: auto answers at once; ask asks you each time.\nLocal access: by default it joins in read-only mode inside an empty workspace (public web allowed, no local project files); --unconfined lifts that so it can read/write local files and run commands.\nLoan time: choose it with --duration when joining (1h by default); lend later restarts it from now, three days at most.\n--session resumes a conversation this software already holds (joining with its context).\nThe local service wakes the AI after you approve; keep the codiscuss service running. Add --json for JSON output.\n",
|
|
1303
1304
|
"只读查看任务授权的项目(本机受限只读任务或外部成员)\n\n用法:\n codiscuss repo ls 列出开放目录(序号即 --root)\n codiscuss repo ls [目录] --root N [--offset N] [--limit N]\n codiscuss repo read 文件 --root N [--offset N] [--max-bytes N]\n codiscuss repo grep 关键词 --root N [--path 路径] [--case-sensitive] [--max-results N]\n codiscuss repo pull 文件… --root N [--refresh]\n codiscuss repo rm 文件 --root N\n codiscuss repo status [--root N]\n凭据取自 --access-file 或 DISCUSS_ACCESS_FILE。\n": "Read authorized project files in a local restricted read-only task or as an external member\n\nUsage:\n codiscuss repo ls List the opened directories (their numbers are --root)\n codiscuss repo ls [DIRECTORY] --root N [--offset N] [--limit N]\n codiscuss repo read FILE --root N [--offset N] [--max-bytes N]\n codiscuss repo grep KEYWORD --root N [--path PATH] [--case-sensitive] [--max-results N]\n codiscuss repo pull FILE… --root N [--refresh]\n codiscuss repo rm FILE --root N\n codiscuss repo status [--root N]\nCredentials come from --access-file or DISCUSS_ACCESS_FILE.\n",
|
|
1304
1305
|
"用法:codiscuss repo ls | read | grep | pull | rm | status": "Usage: codiscuss repo ls | read | grep | pull | rm | status",
|
|
1305
1306
|
"用法:codiscuss repo rm 文件 --root N 或 codiscuss repo status [--root N]": "Usage: codiscuss repo rm FILE --root N or codiscuss repo status [--root N]",
|
|
@@ -1422,6 +1423,7 @@ export default {
|
|
|
1422
1423
|
"区分大小写": "Match case",
|
|
1423
1424
|
"全字匹配": "Match whole words",
|
|
1424
1425
|
"使用正则表达式": "Use a regular expression",
|
|
1426
|
+
"全部房间搜索的排序:relevance 按相关度(标题命中、命中数),recent 按最近发言": "Order of an all-rooms search: relevance (title matches, then match count) or recent (newest match first)",
|
|
1425
1427
|
"更新房主的房间已读位置": "Update the owner’s room read position",
|
|
1426
1428
|
"指定消息编号,省略时读取房间最新消息编号": "Use this message ID, or read the latest room message ID if omitted",
|
|
1427
1429
|
"标为未读": "Mark as unread",
|
package/runner/image_service.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { existsSync, readFileSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { api_base_url, api_models, read_saved_api_key } from './discussion_api.mjs';
|
|
10
|
-
import { IMAGE_MODELS } from './adapters/profiles.mjs';
|
|
10
|
+
import { adapter_capabilities, IMAGE_MODELS } from './adapters/profiles.mjs';
|
|
11
11
|
import { atomic_json } from './files.mjs';
|
|
12
12
|
import { t } from './i18n.mjs';
|
|
13
13
|
|
|
@@ -50,16 +50,23 @@ export function validate_image_limits(args, limits) {
|
|
|
50
50
|
return quality === 'auto' && max_quality !== 'max' ? { ...args, quality: max_quality } : args;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* default becomes these settings.
|
|
56
|
-
*/
|
|
57
|
-
function legacy_settings(home) {
|
|
53
|
+
function saved_participants(home) {
|
|
54
|
+
if (!home) return {};
|
|
58
55
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
return JSON.parse(readFileSync(join(home, 'launch-settings.json'), 'utf8')).participants || {};
|
|
57
|
+
} catch { return {}; }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Configured local platforms whose adapters provide native subscription image generation. */
|
|
61
|
+
export function native_image_platforms(home) {
|
|
62
|
+
return Object.entries(saved_participants(home)).filter(([, profile]) =>
|
|
63
|
+
profile?.executable && adapter_capabilities(profile.adapter).native_image_gen).map(([name]) => name);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Migrate the first saved image model from a legacy API member card. */
|
|
67
|
+
function legacy_settings(home) {
|
|
68
|
+
const profile = Object.values(saved_participants(home)).find(item => item?.image_model && item.base_url && item.api_key_ref);
|
|
69
|
+
return profile ? { base_url: profile.base_url, model: profile.image_model, api_key_ref: profile.api_key_ref } : null;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
/** This computer's image settings `{base_url, model, api_key_ref, configured, catalog}`; never the key itself. */
|
package/runner/moss_windows.mjs
CHANGED
|
@@ -72,16 +72,16 @@ export const RETIRED_STEWARD_SKILL = 'discuss-report';
|
|
|
72
72
|
|
|
73
73
|
/** Validate the owner's editable preferences without accepting room identity or usage from the caller. */
|
|
74
74
|
export function moss_window_preferences(value = {}) {
|
|
75
|
-
const { work_policy = 'small', daily_limit = DEFAULT_DAILY_LIMIT, daily_tasks = 5, adapter = '', model = '', effort = '', read_directory = '', skills = [] } = value;
|
|
75
|
+
const { work_policy = 'small', daily_limit = DEFAULT_DAILY_LIMIT, daily_tasks = 5, adapter = '', preset = '', model = '', effort = '', service_tier = '', read_directory = '', skills = [] } = value;
|
|
76
76
|
const read_directories = value.read_directories ?? (read_directory ? [read_directory] : []);
|
|
77
77
|
if (!WORK_POLICIES.has(work_policy) || !Number.isSafeInteger(daily_limit) || daily_limit < 0 ||
|
|
78
|
-
!Number.isSafeInteger(daily_tasks) || daily_tasks < 0 || typeof adapter !== 'string' || typeof read_directory !== 'string' ||
|
|
78
|
+
!Number.isSafeInteger(daily_tasks) || daily_tasks < 0 || typeof adapter !== 'string' || typeof preset !== 'string' || typeof read_directory !== 'string' ||
|
|
79
79
|
!Array.isArray(read_directories) || read_directories.length > MAX_EXTRA_DIRECTORIES || read_directories.some(path => typeof path !== 'string' || !isAbsolute(path)) ||
|
|
80
80
|
!Array.isArray(skills) || skills.some(id => typeof id !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/i.test(id) ||
|
|
81
81
|
['local-stt-setup', 'local-tts-setup', 'notify-setup', 'cloudflare-deploy'].includes(id.toLowerCase())) ||
|
|
82
|
-
typeof model !== 'string' || typeof effort !== 'string') throw new Error(t('MOSS 群窗口设置无效。'));
|
|
82
|
+
typeof model !== 'string' || typeof effort !== 'string' || typeof service_tier !== 'string') throw new Error(t('MOSS 群窗口设置无效。'));
|
|
83
83
|
return { habit: window_text(value.habit ?? ''), about: window_text(value.about ?? ''), work_policy, daily_limit, daily_tasks,
|
|
84
|
-
adapter, model, effort, read_directories, read_directory: read_directories[0] || '', skills: [...new Set(skills.filter(id => id.toLowerCase() !== RETIRED_STEWARD_SKILL))] };
|
|
84
|
+
adapter, preset, model, effort, service_tier, read_directories, read_directory: read_directories[0] || '', skills: [...new Set(skills.filter(id => id.toLowerCase() !== RETIRED_STEWARD_SKILL))] };
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/** Resolve preferences at task time. An empty override uses the group default. */
|
package/runner/steward.mjs
CHANGED
|
@@ -24,7 +24,7 @@ const CONFIRMATION_SKILLS = ['local-stt-setup', 'local-tts-setup', 'notify-setup
|
|
|
24
24
|
export { EXPERIENCE_REVIEW_DUTY } from './steward_proactive.mjs';
|
|
25
25
|
const SKILLS = ['rooms-overview', 'codiscuss-help', 'dispatch-analysis', 'share-card', 'codiscuss-draft-cleanup', ...CONFIRMATION_SKILLS];
|
|
26
26
|
const platform_skill = id => CONFIRMATION_SKILLS.includes(id.toLowerCase());
|
|
27
|
-
const FIELDS = ['adapter', 'model', 'effort', 'cwd', 'skills', 'create_rooms'];
|
|
27
|
+
const FIELDS = ['adapter', 'preset', 'model', 'effort', 'service_tier', 'cwd', 'skills', 'create_rooms'];
|
|
28
28
|
|
|
29
29
|
const MOSS_DISPATCH_PROMPT = `# 主理人和私信的分流与验收
|
|
30
30
|
|
|
@@ -103,11 +103,12 @@ export function steward_skill(skill, project = PROJECT) {
|
|
|
103
103
|
/** Resolve local defaults without creating a directory or returning private software settings. */
|
|
104
104
|
export function steward_defaults(home, settings, project = PROJECT) {
|
|
105
105
|
const saved = settings.steward || {};
|
|
106
|
-
const adapter = saved.adapter || '';
|
|
107
|
-
const [, profile = {}] = steward_software(settings, adapter);
|
|
106
|
+
const adapter = saved.adapter || '', preset = saved.preset || '';
|
|
107
|
+
const [, profile = {}] = steward_software(settings, adapter, preset);
|
|
108
108
|
const available = SKILLS.filter(skill => steward_skill(skill, project));
|
|
109
109
|
return {
|
|
110
|
-
adapter, model: saved.model ?? profile.model ?? '', effort: saved.effort ?? profile.effort ?? '',
|
|
110
|
+
adapter, preset, model: saved.model ?? profile.model ?? '', effort: saved.effort ?? profile.effort ?? '',
|
|
111
|
+
service_tier: saved.service_tier ?? (adapter_profile(adapter)?.service_tiers ? profile.service_tier ?? '' : ''),
|
|
111
112
|
project_access: steward_access(adapter), cwd: saved.cwd || join(account_space(home).workspace, 'steward'),
|
|
112
113
|
extra_directories: saved.extra_directories || [],
|
|
113
114
|
skills: saved.skills?.filter(id => id !== RETIRED_STEWARD_SKILL) ?? available, create_rooms: saved.create_rooms !== false, proactive: scheduled_duties(home, proactive_settings(saved.proactive)),
|
|
@@ -187,17 +188,17 @@ export function steward_settings_patch(input) {
|
|
|
187
188
|
/** Private preferences never inherit the main member or expose its platform skills. */
|
|
188
189
|
export function steward_private_patch(input) {
|
|
189
190
|
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new Error(t('MOSS 设置无效'));
|
|
190
|
-
const { adapter, model, effort, skills, project_access, extra_directories } = input;
|
|
191
|
+
const { adapter, preset, model, effort, service_tier, skills, project_access, extra_directories } = input;
|
|
191
192
|
if (project_access !== undefined && !['read', 'auto'].includes(project_access) ||
|
|
192
193
|
Array.isArray(skills) && skills.some(id => CONFIRMATION_SKILLS.includes(id))) throw new Error(t('MOSS 设置无效'));
|
|
193
|
-
const patch = steward_settings_patch(Object.fromEntries(Object.entries({ adapter, model, effort, skills, extra_directories }).filter(([, value]) => value !== undefined)));
|
|
194
|
+
const patch = steward_settings_patch(Object.fromEntries(Object.entries({ adapter, preset, model, effort, service_tier, skills, extra_directories }).filter(([, value]) => value !== undefined)));
|
|
194
195
|
return { ...patch, ...(project_access !== undefined ? { project_access } : {}) };
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
export function steward_private_defaults(home, settings) {
|
|
198
199
|
const saved = settings.steward?.private || {};
|
|
199
200
|
const view = steward_defaults(home, { ...settings, steward: saved });
|
|
200
|
-
return { adapter: view.adapter, model: view.model, effort: view.effort, project_access: saved.project_access || 'read',
|
|
201
|
+
return { adapter: view.adapter, preset: view.preset, model: view.model, effort: view.effort, service_tier: view.service_tier, project_access: saved.project_access || 'read',
|
|
201
202
|
cwd: join(account_space(home).workspace, 'steward-private'), extra_directories: view.extra_directories,
|
|
202
203
|
skills: view.skills.filter(id => !CONFIRMATION_SKILLS.includes(id)) };
|
|
203
204
|
}
|
|
@@ -340,15 +341,16 @@ export function steward_site(home) {
|
|
|
340
341
|
}
|
|
341
342
|
|
|
342
343
|
/** Identify the configured platform behind the selected adapter, without opening its work directory. */
|
|
343
|
-
export function steward_software(settings, adapter) {
|
|
344
|
+
export function steward_software(settings, adapter, preset = '') {
|
|
344
345
|
const facts = adapter_profile(adapter);
|
|
345
346
|
const entries = Object.entries(settings.participants || {});
|
|
346
|
-
|
|
347
|
+
const named = preset && entries.find(([name, profile]) => name === preset && profile.adapter === adapter);
|
|
348
|
+
return facts ? named || entries.find(([, profile]) => profile.adapter === adapter) || entries.find(([name]) => name === facts.platform) || [] : [];
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
/** Resolve the single member's profile and do not inherit a conversation or directory from another room. */
|
|
350
352
|
export function steward_profile(home, settings, view, resolve_profile) {
|
|
351
|
-
const [platform, saved] = steward_software(settings, view.adapter);
|
|
353
|
+
const [platform, saved] = steward_software(settings, view.adapter, view.preset);
|
|
352
354
|
if (!saved) throw new Error(t('请先配置MOSS的本机软件'));
|
|
353
355
|
const access = view.project_access;
|
|
354
356
|
if (view.cwd === join(account_space(home).workspace, 'steward-private')) {
|
|
@@ -356,7 +358,7 @@ export function steward_profile(home, settings, view, resolve_profile) {
|
|
|
356
358
|
mkdirSync(view.cwd, { recursive: true });
|
|
357
359
|
} else if (!settings.steward?.cwd) mkdirSync(view.cwd, { recursive: true });
|
|
358
360
|
const { cwd, session_id, source_thread_id, project_name, project_id, allowed_tools, ...base } = saved;
|
|
359
|
-
const profile = { ...base, adapter: view.adapter, cwd: view.cwd, model: view.model, effort: view.effort, project_access: access };
|
|
361
|
+
const profile = { ...base, adapter: view.adapter, cwd: view.cwd, model: view.model, effort: view.effort, service_tier: view.service_tier, project_access: access };
|
|
360
362
|
const extra_directories = check_extra_directories(view.cwd, view.extra_directories || []);
|
|
361
363
|
return { platform, profile: resolve_profile(platform, {}, { participants: { [platform]: profile }, cwd: view.cwd, extra_directories, entry: 'web' }, false) };
|
|
362
364
|
}
|
|
@@ -386,9 +388,9 @@ export function duty_schedule_options(values) {
|
|
|
386
388
|
|
|
387
389
|
/** Parse the public CLI into the same local actions the browser calls. */
|
|
388
390
|
export async function steward_cli(args, dispatch) {
|
|
389
|
-
const help = () => process.stdout.write(t('用法:codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm') + '\n');
|
|
391
|
+
const help = () => process.stdout.write(t('用法:codiscuss steward status | settings [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --cwd DIR --skills SKILL,... --create-rooms on|off] | ask SKILL [--room ROOM --note TEXT --confirm] | history | delete ROOM --confirm') + '\n');
|
|
390
392
|
const { positionals, values } = parseArgs({ args, allowPositionals: true, options: {
|
|
391
|
-
help: { type: 'boolean', short: 'h' }, adapter: { type: 'string' }, model: { type: 'string' }, effort: { type: 'string' },
|
|
393
|
+
help: { type: 'boolean', short: 'h' }, adapter: { type: 'string' }, model: { type: 'string' }, effort: { type: 'string' }, 'service-tier': { type: 'string' },
|
|
392
394
|
cwd: { type: 'string' }, skills: { type: 'string' }, room: { type: 'string' },
|
|
393
395
|
note: { type: 'string' }, confirm: { type: 'boolean' }, 'create-rooms': { type: 'string' },
|
|
394
396
|
proactive: { type: 'string' }, 'active-hours': { type: 'string' }, 'digest-at': { type: 'string' },
|
|
@@ -397,9 +399,10 @@ export async function steward_cli(args, dispatch) {
|
|
|
397
399
|
const [command, target, ...extra] = positionals;
|
|
398
400
|
if (!command || command === 'help' || values.help) {
|
|
399
401
|
help();
|
|
400
|
-
process.stdout.write(t('开始新会话:codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL]') + '\n');
|
|
402
|
+
process.stdout.write(t('开始新会话:codiscuss steward renew [--window main|private|CHANNEL:CHAT] [--adapter ID] [--model MODEL] [--effort LEVEL] [--service-tier TIER]') + '\n');
|
|
401
403
|
process.stdout.write(t('清空窗口对话:codiscuss steward clear --window main|private|CHANNEL:CHAT --confirm') + '\n');
|
|
402
|
-
process.stdout.write(t('私信设置:codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --project-access read|auto --skills SKILL,...]') + '\n');
|
|
404
|
+
process.stdout.write(t('私信设置:codiscuss steward settings --private [--adapter ID --model MODEL --effort LEVEL --service-tier TIER --project-access read|auto --skills SKILL,...]') + '\n');
|
|
405
|
+
process.stdout.write(t('速度:--service-tier default(标准)、priority(Fast)或 ultrafast;用 --service-tier= 跟随软件,省略则保留。') + '\n');
|
|
403
406
|
return process.stdout.write(t('主动汇报:settings --proactive on|off --active-hours 09:00-22:00 --digest-at 21:00;duty add --text 正文 [--at HH:MM --weekdays 0,1 --deliver channel|window] | duty remove --id ID | duty list;mute MESSAGE_ID --reason 原因') + '\n');
|
|
404
407
|
}
|
|
405
408
|
if (command === 'duty' && ['add', 'remove', 'list'].includes(target) && extra.length <= 1) {
|
|
@@ -410,8 +413,8 @@ export async function steward_cli(args, dispatch) {
|
|
|
410
413
|
const window = values.window ? { window: values.window } : values.private ? { window: 'private' } : {};
|
|
411
414
|
if (command === 'status') return dispatch('steward', window);
|
|
412
415
|
if (command === 'renew') {
|
|
413
|
-
const { adapter, model, effort } = values;
|
|
414
|
-
const selection = Object.fromEntries(Object.entries({ adapter, model, effort }).filter(([, value]) => value !== undefined));
|
|
416
|
+
const { adapter, model, effort, 'service-tier': service_tier } = values;
|
|
417
|
+
const selection = Object.fromEntries(Object.entries({ adapter, model, effort, service_tier }).filter(([, value]) => value !== undefined));
|
|
415
418
|
return dispatch('steward-renew', { ...window, ...selection });
|
|
416
419
|
}
|
|
417
420
|
if (command === 'history') return dispatch('steward-history', window);
|
|
@@ -425,7 +428,7 @@ export async function steward_cli(args, dispatch) {
|
|
|
425
428
|
return dispatch('steward-delete', { ...window, room_id: target });
|
|
426
429
|
}
|
|
427
430
|
if (command === 'settings') {
|
|
428
|
-
const { adapter, model, effort, cwd, skills } = values;
|
|
431
|
+
const { adapter, model, effort, 'service-tier': service_tier, cwd, skills } = values;
|
|
429
432
|
const create = values['create-rooms'];
|
|
430
433
|
const { proactive, 'active-hours': hours, 'digest-at': digest } = values;
|
|
431
434
|
if (proactive !== undefined && !['on', 'off'].includes(proactive)) throw new Error(t('--proactive 只能指定 on 或 off'));
|
|
@@ -435,7 +438,7 @@ export async function steward_cli(args, dispatch) {
|
|
|
435
438
|
...(digest !== undefined ? { digest_at: digest } : {}) };
|
|
436
439
|
if (Object.keys(report).length) proactive_patch(report);
|
|
437
440
|
if (create !== undefined && !['on', 'off'].includes(create)) throw new Error(t('--create-rooms 只能指定 on 或 off'));
|
|
438
|
-
const patch = Object.fromEntries(Object.entries({ adapter, model, effort, cwd,
|
|
441
|
+
const patch = Object.fromEntries(Object.entries({ adapter, model, effort, service_tier, cwd,
|
|
439
442
|
create_rooms: create === undefined ? undefined : create === 'on',
|
|
440
443
|
proactive: Object.keys(report).length ? report : undefined,
|
|
441
444
|
skills: skills?.split(',').map(item => item.trim()).filter(Boolean) }).filter(([, value]) => value !== undefined));
|
|
@@ -42,7 +42,8 @@ export function revise_proactive_list(settings, field, action, input) {
|
|
|
42
42
|
if (!schedule || typeof schedule.at !== 'string' || !TIME.test(schedule.at) || (days !== undefined && (!Array.isArray(days) || !days.length ||
|
|
43
43
|
days.some(day => !Number.isInteger(day) || day < 0 || day > 6))) ||
|
|
44
44
|
!['window', 'channel'].includes(input.deliver ?? 'window')) throw new Error(t('MOSS 职责或屏蔽记录参数无效'));
|
|
45
|
-
|
|
45
|
+
if (schedule.timezone !== undefined && !valid_timezone(schedule.timezone)) throw new Error(t('MOSS 职责或屏蔽记录参数无效'));
|
|
46
|
+
entry.schedule = { at: schedule.at, ...(days ? { weekdays: [...new Set(days)].sort() } : {}), ...(schedule.timezone ? { timezone: schedule.timezone } : {}) };
|
|
46
47
|
entry.deliver = input.deliver ?? 'window';
|
|
47
48
|
}
|
|
48
49
|
return field === 'mutes' ? [...settings[field], { ...entry, text: [...text].slice(0, MUTE_TEXT_LENGTH).join(''), reason }].slice(-MAX_MUTES)
|
|
@@ -117,12 +118,36 @@ async function read_rooms(site) {
|
|
|
117
118
|
return (await response.json()).rooms;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
function valid_timezone(zone) {
|
|
122
|
+
if (typeof zone !== 'string' || !zone) return false;
|
|
123
|
+
try { new Intl.DateTimeFormat('en', { timeZone: zone }); return true; } catch { return false; }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Wall-clock fields of an instant in a zone; no zone means this computer's zone. */
|
|
127
|
+
function zoned_fields(date, zone) {
|
|
128
|
+
const parts = new Intl.DateTimeFormat('en-US', { timeZone: zone, hourCycle: 'h23', year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' }).formatToParts(date);
|
|
129
|
+
const field = type => Number(parts.find(part => part.type === type).value);
|
|
130
|
+
return { year: field('year'), month: field('month'), day: field('day'), hour: field('hour'), minute: field('minute') };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Instant of a wall-clock time in a zone, correcting once for the zone offset on that day. */
|
|
134
|
+
function zoned_instant(year, month, day, hour, minute, zone) {
|
|
135
|
+
let guess = Date.UTC(year, month - 1, day, hour, minute);
|
|
136
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
137
|
+
const seen = zoned_fields(new Date(guess), zone);
|
|
138
|
+
guess -= Date.UTC(seen.year, seen.month - 1, seen.day, seen.hour, seen.minute) - Date.UTC(year, month - 1, day, hour, minute);
|
|
139
|
+
}
|
|
140
|
+
return new Date(guess);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Locate one occurrence in the schedule's calendar time (its zone, else this computer's), including across a week boundary. */
|
|
144
|
+
export function occurrence(schedule, now, direction) {
|
|
122
145
|
const [hour, minute] = schedule.at.split(':').map(Number);
|
|
146
|
+
const today = zoned_fields(now, schedule.timezone);
|
|
123
147
|
for (let offset = 0; offset <= 7; offset++) {
|
|
124
|
-
const
|
|
125
|
-
|
|
148
|
+
const day = new Date(Date.UTC(today.year, today.month - 1, today.day + direction * offset));
|
|
149
|
+
const date = zoned_instant(day.getUTCFullYear(), day.getUTCMonth() + 1, day.getUTCDate(), hour, minute, schedule.timezone);
|
|
150
|
+
if ((!schedule.weekdays || schedule.weekdays.includes(day.getUTCDay())) && (direction > 0 ? date > now : date <= now)) return date;
|
|
126
151
|
}
|
|
127
152
|
}
|
|
128
153
|
|
package/web/app.js
CHANGED
|
@@ -4447,7 +4447,7 @@ async function finish_message(result, job) {
|
|
|
4447
4447
|
const attachment_start = job.preview.attachment_start || 1;
|
|
4448
4448
|
const attachments = job.drafts.filter(item => item.uploaded).map((item, index) => ({ id: item.uploaded, room_id, message_id: saved_id, file_name: item.file.name,
|
|
4449
4449
|
content_type: item.file.type || "application/octet-stream", size: item.file.size, number: attachment_start + index,
|
|
4450
|
-
...(item.width ? { width: item.width, height: item.height } : {}),
|
|
4450
|
+
...(item.width ? { width: item.width, height: item.height } : {}), ...item.uploaded_storage,
|
|
4451
4451
|
url: `/api/rooms/${encodeURIComponent(room_id)}/attachments/${encodeURIComponent(item.uploaded)}/content` }));
|
|
4452
4452
|
const sent_message = { ...result.message, text: job.payload.text || "", attachments, reply_to: job.payload.reply_to ?? result.message.reply_to ?? null,
|
|
4453
4453
|
...(job.payload.attachment_start ? { attachment_start: job.payload.attachment_start } : {}), source: "user", just_sent: true };
|
|
@@ -5309,6 +5309,8 @@ function finish_draft_cloud_upload(item, attachment) {
|
|
|
5309
5309
|
item.cloud_completion_pending = false;
|
|
5310
5310
|
item.pending_object = null;
|
|
5311
5311
|
item.uploaded = attachment.id;
|
|
5312
|
+
// A temporary cloud file draws as a file card, not a player; the sent card must say so before the room's next read.
|
|
5313
|
+
item.uploaded_storage = attachment.storage === "object" ? { storage: "object", stored: attachment.stored, expires_at: attachment.expires_at } : null;
|
|
5312
5314
|
report_upload_percent(item, 100);
|
|
5313
5315
|
if (attachment.storage !== "object" && !attachment.thumbnail_url && /^image\/(png|jpeg|webp)$/.test(attachment.content_type)) {
|
|
5314
5316
|
createImageBitmap(item.file).then(bitmap => store_attachment_thumbnail(attachment, bitmap)).catch(() => {});
|
|
@@ -5721,10 +5723,29 @@ function object_attachment_markup(file) {
|
|
|
5721
5723
|
const path = `/api/rooms/${encodeURIComponent(file.room_id)}/attachments/${encodeURIComponent(file.id)}/content`;
|
|
5722
5724
|
const label = escape_html(t("下载 {name}", { name: file.file_name }));
|
|
5723
5725
|
const link = `href="#" data-object-href="${escape_html(path)}" data-file-name="${name}"`;
|
|
5726
|
+
if (/^(audio|video)\//.test(file.content_type)) return object_media_markup(file, link, label);
|
|
5724
5727
|
return `<div class="attachment-file" data-object-state="stored"${attachment_local_title(file)}><a class="attachment-file-main" ${link} aria-label="${label}">${attachment_file_icon(file.file_name)}<span class="attachment-name"><span title="${name}">${name}</span><small>${escape_html(t("临时文件 · {size}", { size: attachment_size(file.size) }))}${expiry_markup(file) ? ` · ${expiry_markup(file)}` : ""}</small></span></a>
|
|
5725
5728
|
${attachment_actions(file)}</div>`;
|
|
5726
5729
|
}
|
|
5727
5730
|
|
|
5731
|
+
/**
|
|
5732
|
+
* A temporary cloud video or audio plays in place like a computer's file (user #24195); its bytes load only when asked,
|
|
5733
|
+
* through a short-lived signed link, so drawing a message signs nothing.
|
|
5734
|
+
*/
|
|
5735
|
+
function object_media_markup(file, link, label) {
|
|
5736
|
+
const name = escape_html(file.file_name);
|
|
5737
|
+
const tag = file.content_type.startsWith("video/") ? "video" : "audio";
|
|
5738
|
+
const skinned = Boolean(customElements.get(`${tag}-player`));
|
|
5739
|
+
const poster = tag === "video" ? 'poster="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ' : "";
|
|
5740
|
+
const height = !skinned && tag === "video" ? ROUND_MEDIA_HEIGHT : "";
|
|
5741
|
+
const media = `<${tag} ${poster}${skinned ? "" : "controls "}preload="none" playsinline aria-label="${name}"${height}></${tag}>`;
|
|
5742
|
+
const expiry = expiry_markup(file);
|
|
5743
|
+
const size = `<small>${escape_html(t("临时文件 · {size}", { size: attachment_size(file.size) }))}${expiry ? ` · ${expiry}` : ""}</small>`;
|
|
5744
|
+
return `<div class="attachment-media attachment-${tag}" data-object-state="stored"${attachment_local_title(file)}>${skinned ? `<${tag}-player><${tag}-skin class="attachment-player">${media}</${tag}-skin></${tag}-player>` : media}
|
|
5745
|
+
<span class="attachment-media-failed">${escape_html(t("浏览器无法播放这个文件的格式,请点下面的文件名下载后用本机软件打开。"))}</span>
|
|
5746
|
+
<div class="attachment-media-bar"><button type="button" class="attachment-media-name" data-attachment-load ${attachment_data_attributes(file)}>${escape_html(t("点击加载媒体"))}<small>${attachment_size(file.size)}</small></button><a class="attachment-media-name" ${link} title="${label}">${name}${size}</a>${attachment_actions(file)}</div></div>`;
|
|
5747
|
+
}
|
|
5748
|
+
|
|
5728
5749
|
// What a cloud space file can be looked at as: the type only picks the viewer, anything else is downloaded.
|
|
5729
5750
|
const CLOUD_PREVIEW_TYPES = /^(image|video|audio)\/|^application\/pdf$/;
|
|
5730
5751
|
// A player whose link expired asks for a new one at most this often, so a file that cannot play does not loop.
|
|
@@ -8642,6 +8663,7 @@ function open_requested_attachment_media(media, box, button, file) {
|
|
|
8642
8663
|
try {
|
|
8643
8664
|
if (manual_cloud) cloud_started = Date.now();
|
|
8644
8665
|
const url = manual_cloud ? await attachment_url(file, { via_cloud: true, signal: original.signal })
|
|
8666
|
+
: file.storage === "object" ? await cloud_link(file)
|
|
8645
8667
|
: await open_attachment_url(file, {
|
|
8646
8668
|
signal: original.signal, on_cloud: (enabled = true) => { cloud_started = enabled ? Date.now() : undefined; },
|
|
8647
8669
|
on_cloud_transfer: finish => { cloud_finish = finish; },
|