ai_co_discuss 0.2.36 → 0.2.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/workflow.md CHANGED
@@ -8,12 +8,14 @@
8
8
  - **自由协作**:你或 AI 主持人点名一位或多位成员,各自在原会话处理请求;没有讨论发言权、安排和轮次。每位成员单独选择本机唤醒、手动接入或网页代发,见下方 [自由协作房间](#自由协作房间)。
9
9
  - **手动接入**:自由协作成员的一种接入方式。本地成员持自己的凭据文件自行读写,可由人工或软件原生定时触发;网页成员只能阅读房间,回答需转交代发;网页 AI 从其服务器读取阅读链接,本机网站对它不可达,此时由用户粘贴材料。只有这两种成员时建房无需本机接入服务。复制参与指令、下载凭据文件或复制凭证文本都不代表已经送达、接入或唤醒。
10
10
 
11
- 讨论运行中可在进度看板邀请专家(经本机服务配置后加入;Codex CLI / App、Claude 可填写已有会话 ID,续接这个带有自己上下文的原会话,标注为借用会话),或从成员菜单让专家暂离、请回或移除。暂离会取消它当前与排队中的安排,保留位置与会话,不计入之后的轮次;请回换发新凭证、续接原会话。邀请保留已有安排,新专家追加到队尾;暂离、请回或移除不暂停讨论,但排队中的安排作废,由主持人重新安排;主持人本身不能暂离或移除,更换主持人仍会暂停;正在发言(有进行中安排)的专家须先暂停讨论才能暂离或移除。暂停后可对本轮已发言的专家选择“作废本轮发言”:彻底删除其最近一条观点,该专家重新计为本轮未发言(不新增轮次),恢复后由主持人重新安排。故障只暂停并保留原因,不静默换软件、身份或创建第二个会话。
11
+ 讨论运行中可在进度看板邀请专家(经本机服务配置后加入;Codex CLI / App、Claude 可填写已有会话 ID,续接这个带有自己上下文的原会话,标注为借用会话),或从成员菜单让专家暂离、请回或移除。暂离会取消它当前与排队中的安排,保留位置与会话,不计入之后的轮次;请回换发新凭证、续接原会话。邀请保留已有安排,新专家排在本轮的补齐位置;暂离、请回或移除不暂停讨论,但排队中的安排作废,由主持人重新安排;主持人本身不能暂离或移除,更换主持人仍会暂停;正在发言(有进行中安排)的专家须先暂停讨论才能暂离或移除。暂停后可对本轮已发言的专家选择“作废本轮发言”:彻底删除其最近一条观点,该专家重新计为本轮未发言(不新增轮次),恢复后由主持人重新安排。故障只暂停并保留原因,不静默换软件、身份或创建第二个会话。
12
12
 
13
- 邀请弹窗在卡片上方选择自动或手动接入,手动卡片按内容收缩。已有本轮发言安排时,新邀请的自动和手动专家都追加到队列末尾,保留当前发言、原有问题和顺序;重复邀请请求不重复排队。暂停或尚无安排时,由主持人在继续推进时将新专家安排在本轮尚未发言的原专家之后;进入收束后不再追加安排。邀请不会启动或恢复讨论,也不会清除待处理的用户留言。
13
+ 邀请弹窗在卡片上方选择自动或手动接入,手动卡片按内容收缩。已有本轮发言安排时,新邀请的自动和手动专家都加入队列的补齐位置:排在本轮未发言的专家之后、会再次发言的专家之前,没有重复时在队尾;保留当前发言和原有相对顺序、问题;重复邀请请求不重复排队。暂停或尚无安排时,由主持人在继续推进时将新专家安排在本轮尚未发言的原专家之后;进入收束后不再追加安排。邀请不会启动或恢复讨论,也不会清除待处理的用户留言。
14
14
 
15
15
  邀请手动专家后,弹窗提供“复制启动指令”;复制成功后自动关闭,复制失败则保留弹窗并显示错误,方便重试。关闭后仍可在参与者列表中再次复制,不另设“稍后再复制”按钮。复制只交付指令,不改变发言顺序。轮到手动专家时,输入框上方也提供该按钮,复制成功后显示勾号与“已复制”,2 秒后恢复。
16
16
 
17
+ 手动专家的“注册”:专家须在自己的会话里执行 `member register`,网站才把它记为已注册;会话 ID 由 CLI 自动采集,不由专家填写。进度看板中该专家显示“待注册”(警示色,并提示把启动指令交给它的会话),注册后显示“已注册”,轮到与发言后沿用排队、发言中、本轮已发言等状态。存在待注册的手动成员时,输入框上方持续提示并提供复制启动指令,直到它注册;换发新凭证(请回)后需重新注册。只有已注册且上报了 Claude Code / Codex 会话的专家才会被本机服务接管。注册不改变发言顺序。
18
+
17
19
  ## 自由协作房间
18
20
 
19
21
  成员回答下的执行报告列出请求编号、耗时、终态与工作区观察文件;失败或取消的报告保留在原请求下。报告展示最近 100 次执行;“未提供自动改动检测”表示非 Git 目录或未上报,不能据此判断没有文件变化。
@@ -43,7 +45,7 @@
43
45
  新建讨论时可选“点名追问”,默认关闭;之前创建的房间视为开启,保持原有方式。
44
46
 
45
47
  - **开启**:每轮结束后主持人读完回答,给每位专家写针对性的追问。
46
- - **关闭**:首轮仍由主持人拆题出题;之后专家统一按“先读上一轮回答、回应不同意或需补充的观点、可 @ 彼此提问”发言,主持人用自己的主持说明引导方向。同时开启“智能调度”时,每轮结束由决策模型判断:还有分歧就自动开下一轮(先请最需要回应的专家,不是上一轮最后发言者),可以收束、跑偏或卡住才唤醒主持人。自动开轮受轮次与时长上限约束,到限照常交给主持人处理。
48
+ - **关闭**:首轮仍由主持人拆题出题;之后专家统一按“先读上一轮回答、回应不同意或需补充的观点、可 @ 彼此提问”发言,主持人用自己的主持说明引导方向。同时开启“智能调度”时,每轮结束由决策模型判断:还有分歧就自动开下一轮(先请最需要回应的专家,不是上一轮最后发言者),可以收束、跑偏或卡住才唤醒主持人。决策模型每次只安排一位发言人,那位答完后再判断下一位(含点“跳过”、邀请或成员变动后队列为空的情况);手动接入的专家不由它安排。自动开轮受轮次与时长上限约束,到限照常交给主持人处理。
47
49
 
48
50
  ## 讨论上限
49
51
 
@@ -110,7 +112,7 @@ stateDiagram-v2
110
112
 
111
113
  主持人可以一次排好本轮顺序(`turn create --plan-file`):第一项立即生效,其余为 `queued`。专家保存回答后,网站在同一事务中把发言权交给下一位排队专家;末位答完才交回主持人。接力不发通知,需要逐个转交的在线专家不放进整轮。
112
114
 
113
- 用户留言或修改目标、背景、边界、焦点会记为待主持人处理(`held_since`),不打断正在发言的专家;该专家保存回答后交回主持人而不接力。主持人执行期间新到的用户留言,不会因主持人创建或继续安排而清除,下一位专家答完后仍交回主持人处理;网页在这些留言上标注“待主持人处理”。要立即生效,用户在进度看板点「跳过」:当前安排取消、本次执行作废并交回主持人,排队安排保留。主持人处理后用 `turn continue` 按原计划继续,或直接创建新安排,剩余排队改为 `skipped`。建房时开启“智能调度”的讨论,留言由决策模型先判断:有把握是“仅补充信息”就按原计划继续,是在问某位专家就先请该专家回应,其余情况才交回主持人;每次判断都在对话中留一行“智能调度”记录。暂停保留当前与排队安排,点“重启”由原专家继续;若要跳过当前安排,可点“跳过”,取消该安排后恢复讨论并交回主持人,后续队列保留;邀请只在队尾追加,提前结束、到限处理、收束、更换主持人或专家暂离、请回、移除才会作废全部排队安排。
115
+ 用户留言或修改目标、背景、边界、焦点会记为待主持人处理(`held_since`),不打断正在发言的专家;该专家保存回答后交回主持人而不接力。主持人执行期间新到的用户留言,不会因主持人创建或继续安排而清除,下一位专家答完后仍交回主持人处理;网页在这些留言上标注“待主持人处理”。要立即生效,用户在进度看板点「跳过」:当前安排取消、本次执行作废并交回主持人,排队安排保留。主持人处理后用 `turn continue` 按原计划继续,或直接创建新安排,剩余排队改为 `skipped`。建房时开启“智能调度”的讨论,留言由决策模型先判断:有把握是“仅补充信息”就按原计划继续,是在问某位专家就先请该专家回应,其余情况才交回主持人;每次判断都在对话中留一行“智能调度”记录。暂停保留当前与排队安排,点“重启”由原专家继续;若要跳过当前安排,可点“跳过”,取消该安排后恢复讨论并交回主持人,后续队列保留;邀请只插入补齐位置,提前结束、到限处理、收束、更换主持人或专家暂离、请回、移除才会作废全部排队安排。
114
116
 
115
117
  本地专家自行领取与归还;在线专家由主持人以自身操作者身份、指定原专家代操作。主持人不能代领另一位本地专家的发言权。主动归还后未完成安排仍存在,主持人需取消或处理。正常推进不超时夺取;配置的到限处理会取消未完成安排并撤销旧自动执行,再交回主持人。
116
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -11,6 +11,7 @@ const MAX_MODEL_TURNS = 24;
11
11
  // API participants follow the same skills that local software loads, read fresh for every execution.
12
12
  const SKILLS = fileURLToPath(new URL('../.agents/skills/', import.meta.url));
13
13
  const SITE_TIMEOUT_MS = 10_000;
14
+ const REPLY_EXCERPT_CHARS = 300;
14
15
  const MODEL_RETRIES = 2;
15
16
  const MODEL_RETRY_DELAY_MS = 3000;
16
17
  const NO_TOOL_REMINDER = '普通文本不会被保存。请调用写入工具提交真实结果;确实无法继续才不调用工具直接结束。';
@@ -154,6 +155,13 @@ export function system_prompt(context) {
154
155
  return [environment, skill_text('discuss-participant'), ...(host && context.mode !== 'free' ? [skill_text('discuss-host')] : [])].join('\n\n---\n\n');
155
156
  }
156
157
 
158
+ /** Plain text of the model's latest reply, so a stop without a write can show its stated reason. */
159
+ function last_reply_text(history) {
160
+ const item = history.at(-1) || {};
161
+ const parts = item.parts || (Array.isArray(item.content) ? item.content : [{ text: item.content }]);
162
+ return parts.map(part => (typeof part === 'string' ? part : part.text || '')).join('').trim().slice(0, REPLY_EXCERPT_CHARS);
163
+ }
164
+
157
165
  /** Retry a model request that failed before any room write; history is only extended on success. */
158
166
  async function generate_with_retry(profile, key, state, signal) {
159
167
  for (let attempt = 0; ; attempt++) {
@@ -174,15 +182,21 @@ async function run_participant(profile, key, context) {
174
182
  ...(context.scheduler_suggestions?.length ? { scheduler_suggestions: context.scheduler_suggestions } : {}) } });
175
183
  const state = { system: system_prompt(context), history: api_history(profile, prompt), tools: definitions };
176
184
  let reminded = false;
185
+ let used_tools = false;
177
186
  for (let index = 0; index < MAX_MODEL_TURNS; index++) {
178
187
  const calls = await generate_with_retry(profile, key, state, context.signal);
179
188
  if (!calls.length) {
180
189
  // Some models answer in plain text mid-run; one reminder avoids pausing on a recoverable slip.
181
- if (reminded) throw new Error('模型未调用房间工具保存结果,请核对模型是否支持工具调用');
190
+ if (reminded) {
191
+ const reply = last_reply_text(state.history);
192
+ throw new Error(used_tools ? `模型未提交结果就结束了本次执行,可能在等你决定或补充${reply ? `。模型说明:${reply}` : ''}`
193
+ : `模型未调用房间工具保存结果,请核对模型是否支持工具调用${reply ? `(其回复:${reply})` : ''}`);
194
+ }
182
195
  reminded = true;
183
196
  state.history.push(profile.api_protocol === 'gemini' ? { role: 'user', parts: [{ text: NO_TOOL_REMINDER }] } : { role: 'user', content: NO_TOOL_REMINDER });
184
197
  continue;
185
198
  }
199
+ used_tools = true;
186
200
  const results = [];
187
201
  for (const call of calls) {
188
202
  context.signal.throwIfAborted();
package/runner/discuss.py CHANGED
@@ -314,6 +314,11 @@ def execution_commands(subcommands, registry):
314
314
  parser.add_argument("--reason", required=True)
315
315
 
316
316
 
317
+ def member_commands(subcommands, registry):
318
+ """Let a manual member announce itself; the CLI attaches the hosting session on its own."""
319
+ add_leaf(subcommands, registry, "member register", "手动接入成员用自己的凭据向房间注册;会话 ID 由本程序自动附带,无需填写", True)
320
+
321
+
317
322
  def build_parser(prog="discuss"):
318
323
  """Build help and schema from the same command definitions."""
319
324
  parser = Parser(prog=prog, description="AI CoDiscuss CLI:通过 HTTP 操作现有讨论网站。",
@@ -325,7 +330,7 @@ def build_parser(prog="discuss"):
325
330
  for name, register in (("room", room_commands), ("message", message_commands),
326
331
  ("attachment", attachment_commands),
327
332
  ("turn", turn_commands), ("state", state_commands), ("floor", floor_commands),
328
- ("run", run_commands), ("execution", execution_commands)):
333
+ ("run", run_commands), ("execution", execution_commands), ("member", member_commands)):
329
334
  group = subcommands.add_parser(name, help=f"{name} 操作", allow_abbrev=False)
330
335
  add_common(group)
331
336
  register(group.add_subparsers(dest="action", required=True), registry)
@@ -621,6 +626,13 @@ def plan_execution(args):
621
626
  return RequestPlan(f"/api/rooms/{args.room}/events/{args.id}", "POST", body)
622
627
 
623
628
 
629
+ def plan_member(args):
630
+ """Register with the credential file; the token itself decides which member this is."""
631
+ if not load_access(args):
632
+ raise CliError("注册须使用成员自己的凭据文件(--access-file 或 DISCUSS_ACCESS_FILE)")
633
+ return RequestPlan(f"/api/rooms/{args.room}/register", "POST", {})
634
+
635
+
624
636
  def build_plan(args):
625
637
  """Validate local input before constructing any network request."""
626
638
  stdin_count = sum(value == "-" for key, value in vars(args).items()
@@ -630,7 +642,7 @@ def build_plan(args):
630
642
  handlers = {"room": plan_room, "message": plan_message, "turn": plan_turn,
631
643
  "attachment": plan_attachment,
632
644
  "state": plan_state, "floor": plan_floor, "api": plan_api,
633
- "run": plan_run, "execution": plan_execution}
645
+ "run": plan_run, "execution": plan_execution, "member": plan_member}
634
646
  plan = RequestPlan("/api/health") if args.resource == "health" else handlers[args.resource](args)
635
647
  if getattr(args, "dry_run", False) and plan.method != "POST" and plan.download_file is None:
636
648
  raise CliError("--dry-run 仅用于写入命令;读取命令本身不会修改数据")
@@ -9,7 +9,7 @@ import { parseArgs } from 'node:util';
9
9
  import { setTimeout as sleep } from 'node:timers/promises';
10
10
  import { atomic_json, deliver_task, remove_agy_projects, setup_sidecar, sidecar_receipt, TASK_SUBCOMMANDS } from './discussion_adapters.mjs';
11
11
  import { read_api_key } from './discussion_api.mjs';
12
- import { decide_interjection, decide_round, validate_scheduler } from './scheduler.mjs';
12
+ import { decide_interjection, decide_next_speaker, decide_round, validate_scheduler } from './scheduler.mjs';
13
13
 
14
14
  const POLL_MS = 2000;
15
15
  /** Headless CLIs know their session at start, so the runner enters the execution instead of spending model turns on it. */
@@ -41,6 +41,11 @@ export function peer_round_question(round) {
41
41
  return `第 ${round} 轮:先读取上一轮其他专家的最新回答,回应你不同意或需要补充的观点;被其他专家 @ 提问时优先回答,也可以 @ 某位专家提出问题。`;
42
42
  }
43
43
 
44
+ /** The prompt for an expert speaking for the first time, such as a newly invited one. */
45
+ function opening_question(phase) {
46
+ return phase === 'initial' ? '欢迎加入:请先读取议题,独立给出你的开场观点。' : '欢迎加入:请先读取议题和已有回答,给出你的观点。';
47
+ }
48
+
44
49
  /** Ask one expert to answer a user's interjection before the rest of the plan continues. */
45
50
  function interjection_question(message) {
46
51
  const text = String(message.text || '').replace(/\s+/g, ' ').trim();
@@ -356,6 +361,8 @@ export class DiscussionRunner {
356
361
  if (room.limits?.reached) return skip('round', '已到讨论上限');
357
362
  const page = await api(this.config, `/messages?after=${Math.max(0, room.latest_id - CONTEXT_MESSAGES)}`);
358
363
  const experts = Object.keys(room.experts || {});
364
+ // Only experts the runner can wake are offered to the decision model; manual ones wait for the host.
365
+ const automatic = experts.filter(name => this.config.participants[name]);
359
366
  const context = { title: room.title, goal: room.goal, user_request: room.user_request, context: page.messages, host: room.host };
360
367
  if (room.held_since) {
361
368
  const pending = page.messages.filter(item => item.id >= room.held_since && item.author === '用户');
@@ -363,7 +370,7 @@ export class DiscussionRunner {
363
370
  if (pending.length !== 1) return skip('interjection', pending.length ? '同时有多条留言' : '话题设置有修改');
364
371
  const message = pending[0];
365
372
  const decision = await decide_interjection(this.config.api_home, this.config.scheduler,
366
- { ...context, message, experts: experts.filter(name => name !== room.host) }, this.fetch);
373
+ { ...context, message, experts: automatic.filter(name => name !== room.host) }, this.fetch);
367
374
  const plan = { ...decision, kind: 'interjection', message_id: message.id, after_message_id: anchor };
368
375
  if (decision.action === 'ask') {
369
376
  return { ...plan, turns: [{ expert: decision.expert, question: interjection_question(message) },
@@ -377,17 +384,33 @@ export class DiscussionRunner {
377
384
  const round_open = !room.rounds?.at(-1)?.completed;
378
385
  if (round_open) {
379
386
  const restored = await this.restore_voided_plan(room, experts, anchor);
380
- return restored || skip('round', '本轮还有专家未发言但没有后续安排');
387
+ if (restored) return restored;
388
+ const spoken = new Set(room.rounds?.at(-1)?.speakers || []);
389
+ // Experts without local software cannot be woken by the runner, so only automatic ones are candidates.
390
+ const waiting = automatic.filter(name => !spoken.has(name));
391
+ if (!waiting.length) return skip('round', '本轮未发言的专家都是手动接入,无法自动安排');
392
+ // An expert the user just skipped is not picked again unless nobody else is left.
393
+ const skipped = room.current_turn?.status === 'cancelled' ? room.current_turn.expert : null;
394
+ const candidates = waiting.filter(name => name !== skipped);
395
+ return this.next_speaker_plan(room, context, candidates.length ? candidates : waiting, anchor);
381
396
  }
382
397
  if (room.named_followup) return skip('round', '点名追问已开启,由主持人安排下一轮');
383
398
  const decision = await decide_round(this.config.api_home, this.config.scheduler,
384
- { ...context, experts, last_speaker: room.current_turn?.expert }, this.fetch);
399
+ { ...context, experts: automatic, last_speaker: room.current_turn?.expert }, this.fetch);
385
400
  const plan = { ...decision, kind: 'round', after_message_id: anchor };
386
401
  if (decision.action !== 'continue') return plan;
387
- const round = room.completed_rounds + 1;
388
- const order = [decision.first, ...experts.filter(name => name !== decision.first)].slice(0, MAX_PLAN_TURNS);
402
+ // Only the first speaker is arranged; each answer ends with an empty queue, so the next one is judged then.
389
403
  return { ...plan, phase: room.phase === 'initial' ? 'discussing' : undefined,
390
- turns: order.map(expert => ({ expert, question: peer_round_question(round) })) };
404
+ turns: [{ expert: decision.first, question: peer_round_question(room.completed_rounds + 1) }] };
405
+ }
406
+ /** Ask the decision model for the next speaker among candidates; an expert who never spoke gets the opening prompt. */
407
+ async next_speaker_plan(room, context, candidates, anchor) {
408
+ const next = await decide_next_speaker(this.config.api_home, this.config.scheduler, { ...context, candidates }, this.fetch);
409
+ const plan = { ...next, kind: 'round', after_message_id: anchor };
410
+ if (next.action !== 'next') return plan;
411
+ const has_spoken = (room.rounds || []).some(round => round.speakers.includes(next.expert));
412
+ const question = has_spoken ? peer_round_question(room.completed_rounds + 1) : opening_question(room.phase);
413
+ return { ...plan, turns: [{ expert: next.expert, question }] };
391
414
  }
392
415
  /**
393
416
  * A roster change voids queued turns, leaving them skipped after the last real arrangement. Put back the ones whose
@@ -402,7 +425,7 @@ export class DiscussionRunner {
402
425
  const spoken = new Set(room.rounds?.at(-1)?.speakers || []);
403
426
  const planned = new Set(voided.map(turn => turn.expert));
404
427
  const joining = experts.filter(name => !spoken.has(name) && !planned.has(name));
405
- const opening = room.phase === 'initial' ? '欢迎加入:请先读取议题,独立给出你的开场观点。' : '欢迎加入:请先读取议题和已有回答,给出你的观点。';
428
+ const opening = opening_question(room.phase);
406
429
  const plan_turns = [...voided.map(({ expert, question }) => ({ expert, question })), ...joining.map(expert => ({ expert, question: opening }))].slice(0, MAX_PLAN_TURNS);
407
430
  if (!plan_turns.length) return null;
408
431
  const label = `成员有变化:${voided.length ? `补回原计划(${voided.map(turn => turn.expert).join('、')})` : '原计划成员已离开'}${joining.length ? `,请 ${joining.join('、')} 开场` : ''}`;
@@ -220,12 +220,12 @@ class RoomWorker {
220
220
  }
221
221
  this.state.config_version = snapshot.version;
222
222
  }
223
- /** A manual Claude or Codex expert whose CLI reported its session is handed to the service, which resumes that session from the next turn on. */
223
+ /** A manual Claude or Codex expert that has registered and whose CLI reported its session is handed to the service, which resumes that session from the next turn on. */
224
224
  async adopt_manual_members() {
225
225
  if (this.config.mode === 'free') return;
226
226
  for (const member of this.runner.members || []) {
227
227
  const key = `${member.name}:${member.reported_session}`;
228
- if (member.access !== 'manual' || member.status !== 'active' || !member.reported_session || this.adopt_failed.has(key)) continue;
228
+ if (member.access !== 'manual' || member.status !== 'active' || !member.registered_at || !member.reported_session || this.adopt_failed.has(key)) continue;
229
229
  try {
230
230
  const { adopt_member_profile } = await import('./discussion_launch.mjs');
231
231
  const adapter = adopt_member_profile(this.home, this.path, member.name, member.reported_session, member.reported_client);
@@ -126,6 +126,25 @@ export async function decide_interjection(home, scheduler, { title, goal, user_r
126
126
  return { action: 'host', confidence, label: choice === HOST_CHOICE && sure ? '这条留言需要主持人处理' : '拿不准这条留言如何处理,交给主持人' };
127
127
  }
128
128
 
129
+ /**
130
+ * Mid-round with no queued turn left: pick the next speaker among the experts who can be woken and have not spoken
131
+ * this round, or hand back to the host when unsure or when the discussion needs steering.
132
+ */
133
+ export async function decide_next_speaker(home, scheduler, { title, goal, user_request, context, host, candidates }, fetch_impl) {
134
+ const recent = context.slice(-CONTEXT_MESSAGES).map(excerpt);
135
+ const state = [topic_lines(title, goal, user_request), recent.length ? `本轮及最近发言(旧→新):\n${recent.join('\n')}` : '还没有发言。'].join('\n\n');
136
+ const choices = [...candidates.map(name => ({ value: name, description: `请 ${name} 接着发言` })),
137
+ { value: HOST_CHOICE, description: `交给主持人 ${host}:讨论偏离目标、卡住,或需要主持人调整安排` }];
138
+ const answers = await decide(home, scheduler, state, [{ type: 'choice', name: 'speaker',
139
+ instructions: '本轮还有专家没发言,安排被取消或用完。结合已有发言判断下一位应请谁发言:优先选被点名追问、最能回应当前焦点的人。', choices }], fetch_impl);
140
+ const choice = answers.speaker?.choice;
141
+ const confidence = certainty(answers.speaker);
142
+ if (candidates.includes(choice) && confidence !== null && confidence >= ROUTE_CONFIDENCE) {
143
+ return { action: 'next', expert: choice, confidence, label: `本轮继续,请 ${choice} 接着发言` };
144
+ }
145
+ return { action: 'host', confidence, label: '拿不准下一位该请谁发言,交给主持人' };
146
+ }
147
+
129
148
  /**
130
149
  * At the end of a round without named follow-ups: continue with another peer round, or wake the host
131
150
  * (to conclude, or because the discussion drifted, repeats itself or is stuck). The first speaker is never the last one.
package/web/app.js CHANGED
@@ -2236,8 +2236,8 @@ async function copy_member_join(name, with_credential = false) {
2236
2236
  let instruction;
2237
2237
  if (member.access === "online") instruction = "你是在线只读成员,请在原聊天回答,由用户或授权主持人代发;不要尝试直接写入房间。模型与思考强度在原网页设置。";
2238
2238
  else if (member.access === "runner") instruction = `${skills}等待本机程序交付有效任务,按 task 中的 access_file 和 execution 凭据操作${room.mode === "free" ? ";自由协作的回答必须绑定本次有效 execution_id" : ""}。不要另建定时任务;只处理本次有效执行,失效或撤销后停止提交。下载的持久成员私有文件不能替代自动执行凭据。`;
2239
- else if (with_credential) instruction = `${skills}凭证文本在下方:原样设为环境变量 DISCUSS_ACCESS(不要回显,不要写进命令行参数),命令省略 --access-file;先执行 codiscuss room view ${room.id} --site ${location.origin} --as ${name},后续命令保持本站点、房间和身份。模型与思考强度在原软件中设置。${manual_trigger_instruction(room)}${workspace_instruction()}`;
2240
- else instruction = `${skills}使用属于你的私有文件 member-${room.id}-${name}.json,由用户提供它在本机的实际完整路径;先执行 codiscuss room view ${room.id} --site ${location.origin} --as ${name} --access-file "实际完整路径",后续命令保持本站点、房间和身份。不要读取或公开文件中的 token;若用户给的是凭证文本而非文件,把它设为环境变量 DISCUSS_ACCESS(不要回显)并省略 --access-file。模型与思考强度在原软件中设置。${manual_trigger_instruction(room)}${workspace_instruction()}`;
2239
+ else if (with_credential) instruction = `${skills}凭证文本在下方:每条 codiscuss 命令都在同一命令内把它原样设为环境变量 DISCUSS_ACCESS(不回显;首条 room view 也要带,否则无法识别你),命令省略 --access-file;先执行 codiscuss room view ${room.id} --site ${location.origin} --as ${name},随后立即执行 codiscuss member register ${room.id} --site ${location.origin} --as ${name} 完成注册(只需一次,会话 ID 由程序自动附带,不要自己填写),之后命令保持本站点、房间和身份。模型与思考强度在原软件中设置。${manual_trigger_instruction(room)}${workspace_instruction()}`;
2240
+ else instruction = `${skills}使用属于你的私有文件 member-${room.id}-${name}.json,由用户提供它在本机的实际完整路径;先执行 codiscuss room view ${room.id} --site ${location.origin} --as ${name} --access-file "实际完整路径";随后立即执行 codiscuss member register ${room.id} --site ${location.origin} --as ${name} --access-file "实际完整路径" 完成注册(只需一次,会话 ID 由程序自动附带,不要自己填写),之后命令保持本站点、房间和身份。不要读取或公开文件中的 token;若用户给的是凭证文本而非文件,把它设为环境变量 DISCUSS_ACCESS(不要回显)并省略 --access-file。模型与思考强度在原软件中设置。${manual_trigger_instruction(room)}${workspace_instruction()}`;
2241
2241
  const credential = with_credential ? `
2242
2242
  凭证文本(含 token,仅限你使用):${JSON.stringify({ site: location.origin, room: room.id, token: member_credentials(room.id)[name].token })}` : "";
2243
2243
  await copy_text(`请以 ${name} 身份参与房间。