ai_co_discuss 0.2.99 → 0.3.0

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/SKILL.md +3 -3
  2. package/.agents/skills/discuss-host/references/discussion.md +16 -16
  3. package/.agents/skills/discuss-host/references/launch.md +1 -3
  4. package/.agents/skills/discuss-host/references/manual.md +14 -77
  5. package/.agents/skills/discuss-participant/SKILL.md +3 -3
  6. package/.agents/skills/discuss-participant/references/discussion.md +29 -27
  7. package/.agents/skills/discuss-participant/references/free.md +2 -2
  8. package/.agents/skills/discuss-participant/references/manual.md +8 -10
  9. package/.agents/skills/discuss-participant/references/writing.md +9 -9
  10. package/.github/SECURITY.md +1 -1
  11. package/README.md +3 -3
  12. package/README.zh-CN.md +3 -3
  13. package/backend/free_room.py +360 -68
  14. package/backend/room_import.py +75 -15
  15. package/backend/runtime.py +81 -169
  16. package/backend/schema.sql +136 -244
  17. package/backend/server.py +602 -166
  18. package/backend/session_room.py +919 -0
  19. package/docs/architecture.md +3 -2
  20. package/docs/en/architecture.md +4 -3
  21. package/docs/en/runner.md +3 -1
  22. package/docs/en/workflow.md +9 -6
  23. package/docs/runner.md +3 -1
  24. package/docs/workflow.md +11 -8
  25. package/package.json +2 -2
  26. package/runner/api_participant.mjs +47 -44
  27. package/runner/discuss.py +77 -58
  28. package/runner/discussion_adapters.mjs +6 -3
  29. package/runner/discussion_launch.mjs +98 -70
  30. package/runner/discussion_runner.mjs +38 -496
  31. package/runner/discussion_service.mjs +21 -74
  32. package/runner/discussion_sidecar.mjs +4 -13
  33. package/runner/expert_prompts.mjs +29 -21
  34. package/runner/free_runner.mjs +84 -19
  35. package/runner/session_driver.mjs +175 -0
  36. package/web/app.js +193 -128
  37. package/web/backup.js +1 -1
  38. package/web/modern.css +1 -1
  39. package/web/modern.js +5482 -6646
