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.
Files changed (39) hide show
  1. package/.agents/skills/discuss-host/references/room.md +1 -1
  2. package/.agents/skills/discuss-participant/references/situations.md +1 -1
  3. package/.agents/skills/screen-acceptance/SKILL.md +1 -1
  4. package/backend/room_search.py +21 -6
  5. package/docs/en/guide/cli.md +2 -1
  6. package/docs/en/guide/external-members.md +3 -1
  7. package/docs/en/guide/members.md +1 -1
  8. package/docs/en/guide/rooms.md +8 -8
  9. package/docs/en/guide/steward.md +3 -3
  10. package/docs/en/guide/workflows.md +1 -0
  11. package/docs/en/guide/working.md +2 -2
  12. package/docs/guide/cli.md +2 -1
  13. package/docs/guide/external-members.md +3 -1
  14. package/docs/guide/members.md +1 -1
  15. package/docs/guide/rooms.md +8 -8
  16. package/docs/guide/steward.md +3 -3
  17. package/docs/guide/workflows.md +1 -0
  18. package/docs/guide/working.md +2 -2
  19. package/frontend/locales/en/core.json +2 -0
  20. package/frontend/locales/en/discussion.json +24 -1
  21. package/frontend/locales/en/room.json +4 -0
  22. package/frontend/locales/en/steward.json +2 -2
  23. package/package.json +2 -1
  24. package/runner/adapters/profiles.mjs +1 -1
  25. package/runner/codiscuss.mjs +1 -0
  26. package/runner/discuss.py +3 -1
  27. package/runner/discussion_launch.mjs +151 -54
  28. package/runner/external_client.mjs +29 -9
  29. package/runner/free_runner.mjs +22 -19
  30. package/runner/i18n_en.mjs +6 -4
  31. package/runner/image_service.mjs +17 -10
  32. package/runner/moss_windows.mjs +4 -4
  33. package/runner/steward.mjs +22 -19
  34. package/runner/steward_proactive.mjs +30 -5
  35. package/web/app.js +23 -1
  36. package/web/backup.js +1 -1
  37. package/web/i18n.js +2 -2
  38. package/web/modern.css +1 -1
  39. package/web/modern.js +90 -90
@@ -277,9 +277,9 @@
277
277
  "软件与模型": "Software and model",
278
278
  "切换": "Switch",
279
279
  "新开对话": "New conversation",
280
- "没有改动软件、模型或强度": "Software, model and strength are unchanged",
280
+ "没有改动软件、模型、强度或速度": "Software, model, strength and speed are unchanged",
281
281
  "换软件总会开始新的会话:“切换”会让 {name} 接着这个窗口最近的对话往下聊,原会话里没写进对话的过程带不过去;“新开对话”从头开始。": "Changing software always starts a new session. Switch lets {name} pick up from this window's recent conversation, though work in the old session that never reached the conversation does not carry over. New conversation starts from scratch.",
282
- "“切换”保留当前会话,从下一轮起用新的模型与强度;“新开对话”清掉当前会话的上下文。": "Switch keeps the current session and uses the new model and strength from the next turn. New conversation clears the current session's context.",
282
+ "“切换”保留当前会话,新的设置从下一轮起生效;“新开对话”清掉当前会话的上下文。": "Switch keeps the current session and applies the new settings from the next turn. New conversation clears the current session's context.",
283
283
  "“新开对话”清掉当前会话的上下文;对话记录、职责、配置和记忆都保留。": "New conversation clears the current session's context. The conversation history, duties, settings and memory are kept.",
284
284
  "MOSS 正在工作,切换会在它这一轮做完后生效": "MOSS is working. The switch takes effect once this turn is done.",
285
285
  "已改用 {name},下一次对话起生效": "Switched to {name}. It applies from the next conversation.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -27,6 +27,7 @@
27
27
  "@earendil-works/pi-coding-agent": "1.5.2",
28
28
  "@iconify-json/lucide": "1.2.144",
29
29
  "@iconify-json/vscode-icons": "1.2.100",
30
+ "@internationalized/date": "3.12.4",
30
31
  "@mdit/plugin-katex": "1.1.3",
31
32
  "@nuxt/ui": "4.11.3",
32
33
  "@silurus/ooxml": "0.89.9",
@@ -251,7 +251,7 @@ export const ADAPTER_PROFILES = {
251
251
  unsupported_hints: { auto: t('agy 只在交互窗口提供自动模式,后台运行(-p)不支持') },
252
252
  // Only a conversation this tool created gets its session rules; an existing one keeps its own project and permissions.
253
253
  client: 'antigravity', adopt: 'session', host_existing: false, own_project_when_bound: true, browse_sessions: true, copy_bound: true,
254
- capabilities: { steer_receipt: false, live_details: true, compact_context: false, delivery: PROCESS, rewind: 'cut', project: true, access_env: true, limits_directories: true, confines_reads: true, chat: true, resume: true, capture: FINAL_REMARK },
254
+ capabilities: { steer_receipt: false, live_details: true, compact_context: false, delivery: PROCESS, rewind: 'cut', project: true, access_env: true, limits_directories: true, confines_reads: true, chat: true, resume: true, capture: FINAL_REMARK, native_image_gen: true },
255
255
  // In read and write, agy allows only codiscuss commands and headless agy ends the turn on a denied one; agy streams no
256
256
  // thinking text, so without a word at each turning point the page cannot show how far it got.
257
257
  // A denied command ends headless agy's turn at once (1.5.16, 2026-11-25), so it must not list or read through the shell.
@@ -100,6 +100,7 @@ function website_cli(args) {
100
100
  case: t('区分大小写'),
101
101
  word: t('全字匹配'),
102
102
  regex: t('使用正则表达式'),
103
+ order: t('全部房间搜索的排序:relevance 按相关度(标题命中、命中数),recent 按最近发言'),
103
104
  }) },
104
105
  });