@@ -15,7 +15,8 @@ import { API_PROVIDERS, api_check, api_models, save_api_key, saved_api_keys, val
15
15
  import { SCHEDULER_PROVIDERS, scheduler_check } from './scheduler.mjs';
16
16
  import { access_levels, BUILTIN_EXPERT_PRESETS, MAX_EXPERT_PROMPT, PROJECT_ACCESS } from './expert_prompts.mjs';
17
17
  import { BRANCHABLE_ADAPTERS, branch_session } from './session_cut.mjs';
18
- import { acquire_lock, api, CODEX_ADAPTERS, DiscussionStore, service_drafts, task_files, validate_config } from './discussion_runner.mjs';
18
+ import { acquire_lock, api, CODEX_ADAPTERS, DiscussionStore, service_drafts, validate_config } from './discussion_runner.mjs';
19
+ import { FreeRoomRunner, free_task_files } from './free_runner.mjs';
19
20
  import { assert_shared_home, CONNECTION_FIELDS, configuration_snapshot, read_registry, registered_identity, register_room, service_home, service_pid, start_service } from './discussion_service.mjs';
20
21
 
21
22
  const CLIENTS = { Codex: ['codex_cli', 'codex', 'api'], Claude: ['claude', 'api'], Gemini: ['antigravity_cli', 'antigravity', 'api'], DeepSeek: ['api'], Qwen: ['api'], Grok: ['api'] };
@@ -40,8 +41,7 @@ const PROFILE_FIELDS = ['adapter', 'executable', 'model', 'effort', 'source_thre
40
41
  const MAX_MINUTES = 1440;
41
42
  const SESSION_ID_PATTERN = /^[0-9A-Za-z_-]{8,128}$/;
42
43
  const LOCAL_MEMBERS_FORMAT = 'ai-codiscuss-local-members';
43
- // Reading events after this id proves the owner credential without transferring any.
44
- const MAX_EVENT_ID = 2147483647;
44
+ // Reading the inbox proves the owner credential without transferring any messages.
45
45
  const CONFIG_APPLY_TIMEOUT_MS = 6000;
46
46
  const CONFIG_APPLY_POLL_MS = 100;
47
47
  const HELP = `用法:codiscuss launch settings [--file FILE]
@@ -556,8 +556,8 @@ async function member_room_context(home, raw) {
556
556
  });
557
557
  if (paths.length !== 1) throw new Error('未找到本房间唯一的已登记配置,请核对本机接入服务');
558
558
  const config = configuration_snapshot(paths[0]).config;
559
- // Both reads need the owner credential; a discussion reads past its last event so nothing is transferred.
560
- await site_request(input.site, `/api/rooms/${input.room_id}/${config.mode === 'free' ? 'inbox' : `events?after=${MAX_EVENT_ID}`}`, input.token);
559
+ // Both reads need the owner credential; the inbox transfers no messages.
560
+ await site_request(input.site, `/api/rooms/${input.room_id}/inbox`, input.token);
561
561
  return { input, path: paths[0], config };
562
562
  }
563
563
 
@@ -577,7 +577,8 @@ export async function room_member(home, raw, locked = false) {
577
577
  const { input, path, config: registered } = await member_room_context(home, raw);
578
578
  const { action, name } = input;
579
579
  const access = input.access || 'runner';
580
- const free = registered.mode === 'free';
580
+ const room = await site_request(input.site, `/api/rooms/${input.room_id}`, input.token);
581
+ const free = room.mode === 'free';
581
582
  if (!['add', 'rejoin'].includes(action) || !platform_of(name) || (access !== 'manual' && !clients_of(name)) || !['runner', 'manual'].includes(access)) {
582
583
  throw new Error('action 须为 add/rejoin,成员须为支持的 AI,接入方式须为 runner/manual');
583
584
  }
@@ -585,7 +586,6 @@ export async function room_member(home, raw, locked = false) {
585
586
  try {
586
587
  const config = configuration_snapshot(path).config;
587
588
  config.api_home = home;
588
- const room = await site_request(input.site, `/api/rooms/${input.room_id}`, input.token);
589
589
  const roster = free ? room.free.members : room.members;
590
590
  if (action === 'add' && input.new_instance) {
591
591
  // A name once bound keeps its session locally, so a new instance never reuses a removed member's name.
@@ -740,7 +740,9 @@ export function adopt_member_profile(home, path, name, session_id, client = 'cla
740
740
  const sidecar = adapter === 'antigravity' ? { ipc_directory: join(dirname(path), 'agy-app-sidecar') } : {};
741
741
  // A manually started member keeps its own session's permissions; the room's 只读 / 可写 does not apply to it.
742
742
  const input = { cwd: config.cwd, adopt: true, participants: { [name]: { adapter, session_id, project_access: 'own', ...sidecar } } };
743
- const profile = borrowed_session(name, participant_profile(name, launch_settings(home).participants, input, false), config.cwd);
743
+ // Its model, effort, prompt and tools stay as the user set them in that session; machine defaults never override them.
744
+ const { model, effort, allowed_tools, system_prompt, ...own } = participant_profile(name, launch_settings(home).participants, input, false);
745
+ const profile = borrowed_session(name, own, config.cwd);
744
746
  if (sidecar.ipc_directory) setup_sidecar(sidecar);
745
747
  // A free room delivers with each member's own credential; the browser-made one is not kept locally, so the owner issues a new one.
746
748
  const next = { ...config, participants: { ...config.participants, [name]: profile },
@@ -781,7 +783,7 @@ export async function room_profiles(home, raw) {
781
783
  const path = registered_room_path(home, input.site, input.room_id);
782
784
  if (!path) return { room_id: input.room_id, local_members: null };
783
785
  const config = configuration_snapshot(path).config;
784
- await site_request(input.site, `/api/rooms/${input.room_id}/${config.mode === 'free' ? 'inbox' : `events?after=${MAX_EVENT_ID}`}`, input.token);
786
+ await site_request(input.site, `/api/rooms/${input.room_id}/inbox`, input.token);
785
787
  const sessions = bound_sessions(config, path);
786
788
  const participants = Object.fromEntries(Object.entries(config.participants).map(([name, profile]) => {
787
789
  const kept = Object.fromEntries(Object.entries(profile).filter(([key]) => [...PROFILE_FIELDS, 'project_access'].includes(key)));
@@ -929,65 +931,84 @@ function check_registration(home, config, path) {
929
931
  }
930
932
  }
931
933
 
932
- /** Start once; a lost start response is reconciled from the persisted expected generation. */
933
- async function enable_run(config, record, persist, minutes) {
934
- let runtime = await api(config, '/runtime');
935
- if (!record.generation && record.expected_generation === runtime.generation && runtime.revision === record.start_revision && runtime.status === 'running') {
936
- record.generation = runtime.generation;
937
- persist();
934
+ /** Start a session once, reconciling a lost response from the durable start intent. */
935
+ async function start_session(config, record, persist, room, minutes) {
936
+ const state = await api(config, '/discussion');
937
+ if (record.session_id && state.session?.id === record.session_id && !record.start_pending) {
938
+ if (record.start_submission_id && state.session.start_submission_id !== record.start_submission_id) {
939
+ throw new Error('房间当前讨论的启动编号与本次记录不同');
940
+ }
941
+ if (state.session.status !== 'active') throw new Error('讨论已暂停或结束;请在房间核对状态后再操作');
942
+ return state.session;
938
943
  }
939
- if (record.generation) {
940
- if (runtime.generation !== record.generation || runtime.status !== 'running' || runtime.expired) throw new Error('这次启动已暂停、停止或过期;请在原房间核对并明确继续');
941
- return runtime;
944
+ if (record.session_id && state.session?.id !== record.session_id) throw new Error('房间当前讨论与本次启动记录不同');
945
+ if (state.session && !record.start_pending) {
946
+ if (state.session.status !== 'active') throw new Error('讨论已暂停或结束;请在房间核对状态后再操作');
947
+ throw new Error('房间已有进行中的讨论;请沿用原启动记录');
942
948
  }
943
- if (runtime.status !== 'ready' || runtime.expired) throw new Error('房间已运行、暂停、停止或过期;请在原房间核对,不会重新启动');
944
- if (!record.start_revision) { record.start_revision = runtime.revision + 1; persist(); }
945
- if (runtime.revision + 1 !== record.start_revision) throw new Error('启动期间房间状态已变化,请核对原房间');
946
- record.expected_generation = runtime.generation + 1;
947
- persist();
948
- try {
949
- runtime = await api(config, '/runtime', { action: 'start', mode: 'automatic', revision: runtime.revision,
950
- deadline: minutes ? Math.floor(Date.now() / 1000 + minutes * 60) : 0 });
951
- } catch (error) {
952
- const latest = await api(config, '/runtime');
953
- if (latest.generation !== record.expected_generation || latest.status !== 'running') throw error;
954
- runtime = latest;
949
+ if (room.session?.status === 'concluded' && !record.start_pending) throw new Error('房间中的讨论已结束;请从房间明确开启新讨论');
950
+ if (!record.start_submission_id) record.start_submission_id = randomUUID();
951
+ if (!record.start_request) {
952
+ if (record.start_revision && record.start_revision !== state.revision) throw new Error('开启期间讨论状态已变化,请重新读取房间状态');
953
+ const topic_minutes = Number(room.limits?.max_minutes || 0);
954
+ const session_minutes = topic_minutes > 0 ? (minutes > 0 ? Math.min(topic_minutes, minutes) : topic_minutes) : minutes;
955
+ record.start_revision = state.revision;
956
+ record.start_request = { action: 'start', revision: state.revision, submission_id: record.start_submission_id,
957
+ goal: room.goal || room.title, named_followup: Boolean(room.named_followup),
958
+ limits: { max_rounds: room.limits?.max_rounds ?? 0, max_minutes: session_minutes,
959
+ execution_minutes: room.limits?.execution_minutes ?? 0 } };
960
+ record.start_pending = true;
961
+ persist();
955
962
  }
956
- record.generation = runtime.generation;
963
+ const result = await api(config, '/discussion', record.start_request);
964
+ if (!result.session || result.session.start_submission_id !== record.start_submission_id) throw new Error('网站返回的讨论会话与本次启动编号不符');
965
+ record.session_id = result.session.id;
966
+ record.start_pending = false;
957
967
  persist();
958
- return runtime;
968
+ if (result.session.status !== 'active') throw new Error('本次讨论已暂停或结束;请在房间核对状态后再操作');
969
+ return result.session;
959
970
  }
960
971
 
961
972
  /** Reserve the first host task for the calling conversation without sending it a duplicate prompt. */
962
973
  async function current_host_task(config, record, persist, room) {
963
- const page = await api(config, '/events?after=0');
964
- const event = record.event_id ? page.events.find(item => item.id === record.event_id)
965
- : page.events.filter(item => item.generation === record.generation && item.role === 'host' && item.participant === room.host && item.status === 'pending').at(-1);
966
- if (!event) throw new Error('没有可由当前会话接手的主持任务;请核对原房间');
967
- record.event_id = event.id;
968
- record.execution_token ||= randomUUID();
974
+ if (record.current_task) return record.current_task;
975
+ const discussion = await api(config, '/discussion');
976
+ if (discussion.session?.status !== 'active' || discussion.session.id !== record.session_id) throw new Error('本次讨论会话已暂停、结束或变化;请核对原房间');
977
+ const page = await api(config, '/inbox');
978
+ const member = page.members.find(item => item.name === room.host && item.role === 'host');
979
+ const request = member?.pending.find(item => item.purpose === 'discuss_host' && item.session_id === record.session_id);
980
+ if (!member || (!request && !record.execution_client_id && !record.execution_id)) throw new Error('没有可由当前会话接手的主持请求;请核对原房间');
981
+ record.execution_client_id ||= randomUUID();
982
+ persist();
983
+ const execution = record.execution_id ? await api(config, `/executions/${record.execution_id}`)
984
+ : await api(config, '/executions', { member_id: member.id, client_id: record.execution_client_id, cwd: '' });
985
+ if (!['dispatched', 'started'].includes(execution.status)) throw new Error('主持请求已不再等待执行;请核对原房间');
986
+ if (!execution.requests?.some(item => item.purpose === 'discuss_host' && item.session_id === record.session_id)) {
987
+ throw new Error('预约到的执行不属于本次讨论主持请求');
988
+ }
989
+ record.execution_id = execution.id;
969
990
  persist();
970
- if (event.status === 'pending') await api(config, `/events/${event.id}`, { action: 'reserve', execution_token: record.execution_token });
971
- else await api(config, `/events/${event.id}`, { action: 'view' }, record.execution_token);
972
991
  const store = new DiscussionStore(config.directory);
973
992
  try {
974
993
  store.context(config);
975
- const runtime = await api(config, '/runtime');
976
- store.scope(config, runtime.run_id);
977
- store.receive(page);
994
+ store.scope(config);
978
995
  const session_id = config.participants[room.host].session_id;
979
996
  store.bind(room.host, session_id);
980
- const task = task_files(config, event, record.execution_token, { session_id });
981
- store.record(event.id, { status: 'accepted', token: record.execution_token, sent_at: Date.now() });
982
- return { event_id: event.id, access_file: task.access_path, task_file: join(config.directory, `${task.id}.task.json`) };
997
+ const task = free_task_files(config, member, execution, { session_id }, { session: discussion.session, process_access: false });
998
+ new FreeRoomRunner(config, store).save(room.host, { client_id: record.execution_client_id, execution_id: execution.id,
999
+ status: 'running', attempts: 0, started: Date.now(), last_renew: Date.now() });
1000
+ record.current_task = { execution_id: execution.id, access_file: task.access_path, task_file: join(config.directory, `${task.id}.task.json`) };
1001
+ persist();
1002
+ return record.current_task;
983
1003
  } finally { store.close(); }
984
1004
  }
985
1005
 
986
1006
  /** Return launch evidence and paths, never raw control or execution tokens. */
987
1007
  async function launch_receipt(config, record, config_path) {
988
1008
  const room = await api(config, '');
1009
+ const discussion = record.session_id ? await api(config, '/discussion') : null;
989
1010
  return { entry: record.entry, room, url: `${config.site}/?room=${config.room}`, config_path,
990
- status: room.mode === 'free' ? 'free' : room.runtime.status, current_task: record.current_task || null };
1011
+ status: discussion?.session?.status || (record.session_id ? 'concluded' : 'free'), current_task: record.current_task || null };
991
1012
  }
992
1013
 
993
1014
  /** Read a saved launch without creating state during validation or preview. */
@@ -997,13 +1018,17 @@ function read_launch(directory) {
997
1018
  }
998
1019
 
999
1020
  /** Find the registered room only after proving the caller's original control credential. */
1000
- async function room_config_context(home, raw) {
1021
+ async function room_config_context(home, raw, options = {}) {
1001
1022
  const input = launch_input({ ...raw, entry: 'web' });
1002
1023
  if (!input.room_id || typeof input.token !== 'string' || !input.token.trim()) throw new Error('读取本场配置须提供房间编号和原控制凭据');
1003
- const room = await site_request(input.site, `/api/rooms/${input.room_id}`, input.token);
1004
- if (!room.runtime?.protected) throw new Error('本场配置修正仅支持具有原控制凭据的受保护房间');
1005
- await verify_control({ site: input.site, room: input.room_id, token: input.token }, room);
1006
- if (room.archived || room.runtime.mode !== 'automatic' || room.runtime.status !== 'paused' || room.phase === 'concluded') throw new Error('请先暂停本场讨论,再修正软件路径');
1024
+ const room = options.local_guard ? { id: input.room_id, archived: false }
1025
+ : await site_request(input.site, `/api/rooms/${input.room_id}`, input.token);
1026
+ const config = { site: input.site, room: input.room_id, token: input.token };
1027
+ if (!options.local_guard) await verify_control(config, room);
1028
+ const discussion = options.local_guard
1029
+ ? { session: { status: 'paused' }, revision: raw.session_revision ?? raw.runtime_revision }
1030
+ : await api(config, '/discussion');
1031
+ if (room.archived || discussion.session?.status !== 'paused') throw new Error('请先暂停本场讨论,再修正软件路径');
1007
1032
  const paths = read_registry(home).filter(path => {
1008
1033
  const identity = registered_identity(path);
1009
1034
  return identity?.site === input.site && identity.room === input.room_id;
@@ -1012,12 +1037,12 @@ async function room_config_context(home, raw) {
1012
1037
  const path = paths[0];
1013
1038
  const journal = read_launch(dirname(path));
1014
1039
  if (journal && !journal.finished) throw new Error('本次启动尚未完成,请先核对原启动待办');
1015
- return { input, room, path, ...configuration_snapshot(path) };
1040
+ return { input, room, discussion, path, ...configuration_snapshot(path) };
1016
1041
  }
1017
1042
 
1018
1043
  /** Expose only editable connection paths, never credentials or unrelated room settings. */
1019
1044
  function connection_view(context) {
1020
- return { room_id: context.room.id, runtime_revision: context.room.runtime.revision, version: context.version,
1045
+ return { room_id: context.room.id, session_revision: context.discussion.revision, runtime_revision: context.discussion.revision, version: context.version,
1021
1046
  participants: Object.fromEntries(Object.entries(context.config.participants).map(([name, profile]) =>
1022
1047
  [name, Object.fromEntries(['adapter', ...CONNECTION_FIELDS].filter(field => profile[field] !== undefined).map(field => [field, profile[field]]))])) };
1023
1048
  }
@@ -1067,7 +1092,7 @@ async function configuration_applied(home, path, version) {
1067
1092
  const status_path = join(home, 'status.json');
1068
1093
  const status = existsSync(status_path) ? JSON.parse(readFileSync(status_path, 'utf8')) : {};
1069
1094
  const worker = status.rooms?.find(item => resolve(item.config) === resolve(path));
1070
- if (status.pid === pid && worker?.config_version === version && worker.status === 'paused') return true;
1095
+ if (status.pid === pid && worker?.config_version === version && worker.status !== 'error') return true;
1071
1096
  await sleep(CONFIG_APPLY_POLL_MS);
1072
1097
  }
1073
1098
  return false;
@@ -1075,18 +1100,22 @@ async function configuration_applied(home, path, version) {
1075
1100
 
1076
1101
  /** Read or save a paused room's connection paths without changing its runtime or global defaults. */
1077
1102
  export async function room_configuration(home, raw, options = {}) {
1078
- if (raw.participants !== undefined && !options.local_guard) return save_room_connection(raw);
1079
- let context = await room_config_context(home, raw);
1103
+ let context = await room_config_context(home, raw, options);
1104
+ if (raw.participants !== undefined && !options.local_guard) {
1105
+ const saved = await save_room_connection(raw);
1106
+ return { ...saved, applied: await configuration_applied(home, context.path, saved.version) };
1107
+ }
1080
1108
  if (raw.participants === undefined) return connection_view(context);
1081
1109
  if (!raw.participants || typeof raw.participants !== 'object' || Array.isArray(raw.participants)) throw new Error('participants 须为本场软件路径对象');
1082
1110
  const release = acquire_lock(join(dirname(context.path), 'configuration-edit'));
1083
1111
  try {
1084
- context = await room_config_context(home, raw);
1112
+ context = await room_config_context(home, raw, options);
1085
1113
  const config = corrected_configuration(context);
1086
- if (raw.version !== context.version || raw.runtime_revision !== context.room.runtime.revision) throw new Error('房间状态或配置已变化,请重新读取本场配置后核对');
1114
+ if (raw.version !== context.version || (raw.session_revision ?? raw.runtime_revision) !== context.discussion.revision) throw new Error('房间状态或配置已变化,请重新读取本场配置后核对');
1087
1115
  atomic_json(context.path, config);
1088
1116
  const saved = { ...context, ...configuration_snapshot(context.path) };
1089
- return { ...connection_view(saved), applied: await configuration_applied(home, context.path, saved.version) };
1117
+ // The local website holds its database write lock here; the worker can acknowledge only after that lock is released.
1118
+ return { ...connection_view(saved), applied: false };
1090
1119
  } finally { release(); }
1091
1120
  }
1092
1121
 
@@ -1105,7 +1134,7 @@ async function save_room_connection(raw) {
1105
1134
 
1106
1135
  /** Prove dispatcher access before a protected room is started or a corrected credential is saved. */
1107
1136
  async function verify_control(config, room) {
1108
- if (room.runtime?.protected) await api({ ...config, room: room.id }, '/events?after=0');
1137
+ await api({ ...config, room: room.id }, '/inbox');
1109
1138
  }
1110
1139
 
1111
1140
  /** Pin resolved defaults, while comparing retries against only the caller's explicit request. */
@@ -1131,7 +1160,7 @@ async function prepare_launch(home, input, directory, options = {}) {
1131
1160
  const minutes = previous?.minutes ?? legacy?.minutes ?? launch_minutes(input, room);
1132
1161
  const draft = signature({ entry: input.entry, room_id: input.room_id, room: input.room, participants: config.participants, cwd: input.cwd, discussion_project: input.discussion_project, minutes });
1133
1162
  if (legacy && previous.signature !== draft) throw new Error('启动配置与原请求不同;同一次重试须沿用原配置,新讨论请使用新提交编号');
1134
- await verify_control(config, room);
1163
+ if (room.id) await verify_control(config, room);
1135
1164
  return { input, config, room, minutes, draft, request_signature, directory, previous };
1136
1165
  }
1137
1166
 
@@ -1158,26 +1187,26 @@ export async function launch_discussion(home, raw, options = {}) {
1158
1187
  /** Persist preparation before writes, hand off the current host when needed, then register once. */
1159
1188
  async function perform_launch(home, context, options) {
1160
1189
  const { input, config, minutes, draft, request_signature, directory, previous } = context;
1161
- const record = previous || { token: config.token, signature: draft, request_signature, config, minutes, entry: input.entry };
1190
+ const discussion = previous?.discussion ?? (input.room ? input.room.mode !== 'free' : Boolean(context.room.session && context.room.session.status !== 'concluded'));
1191
+ const record = previous || { token: config.token, signature: draft, request_signature, config, minutes, entry: input.entry, discussion };
1192
+ record.discussion = discussion;
1162
1193
  const persist = () => atomic_json(join(directory, 'launch.json'), record);
1163
1194
  if (!previous) persist();
1164
1195
  const progress = { stage: 'unconfirmed' };
1165
1196
  try {
1166
1197
  let room = context.room;
1167
- const free = config.mode === 'free';
1168
1198
  if (!input.room_id) room = await site_request(input.site, '/api/rooms', config.token, {
1169
- ...input.room, ...(free ? {} : { runtime_mode: 'automatic' }),
1199
+ ...input.room,
1170
1200
  members: [...Object.keys(config.participants).map(name => ({ name, adapter: config.participants[name].adapter,
1171
1201
  token: config.members[name].token, access: 'runner', session_mode: config.participants[name].session_id ? 'borrowed' : 'new' })),
1172
1202
  // Manual and online members keep the credentials the browser generated; nothing local is configured for them.
1173
- ...(input.room.members || []).filter(member => free ? !woken_member(member) : member?.access === 'manual')
1203
+ ...(input.room.members || []).filter(member => record.discussion ? member?.access === 'manual' : !woken_member(member))
1174
1204
  .map(({ name, token, access }) => ({ name, token, access, adapter: '', session_mode: 'new' }))],
1175
1205
  });
1176
1206
  config.room = room.id;
1177
1207
  await verify_control(config, room);
1178
1208
  Object.assign(progress, { stage: 'created', room_id: room.id });
1179
1209
  Object.assign(record, { token: config.token, request_signature, config, minutes, room_id: room.id });
1180
- if (!record.start_revision && room.runtime.status === 'ready') record.start_revision = room.runtime.revision + 1;
1181
1210
  persist();
1182
1211
  const config_path = join(directory, 'config.json');
1183
1212
  check_registration(home, config, config_path);
@@ -1189,10 +1218,9 @@ async function perform_launch(home, context, options) {
1189
1218
  atomic_json(config_path, config);
1190
1219
  const service = await (options.start_service || start_service)(home);
1191
1220
  if (!service?.running) throw new Error('讨论服务未就绪,未开始本次讨论');
1192
- // Free rooms have no discussion run: registering the room is what lets the service deliver requests.
1193
- if (!free) await enable_run(config, record, persist, minutes);
1221
+ if (record.discussion) await start_session(config, record, persist, room, minutes);
1194
1222
  progress.stage = 'started';
1195
- if (input.entry === 'conversation') record.current_task = await current_host_task(config, record, persist, room);
1223
+ if (record.discussion && input.entry === 'conversation') record.current_task = await current_host_task(config, record, persist, room);
1196
1224
  register_room(home, config_path);
1197
1225
  record.finished = true;
1198
1226
  persist();