105
106
  if (result.error) throw new Error(t('网站操作需要 Python 3.10+,无法启动 {value1}:{value2}', { value1: executable, value2: result.error.message }));
package/runner/discuss.py CHANGED
@@ -739,6 +739,8 @@ def build_parser(prog="discuss"):
739
739
  search.add_argument("--case", action="store_true", help=search_help.get("case", "区分大小写"))
740
740
  search.add_argument("--word", action="store_true", help=search_help.get("word", "全字匹配"))
741
741
  search.add_argument("--regex", action="store_true", help=search_help.get("regex", "使用正则表达式"))
742
+ search.add_argument("--order", choices=("relevance", "recent"), default="relevance",
743
+ help=search_help.get("order", "全部房间搜索的排序:relevance 按相关度(标题命中、命中数),recent 按最近发言"))
742
744
  add_leaf(subcommands, registry, "health", "检查目标站点的 HTTP 健康接口")
743
745
  api = add_leaf(subcommands, registry, "api", "直接调用本站 /api 或 /r;请求体原样传送")
744
746
  api.add_argument("path", help="本站路径,可含查询参数;禁止完整 URL")
@@ -1410,7 +1412,7 @@ def plan_search(args):
1410
1412
  """Send the same search parameters as the page, with any bound room read context."""
1411
1413
  params = {"q": args.keyword, **{key: str(int(getattr(args, key))) for key in ("case", "word", "regex")}}
1412
1414
  if args.search_room is None:
1413
- return RequestPlan("/api/search", params={**params, "archived": "1"})
1415
+ return RequestPlan("/api/search", params={**params, "archived": "1", "order": args.order})
1414
1416
  args.room = args.search_room
1415
1417
  return RequestPlan(f"/api/rooms/{args.room}/search", params={**params, **read_context_params(args)})
1416
1418
 
@@ -39,7 +39,7 @@ import { local_service_stop, local_services } from './tts_providers.mjs';
39
39
  import { CHANNELS, can_notify, moss_send_requirements, channel_command, weixin_command } from './channels.mjs';
40
40
  import { ask_group_task_limit, change_moss_window, clear_moss_group_pending, moss_group_enabled, moss_group_failure, moss_group_task_usage, moss_window_key, moss_window_habits, moss_window_preferences, moss_window_usage, moss_windows, moss_windows_patch } from './moss_windows.mjs';
41
41
  import { stt_part } from './stt.mjs';
42
- import { image_check, image_settings, MODEL_ID, room_image, save_image_settings, validate_image_limits } from './image_service.mjs';
42
+ import { image_check, image_settings, MODEL_ID, native_image_platforms, room_image, save_image_settings, validate_image_limits } from './image_service.mjs';
43
43
  import { open_project } from './adapters/api_files.mjs';
44
44
  import { redact_media_text, run_image_tool } from './adapters/api_images.mjs';
45
45
  import { active_suggestions, admission_view, change_managed_experience, experiences, legacy_text, queue_legacy_experience } from './host_experience.mjs';
@@ -57,7 +57,7 @@ import { site_fetch } from './entry_client.mjs';
57
57
  import { channel_locale, t, with_channel_locale } from './i18n.mjs';
58
58
  import { EXPERIENCE_REVIEW_DUTY, edit_steward_memory, move_steward_memory, post_steward_request, require_steward_skill, require_steward_software, steward_access, steward_defaults, steward_private_defaults, steward_private_patch, steward_profile, steward_room_permissions, steward_settings_patch, steward_site, steward_software, steward_status, sync_steward_platform_skills } from './steward.mjs';
59
59
  import { duty_schedule_options } from './steward.mjs';
60
- import { proactive_settings, revise_proactive_list, steward_proactive_tick } from './steward_proactive.mjs';
60
+ import { occurrence, proactive_settings, revise_proactive_list, steward_proactive_tick } from './steward_proactive.mjs';
61
61
  import { HOST_MODEL_FIELDS, host_configure_items, host_room_limit, without_host_item } from './host_permissions.mjs';
62
62
  import { guest_protection, guest_state_of, guest_withheld, HOST_ACTION_ITEMS, HOST_ITEMS, HOST_LEGACY_ITEMS, host_allowed, host_permission_fields, host_permissions, host_refusal, normalize_host_permissions } from './host_permissions.mjs';
63
63
 
@@ -222,7 +222,7 @@ const help_text = () => `用法:codiscuss launch settings [--file FILE]
222
222
  codiscuss launch templates [--file FILE]
223
223
  codiscuss launch experience list|add|edit|remove|enable|disable|accept|reject|dismiss|go|refine [--id ID] [--file JSON]
224
224
  codiscuss launch experience-propose --message ID --file JSON
225
- codiscuss launch experience review on|off [--at HH:MM]
225
+ codiscuss launch experience review on|off [--at HH:MM [--timezone IANA]]
226
226
  ${t('所有经验均为全局。添加或编辑时,JSON 文件填 text。')}
227
227
  codiscuss launch experience confirm|resolve|direct-enable|retry|revoke-source|distill --id ID [--file JSON]
228
228
  codiscuss launch experience-moss --file JSON
@@ -659,6 +659,7 @@ export async function room_models(home, raw, { read_defaults = profile => cached
659
659
  api_max_requests: config.api_max_requests ?? DEFAULT_API_MAX_REQUESTS,
660
660
  // Whether members may draw here, and whether this computer has an image service to draw with.
661
661
  image_generation: Boolean(config.image_generation), image_mode: config.image_mode ?? 'api', image_configured: image_settings(home).configured,
662
+ native_image_configured: native_image_platforms(home).length > 0,
662
663
  model_specialist: config.model_specialist || '', model_generation: Boolean(config.model_generation), model_configured: model_configured(home),
663
664
  video_generation: Boolean(config.video_generation), video_configured: video_settings(home).configured };
664
665
  }
@@ -1577,7 +1578,8 @@ const internal_admission = Symbol();
1577
1578
  function experience_review_status(home) {
1578
1579
  const steward = launch_settings(home).steward;
1579
1580
  const duty = steward?.proactive?.duties?.find(item => item.id === EXPERIENCE_REVIEW_DUTY);
1580
- return { configured: Boolean(steward?.adapter), enabled: Boolean(steward?.adapter && duty), at: duty?.schedule.at || '08:00' };
1581
+ return { configured: Boolean(steward?.adapter), enabled: Boolean(steward?.adapter && duty), at: duty?.schedule.at || '08:00',
1582
+ ...(duty ? { timezone: duty.schedule.timezone || null, next_run: occurrence(duty.schedule, new Date(), 1).toISOString() } : {}) };
1581
1583
  }
1582
1584
 
1583
1585
  /** Change the account's daily inspection duty. No separate switch is stored. */
@@ -1597,7 +1599,7 @@ export async function experience_review(home, input) {
1597
1599
  if (!experience_review_status(home).configured) throw new Error(t('请先配置 MOSS。'));
1598
1600
  const text = t('执行主持人经验每日排查。先读 dispatch-analysis 技能的“每日排查”一节。');
1599
1601
  const [entry] = revise_proactive_list({ duties: [] }, 'duties', 'add', { text,
1600
- schedule: { at: input.at ?? old?.schedule.at ?? '08:00' } });
1602
+ schedule: { at: input.at ?? old?.schedule.at ?? '08:00', timezone: input.timezone || (input.at ? undefined : old?.schedule.timezone) } });
1601
1603
  duties = [...duties, { ...entry, id: EXPERIENCE_REVIEW_DUTY, created_at: old?.created_at ?? entry.created_at }];
1602
1604
  }
1603
1605
  save_launch_settings(home, {}, { proactive: { ...previous, duties } });
@@ -1792,7 +1794,11 @@ export function save_launch_settings(home, input, steward_patch = null, update_s
1792
1794
  if (update_strategies) settings.host_strategies = validate_host_strategies(update_strategies(previous.host_strategies));
1793
1795
  if (['zh-CN', 'en'].includes(input.channel_locale) && (!input.channel_locale_default || !settings.channel_locale))
1794
1796
  settings.channel_locale = input.channel_locale;
1795
- if (steward_patch) settings.steward = merge_steward_settings(previous.steward, steward_patch);
1797
+ if (steward_patch) {
1798
+ settings.steward = merge_steward_settings(previous.steward, steward_patch);
1799
+ if (steward_patch.adapter !== undefined && settings.steward.adapter !== previous.steward?.adapter)
1800
+ clear_following_group_speeds(settings);
1801
+ }
1796
1802
  if (patch.create_preferences) settings.create_preferences = { ...previous.create_preferences, ...patch.create_preferences };
1797
1803
  if (choices) settings.participants = merge_participant_choices(settings.participants, choices);
1798
1804
  if (Object.hasOwn(prompts || {}, 'host') || input.experience) {
@@ -2484,17 +2490,40 @@ function save_moss_room_preferences(home, window, patch) {
2484
2490
  }
2485
2491
 
2486
2492
  function moss_room_preferences_patch(home, settings, window, patch) {
2487
- if (window === 'main') return steward_settings_patch(patch);
2493
+ if (window === 'main') return steward_preferences_patch(home, settings, patch);
2488
2494
  if (window === 'private') {
2489
- const validated = steward_private_patch(patch);
2495
+ const validated = steward_preferences_patch(home, settings, patch, true);
2490
2496
  if (validated.extra_directories !== undefined) check_extra_directories(steward_private_defaults(home, settings).cwd, validated.extra_directories);
2491
2497
  return { private: validated };
2492
2498
  }
2493
2499
  const windows = settings.steward?.windows || {};
2494
- const preferences = validate_moss_group_preferences(home, settings, window, { ...windows[window], ...patch });
2500
+ const preferences = validate_moss_group_preferences(home, settings, window, { ...windows[window], ...patch }, patch.service_tier !== undefined);
2495
2501
  return { windows: { ...windows, [window]: preferences } };
2496
2502
  }
2497
2503
 
2504
+ /** Drop an old override when switching to software without speed settings. */
2505
+ function moss_speed_reset(patch) {
2506
+ return patch.adapter !== undefined && patch.service_tier === undefined && !adapter_profile(patch.adapter)?.service_tiers
2507
+ ? { service_tier: '' } : {};
2508
+ }
2509
+
2510
+ /** Validate the pending speed against the effective window software and model. */
2511
+ function steward_preferences_patch(home, settings, input, private_window = false) {
2512
+ const patch = (private_window ? steward_private_patch : steward_settings_patch)({ ...input, ...moss_speed_reset(input) });
2513
+ if (['adapter', 'preset', 'model', 'service_tier'].some(key => Object.hasOwn(patch, key))) {
2514
+ const steward = merge_steward_settings(settings.steward, private_window ? { private: patch } : patch);
2515
+ const view = (private_window ? steward_private_defaults : steward_defaults)(home, { ...settings, steward });
2516
+ const [, software] = steward_software(settings, view.adapter, view.preset);
2517
+ validate_moss_speed(home, { ...software, ...view });
2518
+ }
2519
+ return patch;
2520
+ }
2521
+
2522
+ function validate_moss_speed(home, profile) {
2523
+ assert_service_tier(adapter_profile(profile.adapter), profile.service_tier);
2524
+ assert_model_speed(home, profile);
2525
+ }
2526
+
2498
2527
  async function moss_room_settings(home, input, path, config, window) {
2499
2528
  const { cwd, extra_directories: dirs } = input;
2500
2529
  const group = Boolean(config.moss_window);
@@ -2642,11 +2671,14 @@ export async function room_member_model(home, raw, headers = {}, { keep_omitted
2642
2671
  try {
2643
2672
  const config = configuration_snapshot(path).config;
2644
2673
  profile = config.participants?.[name];
2645
- const planned = member_model_profile(home, profile, input, { keep_omitted, defaults: config.moss_window });
2674
+ const speed_only = window && Object.hasOwn(input, 'service_tier') && input.model === undefined && input.effort === undefined;
2675
+ const planned = member_model_profile(home, profile, input, { keep_omitted: keep_omitted || speed_only, defaults: config.moss_window });
2646
2676
  next = planned.next;
2647
2677
  const updated = { ...config, participants: { ...config.participants, [name]: next } };
2648
2678
  validate_config(updated, dirname(path));
2649
- if (window) save_moss_room_preferences(home, window, { model: planned.model, effort: planned.effort });
2679
+ if (window) save_moss_room_preferences(home, window, { ...(speed_only ? {} : { model: planned.model, effort: planned.effort }),
2680
+ ...(Object.hasOwn(input, 'service_tier') || (next.service_tier || '') !== (profile.service_tier || '')
2681
+ ? { service_tier: next.service_tier || '' } : {}) });
2650
2682
  atomic_json(path, updated);
2651
2683
  saved = member_model_receipt(config, path, name, next, planned.facts);
2652
2684
  } finally { release(); }
@@ -2738,7 +2770,7 @@ export async function room_member_adapter(home, raw, { host } = {}) {
2738
2770
  if (window) moss_project_access(window, adapter, next.project_access);
2739
2771
  const updated = { ...config, ...(window ? { project_access: next.project_access } : {}), participants: { ...config.participants, [name]: next } };
2740
2772
  validate_config(updated, dirname(path));
2741
- if (window) save_moss_room_preferences(home, window, { adapter, model: next.model || '', effort: next.effort || '' });
2773
+ if (window) save_moss_room_preferences(home, window, { adapter, model: next.model || '', effort: next.effort || '', service_tier: next.service_tier || '' });
2742
2774
  atomic_json(path, updated);
2743
2775
  return { room_id: input.room_id, member: name, adapter };
2744
2776
  } finally { release(); }
@@ -5233,8 +5265,9 @@ async function finish_spawn_setup(path, room, setup, options) {
5233
5265
  function steward_task_member(config, host, access = 'write') {
5234
5266
  const host_name = platform_of(host);
5235
5267
  const source = config.participants[host];
5236
- const profile = Object.fromEntries(['adapter', 'model', 'effort', 'executable', 'ipc_directory', 'base_url', 'api_protocol', 'api_key_ref']
5268
+ const profile = Object.fromEntries(['adapter', 'model', 'effort', 'service_tier', 'executable', 'ipc_directory', 'base_url', 'api_protocol', 'api_key_ref']
5237
5269
  .filter(field => source[field] !== undefined).map(field => [field, source[field]]));
5270
+ profile.service_tier ??= '';
5238
5271
  return { host_name, names: [host_name], access, participants: { [host_name]: { ...profile, project_access: access } } };
5239
5272
  }
5240
5273
 
@@ -5820,7 +5853,7 @@ async function create_steward(home, view, prepared, options, private_window = fa
5820
5853
  const saved = existsSync(pending) ? JSON.parse(readFileSync(pending, 'utf8')) : null;
5821
5854
  const raw = saved?.room?.host === platform && saved.site === steward_site(home) ? saved : {
5822
5855
  entry: 'web', site: steward_site(home), cwd: view.cwd, project_access: profile.project_access, extra_directories: view.extra_directories,
5823
- without_saved_tools: true, participants: { [platform]: profile }, steward_skills: view.skills,
5856
+ without_saved_tools: true, participants: { [platform]: { ...profile, service_tier: view.service_tier || '' } }, steward_skills: view.skills,
5824
5857
  room: { title: private_window ? t('MOSS 私信') : 'MOSS', mode: 'free', host: platform,
5825
5858
  system_kind: private_window ? 'steward_private' : 'steward', members: [platform], submission_id: randomUUID() },
5826
5859
  };
@@ -5832,9 +5865,37 @@ async function create_steward(home, view, prepared, options, private_window = fa
5832
5865
  return { path: result.config_path, config, room: result.room };
5833
5866
  }
5834
5867
 
5835
- function moss_group_profile(home, settings, channel, chat_id, preferences) {
5836
- const adapter = preferences.adapter || settings.steward?.adapter;
5837
- const [platform, saved] = steward_software(settings, adapter);
5868
+ /** Follow the main software when it can run read-only. Keep a registered group's safe software otherwise. */
5869
+ function moss_group_software(settings, preferences, config) {
5870
+ if (preferences.adapter) return { adapter: preferences.adapter, preset: preferences.preset || '' };
5871
+ const { adapter = '', preset = '' } = settings.steward || {};
5872
+ const [name, profile] = Object.entries(config?.participants || {})[0] || [];
5873
+ if (profile && !main_group_software_ready(settings))
5874
+ return { adapter: profile.adapter, preset: platform_of(name) };
5875
+ return { adapter, preset };
5876
+ }
5877
+
5878
+ function moss_group_speed(adapter, service_tier) {
5879
+ return adapter_profile(adapter)?.service_tiers ? service_tier || '' : '';
5880
+ }
5881
+
5882
+ function main_group_software_ready(settings) {
5883
+ const { adapter, preset } = settings.steward || {};
5884
+ return lockdown_support(adapter, { project_access: 'read' }).supported && Boolean(steward_software(settings, adapter, preset)[1]);
5885
+ }
5886
+
5887
+ /** Clear saved follower overrides as part of the same settings write as a compatible main-software switch. */
5888
+ function clear_following_group_speeds(settings) {
5889
+ const { steward } = settings;
5890
+ const { adapter, windows } = steward;
5891
+ if (!windows || !main_group_software_ready(settings) || adapter_profile(adapter)?.service_tiers) return;
5892
+ steward.windows = Object.fromEntries(Object.entries(windows).map(([key, preferences]) => [key,
5893
+ !preferences.adapter && preferences.service_tier ? { ...preferences, service_tier: '' } : preferences]));
5894
+ }
5895
+
5896
+ function moss_group_profile(home, settings, channel, chat_id, preferences, config) {
5897
+ const { adapter, preset } = moss_group_software(settings, preferences, config);
5898
+ const [platform, saved] = steward_software(settings, adapter, preset);
5838
5899
  if (!saved || !lockdown_support(adapter, { project_access: 'read' }).supported) throw new Error(t('当前 MOSS 软件无法按群窗口要求以只读档运行。'));
5839
5900
  const cwd = moss_group_cwd(home, moss_window_key(channel, chat_id));
5840
5901
  const { executable, ipc_directory, base_url, api_protocol, api_key_ref } = saved;
@@ -5843,7 +5904,9 @@ function moss_group_profile(home, settings, channel, chat_id, preferences) {
5843
5904
  ? provider.models.find(model => /(?:^|[-.])(?:flash|haiku|luna|mini|nano|lite)(?:$|[-.])/i.test(model)) : '';
5844
5905
  const defaults = { model: light_model || saved.model, effort: adapter_profile(adapter)?.efforts?.[0] || '' };
5845
5906
  const profile = { adapter, executable, ipc_directory, base_url, api_protocol, api_key_ref,
5846
- model: preferences.model || defaults.model, effort: preferences.effort || defaults.effort, cwd, project_access: 'read' };
5907
+ model: preferences.model || defaults.model, effort: preferences.effort || defaults.effort,
5908
+ service_tier: moss_group_speed(adapter, preferences.service_tier), cwd, project_access: 'read' };
5909
+ validate_moss_speed(home, profile);
5847
5910
  return { platform, cwd, defaults, profile: Object.fromEntries(Object.entries(profile).filter(([, value]) => value !== undefined)) };
5848
5911
  }
5849
5912
 
@@ -5853,13 +5916,42 @@ function moss_group_cwd(home, key) {
5853
5916
 
5854
5917
  const group_read_directories = paths => paths.map(path => ({ path, access: 'read' }));
5855
5918
 
5856
- function validate_moss_group_preferences(home, settings, key, input) {
5919
+ function moss_group_config(home, room_id) {
5920
+ const path = room_id && registered_room_path(home, steward_site(home), room_id);
5921
+ return path ? configuration_snapshot(path).config : undefined;
5922
+ }
5923
+
5924
+ function validate_moss_group_preferences(home, settings, key, input, strict_speed = false) {
5857
5925
  const preferences = moss_windows_patch({ [key]: moss_window_preferences(input) })[key];
5858
5926
  check_extra_directories(moss_group_cwd(home, key), preferences.read_directories);
5859
- if (preferences.adapter) moss_group_profile(home, settings, ...key.split(':'), preferences);
5927
+ if (!preferences.adapter && !preferences.service_tier) return preferences;
5928
+ const config = !preferences.adapter && moss_group_config(home, moss_windows(home)[key]?.room);
5929
+ const { adapter } = moss_group_software(settings, preferences, config);
5930
+ const tier = moss_group_speed(adapter, preferences.service_tier);
5931
+ if (strict_speed) assert_service_tier(adapter_profile(adapter), preferences.service_tier);
5932
+ if (preferences.adapter || tier) moss_group_profile(home, settings, ...key.split(':'), preferences, config);
5933
+ preferences.service_tier = tier;
5860
5934
  return preferences;
5861
5935
  }
5862
5936
 
5937
+ function moss_group_view(home, settings, preferences, room_id) {
5938
+ const config = !preferences.adapter && !main_group_software_ready(settings)
5939
+ ? moss_group_config(home, room_id) : undefined;
5940
+ const { adapter, preset } = moss_group_software(settings, preferences, config);
5941
+ const [selected] = steward_software(settings, adapter, preset);
5942
+ return { ...preferences, service_tier: moss_group_speed(adapter, preferences.service_tier), window_software: { adapter, preset: selected || preset } };
5943
+ }
5944
+
5945
+ /** Window settings keep the selection separate from the software resolved for the next group delivery. */
5946
+ function steward_status_with_groups(home, settings, room_id) {
5947
+ const status = steward_status(home, settings, room_id);
5948
+ const windows = status.settings.windows;
5949
+ for (const [key, group] of Object.entries(moss_windows(home))) {
5950
+ if (group.room) windows[key] = moss_group_view(home, settings, windows[key] || {}, group.room);
5951
+ }
5952
+ return status;
5953
+ }
5954
+
5863
5955
  function steward_window(home, window = 'main') {
5864
5956
  const settings = launch_settings(home);
5865
5957
  if (window === 'main' || window === 'steward') return { kind: 'steward', cwd: steward_defaults(home, settings).cwd, room_id: settings.steward?.room_id };
@@ -5966,17 +6058,17 @@ export async function moss_group_command(home, input, options = {}) {
5966
6058
  const channel = (options.channels || CHANNELS).find(candidate => candidate.id === channel_id);
5967
6059
  if (!channel?.capabilities?.groups) throw new Error(t('此通知渠道不支持 MOSS 群窗口。'));
5968
6060
  if (action === 'groups') {
5969
- const settings = launch_settings(home).steward;
6061
+ const settings = launch_settings(home);
5970
6062
  const windows = moss_windows(home);
5971
6063
  const groups = channel.ready(home) ? await channel.groups(home) : [];
5972
- return { bound: channel.ready(home), supported: lockdown_support(settings?.adapter, { project_access: 'read' }).supported,
5973
- confines_reads: adapter_capabilities(settings?.adapter).confines_reads === true,
6064
+ return { bound: channel.ready(home), supported: lockdown_support(settings.steward?.adapter, { project_access: 'read' }).supported,
6065
+ confines_reads: adapter_capabilities(settings.steward?.adapter).confines_reads === true,
5974
6066
  groups: groups.map(group => {
5975
6067
  const key = moss_window_key(channel_id, group.id);
5976
6068
  const window = windows[key] || {};
5977
- const preferences = moss_window_preferences(settings?.windows?.[key]);
6069
+ const preferences = moss_group_view(home, settings, moss_window_preferences(settings.steward?.windows?.[key]), window.room);
5978
6070
  return { ...group, enabled: window.enabled === true, room: window.room || null, tasks_used_today: moss_group_task_usage(window).submissions.length,
5979
- ...preferences, adapter: preferences.adapter || settings?.adapter || '', used_today: moss_window_usage(window).used,
6071
+ ...preferences, adapter: preferences.window_software.adapter, used_today: moss_window_usage(window).used,
5980
6072
  silent_count: window.silent_count || 0, last_failure: window.last_failure || null, pending_owner: Boolean(window.pending_owner) };
5981
6073
  }) };
5982
6074
  }
@@ -6005,23 +6097,26 @@ export async function moss_group_command(home, input, options = {}) {
6005
6097
  const saved = all[key];
6006
6098
  const merged = { ...saved, ...input.settings };
6007
6099
  if (Object.hasOwn(input.settings || {}, 'read_directory') && !Object.hasOwn(input.settings, 'read_directories')) delete merged.read_directories;
6008
- const preferences = validate_moss_group_preferences(home, settings, key, merged);
6100
+ const preferences = validate_moss_group_preferences(home, settings, key, merged, input.settings?.service_tier !== undefined);
6009
6101
  if (action === 'group-settings') {
6010
6102
  if (!current) throw new Error(t('请先开启此 MOSS 群窗口。'));
6011
6103
  save_launch_settings(home, {}, { windows: { ...all, [key]: preferences } });
6012
- return { ...preferences, enabled: current.enabled, room_id: current.room };
6104
+ return { ...moss_group_view(home, settings, preferences, current.room), enabled: current.enabled, room_id: current.room };
6013
6105
  }
6014
6106
  if (!channel.ready(home)) throw new Error(t('请先在通知渠道绑定房主账号。'));
6015
6107
  const group = (await channel.groups(home, { check_owner: false })).find(item => item.id === chat_id);
6016
6108
  if (!group) throw new Error(t('找不到此账号所在的群。'));
6017
6109
  const create = options.create || create_moss_group;
6018
- moss_group_profile(home, launch_settings(home), channel.id, group.id, preferences);
6110
+ moss_group_profile(home, launch_settings(home), channel.id, group.id, preferences, moss_group_config(home, current?.room));
6019
6111
  const room = current?.room || await create(home, channel, group, preferences, options);
6020
- if (input.settings) save_launch_settings(home, {}, { windows: { ...all, [key]: preferences } });
6112
+ const latest = launch_settings(home);
6113
+ const { service_tier, window_software } = moss_group_view(home, latest, preferences, room);
6114
+ if (input.settings || (saved?.service_tier || '') !== service_tier)
6115
+ save_launch_settings(home, {}, { windows: { ...latest.steward?.windows, [key]: { ...preferences, service_tier } } });
6021
6116
  change_moss_window(home, key, saved => ({ ...saved, enabled: true, room, title: group.title }));
6022
6117
  const introduction = input.introduce === true && !current?.enabled;
6023
6118
  const introduction_sent = introduction ? await introduce_moss_group(home, channel, group, key, options.log) : undefined;
6024
- return { enabled: true, room_id: room, title: group.title, group: { ...group, enabled: true, room },
6119
+ return { enabled: true, room_id: room, title: group.title, group: { ...group, enabled: true, room, window_software },
6025
6120
  ...(introduction ? { introduction_sent } : {}) };
6026
6121
  } finally { release(); }
6027
6122
  }
@@ -6070,7 +6165,9 @@ async function launch_steward_with_recovery(home, raw, options) {
6070
6165
 
6071
6166
  /** Replace the execution member when software changes, keeping its room and conversation. */
6072
6167
  async function save_steward_settings(home, input) {
6073
- const patch = steward_settings_patch(input);
6168
+ let settings = launch_settings(home);
6169
+ const patch = steward_preferences_patch(home, settings, input);
6170
+ if (Object.hasOwn(input, 'private')) patch.private = steward_preferences_patch(home, settings, input.private, true);
6074
6171
  const roster = input.create_preferences;
6075
6172
  if (Object.hasOwn(input, 'create_preferences')) {
6076
6173
  validate_create_preferences(roster);
@@ -6079,7 +6176,6 @@ async function save_steward_settings(home, input) {
6079
6176
  throw new Error(t('MOSS 建房成员设置无效,主持人须在成员名单中'));
6080
6177
  }
6081
6178
  }
6082
- let settings = launch_settings(home);
6083
6179
  const view_for_patch = steward_defaults(home, { ...settings, steward: { ...settings.steward, ...patch } });
6084
6180
  check_extra_directories(view_for_patch.cwd, patch.extra_directories ?? settings.steward?.extra_directories ?? []);
6085
6181
  const previous_cwd = steward_defaults(home, settings).cwd;
@@ -6087,11 +6183,8 @@ async function save_steward_settings(home, input) {
6087
6183
  const main = { kind: 'steward', cwd: view_for_patch.cwd };
6088
6184
  if (moving) window_memory_directory(home, main);
6089
6185
  if (patch.private?.extra_directories !== undefined) check_extra_directories(steward_private_defaults(home, settings).cwd, patch.private.extra_directories);
6090
- for (const [key, saved] of Object.entries(patch.windows || {})) {
6091
- const [channel, chat_id] = key.split(':');
6092
- check_extra_directories(moss_group_cwd(home, key), saved.read_directories || []);
6093
- if (saved.adapter) moss_group_profile(home, settings, channel, chat_id, saved);
6094
- }
6186
+ const group_settings = { ...settings, steward: merge_steward_settings(settings.steward, patch) };
6187
+ for (const [key, saved] of Object.entries(patch.windows || {})) patch.windows[key] = validate_moss_group_preferences(home, group_settings, key, saved);
6095
6188
  const current = await registered_steward(home, settings.steward?.room_id);
6096
6189
  settings = record_steward_software(home, settings, current);
6097
6190
  if (patch.proactive || patch.adapter === '') {
@@ -6111,7 +6204,7 @@ async function save_steward_settings(home, input) {
6111
6204
  const save = () => save_launch_settings(home, roster ? { create_preferences: roster } : {}, patch);
6112
6205
  const { settings: result, memory_move } = moving ? move_steward_memory(
6113
6206
  window_memory_directory(home, { ...main, cwd: previous_cwd }), window_memory_directory(home, main), save) : { settings: save() };
6114
- return { ...steward_status(home, result, current?.config.room), ...(memory_move ? { memory_move } : {}),
6207
+ return { ...steward_status_with_groups(home, result, current?.config.room), ...(memory_move ? { memory_move } : {}),
6115
6208
  ...(roster ? { create_preferences: roster } : {}), ...(busy ? { busy: true } : {}) };
6116
6209
  }
6117
6210
 
@@ -6154,7 +6247,7 @@ export async function poll_steward_proactive(home) {
6154
6247
 
6155
6248
  /** Check both platform identity and the selected adapter using generic profile metadata. */
6156
6249
  function steward_software_changed(config, view, settings) {
6157
- const [platform] = steward_software(settings, view.adapter);
6250
+ const [platform] = steward_software(settings, view.adapter, view.preset);
6158
6251
  const [name, profile] = Object.entries(config.participants)[0];
6159
6252
  return Boolean(platform && (platform_of(name) !== platform || profile.adapter !== view.adapter));
6160
6253
  }
@@ -6164,7 +6257,8 @@ function steward_delivery_changed(config, view, settings) {
6164
6257
  return steward_software_changed(config, view, settings) || profile?.project_access !== view.project_access ||
6165
6258
  config.cwd !== view.cwd ||
6166
6259
  JSON.stringify(config.extra_directories || []) !== JSON.stringify(view.extra_directories || []) ||
6167
- (profile?.model || '') !== view.model || (profile?.effort || '') !== view.effort;
6260
+ (profile?.model || '') !== view.model || (profile?.effort || '') !== view.effort ||
6261
+ (profile?.service_tier || '') !== (view.service_tier || '');
6168
6262
  }
6169
6263
 
6170
6264
  function steward_renew_path(path) { return join(dirname(path), 'steward-renew.json'); }
@@ -6217,8 +6311,7 @@ function prepare_group_delivery(home, config, settings) {
6217
6311
  const { channel, chat_id } = config.moss_window;
6218
6312
  const key = moss_window_key(channel, chat_id);
6219
6313
  const preferences = moss_window_preferences(settings.steward?.windows?.[key]);
6220
- preferences.adapter ||= Object.values(config.participants)[0].adapter;
6221
- const prepared = moss_group_profile(home, settings, channel, chat_id, preferences);
6314
+ const prepared = moss_group_profile(home, settings, channel, chat_id, preferences, config);
6222
6315
  return { prepared, view: { cwd: prepared.cwd, group_defaults: prepared.defaults,
6223
6316
  extra_directories: group_read_directories(preferences.read_directories) } };
6224
6317
  }
@@ -6236,7 +6329,7 @@ function prepare_steward_renewal(home, config, settings, changed) {
6236
6329
 
6237
6330
  /** Save only supplied choices, then replace the member using the latest window settings. */
6238
6331
  async function renew_steward(home, current, input = {}) {
6239
- const selection = Object.fromEntries(['adapter', 'model', 'effort'].filter(key => Object.hasOwn(input, key)).map(key => [key, input[key]]));
6332
+ const selection = Object.fromEntries(['adapter', 'preset', 'model', 'effort', 'service_tier'].filter(key => Object.hasOwn(input, key)).map(key => [key, input[key]]));
6240
6333
  let settings = launch_settings(home);
6241
6334
  const patch = Object.keys(selection).length ? moss_room_preferences_patch(home, settings, moss_room_selector(current.config), selection) : null;
6242
6335
  if (patch) settings = { ...settings, steward: merge_steward_settings(settings.steward, patch) };
@@ -6297,10 +6390,12 @@ async function activate_group_software(home, config, queued) {
6297
6390
  function group_delivery_changed(home, config, key) {
6298
6391
  const settings = launch_settings(home);
6299
6392
  const preferences = moss_window_preferences(settings.steward?.windows?.[key]);
6300
- const [profile] = Object.values(config.participants);
6301
- preferences.adapter ||= profile.adapter;
6302
- if (preferences.adapter === profile.adapter && (profile.model || '') === (preferences.model || config.moss_window.default_model || '') &&
6393
+ const [name, profile] = Object.entries(config.participants)[0];
6394
+ const { adapter, preset } = moss_group_software(settings, preferences, config);
6395
+ const [platform] = steward_software(settings, adapter, preset);
6396
+ if (adapter === profile.adapter && (!platform || platform === platform_of(name)) && (profile.model || '') === (preferences.model || config.moss_window.default_model || '') &&
6303
6397
  (profile.effort || '') === (preferences.effort || config.moss_window.default_effort || '') &&
6398
+ (profile.service_tier || '') === moss_group_speed(adapter, preferences.service_tier) &&
6304
6399
  JSON.stringify(config.extra_directories || []) === JSON.stringify(group_read_directories(preferences.read_directories))) return null;
6305
6400
  return settings;
6306
6401
  }
@@ -6396,7 +6491,9 @@ export async function steward_command(home, action, input = {}, options = {}) {
6396
6491
  try {
6397
6492
  const current = registered_room_config(home, steward_site(home), window.room_id);
6398
6493
  const busy = (await renew_steward(home, { ...current, room: await api(current.config, '') }, input)).busy;
6399
- return { room_id: window.room_id, busy };
6494
+ const settings = launch_settings(home);
6495
+ const preferences = settings.steward?.windows?.[window.key] || {};
6496
+ return { room_id: window.room_id, busy, ...moss_group_view(home, settings, preferences, window.room_id) };
6400
6497
  } finally { release(); }
6401
6498
  }
6402
6499
  const writing = ['steward-settings', 'steward-request', 'steward-duty', 'steward-mute', 'steward-renew'].includes(action) || input.open === true;
@@ -6411,11 +6508,11 @@ export async function steward_command(home, action, input = {}, options = {}) {
6411
6508
  if (action === 'steward-renew') {
6412
6509
  if (!current) throw new Error(t('请先打开 MOSS 对话,再开始新会话'));
6413
6510
  const { busy } = await renew_steward(home, current, input);
6414
- return { ...steward_status(home, launch_settings(home), current.config.room), busy };
6511
+ return { ...steward_status_with_groups(home, launch_settings(home), current.config.room), busy };
6415
6512
  }
6416
6513
  const view = steward_defaults(home, settings);
6417
6514
  const switched = current && steward_software_changed(current.config, view, settings);
6418
- if (!writing) return steward_status(home, settings, current?.config.room);
6515
+ if (!writing) return steward_status_with_groups(home, settings, current?.config.room);
6419
6516
  require_steward_software(view);
6420
6517
  sync_steward_platform_skills(home, undefined, false);
6421
6518
  if (action === 'steward-request') {
@@ -6425,14 +6522,14 @@ export async function steward_command(home, action, input = {}, options = {}) {
6425
6522
  if (current && existsSync(steward_renew_path(current.path))) {
6426
6523
  const { config, busy } = await renew_steward(home, current);
6427
6524
  if (action === 'steward-request') return await post_steward_request(config, input, options.queue === true);
6428
- return { ...steward_status(home, settings, config.room), busy };
6525
+ return { ...steward_status_with_groups(home, settings, config.room), busy };
6429
6526
  }
6430
- if (current && !switched && action === 'steward') return steward_status(home, settings, current.config.room);
6527
+ if (current && !switched && action === 'steward') return steward_status_with_groups(home, settings, current.config.room);
6431
6528
  const prepared = steward_profile(home, settings, view, participant_profile);
6432
6529
  assert_model_available(home, prepared.platform, prepared.profile);
6433
6530
  current ||= await create_steward(home, view, prepared, { ...options, lang: input.lang });
6434
6531
  const { config, busy } = await configure_steward(current, view, prepared);
6435
- if (action === 'steward') return { ...steward_status(home, settings, current.config.room), ...(busy ? { busy: true } : {}) };
6532
+ if (action === 'steward') return { ...steward_status_with_groups(home, settings, current.config.room), ...(busy ? { busy: true } : {}) };
6436
6533
  return await post_steward_request(config, input, options.queue === true);
6437
6534
  } finally { release?.(); }
6438
6535
  }
@@ -6503,7 +6600,7 @@ function host_rule_command(op, id, values) {
6503
6600
  export async function launch_main(args = process.argv.slice(2), input_text) {
6504
6601
  const { values, positionals } = parseArgs({ args, allowPositionals: true, options: {
6505
6602
  file: { type: 'string' }, 'dry-run': { type: 'boolean' }, browser: { type: 'boolean' }, remote: { type: 'boolean' }, device: { type: 'string' },
6506
- 'configuration-locked': { type: 'boolean' }, help: { type: 'boolean', short: 'h' }, overwrite: { type: 'boolean' }, at: { type: 'string' }, weekdays: { type: 'string' }, deliver: { type: 'string' }, preset: { type: 'string' }, workflow: { type: 'string' }, from: { type: 'string' },
6603
+ 'configuration-locked': { type: 'boolean' }, help: { type: 'boolean', short: 'h' }, overwrite: { type: 'boolean' }, at: { type: 'string' }, timezone: { type: 'string' }, weekdays: { type: 'string' }, deliver: { type: 'string' }, preset: { type: 'string' }, workflow: { type: 'string' }, from: { type: 'string' },
6507
6604
  'overwrite-preset': { type: 'boolean' }, 'replace-knowledge': { type: 'boolean' },
6508
6605
  'project-id': { type: 'string' }, scope: { type: 'string' }, project: { type: 'string' }, draft: { type: 'string' }, 'access-file': { type: 'string' }, dir: { type: 'string' }, card: { type: 'string' }, sub: { type: 'string' }, id: { type: 'string' },
6509
6606
  member: { type: 'string' }, order: { type: 'string' }, revision: { type: 'string' }, name: { type: 'string' }, access: { type: 'string' },
@@ -6576,7 +6673,7 @@ export async function launch_main(args = process.argv.slice(2), input_text) {
6576
6673
  return process.stdout.write(JSON.stringify(result) + '\n');
6577
6674
  }
6578
6675
  if (process.env.DISCUSS_ACCESS_FILE || values['access-file']) throw new Error(t('只有用户能管理经验。'));
6579
- if (positionals[1] === 'review') return process.stdout.write(JSON.stringify(await experience_review(home, { mode: positionals[2], at: values.at })) + '\n');
6676
+ if (positionals[1] === 'review') return process.stdout.write(JSON.stringify(await experience_review(home, { mode: positionals[2], at: values.at, timezone: values.timezone })) + '\n');
6580
6677
  input.action = positionals[1] || 'list';
6581
6678
  if (values.id) input.id = values.id;
6582
6679
  if (input.action === 'go') return process.stdout.write(JSON.stringify(await start_intent(home, input.id)) + '\n');