ai_co_discuss 0.4.93 → 0.4.95

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.
@@ -39,7 +39,7 @@
39
39
 
40
40
  ## 主动发言
41
41
 
42
- 需要主动说明或派活时(定时检查发现问题、用户在你自己的窗口里要你发言、你自己失效的执行要补交),用参与技能 [按需场景](../../discuss-participant/references/situations.md)“主动发言”一节的 `--proactive`,可同时 `--to` 派活或 `--continue`。
42
+ 需要主动说明或派活时(定时检查发现问题、用户在你自己的窗口里要你发言、你自己失效的执行要补交),用参与技能 [按需场景](../../discuss-participant/references/situations.md)“主动发言”一节的 `--proactive`,可同时 `--to` 派活或 `--continue`。还有待处理的请求时默认被拒:通常等本机服务把请求交给你再一并回答;请求迟迟没有交来时,发言就是某条普通请求的回答就加 `--also-request 请求编号` 关闭它,与它们无关又必须现在说就加 `--force`。
43
43
 
44
44
  ## 你自己失败时
45
45
 
@@ -19,7 +19,7 @@
19
19
  |---|---|---|---|
20
20
  | Claude(Claude Code) | `claude-fable-5-2`、`claude-opus-5-5`、`claude-sonnet-5-5`、`claude-haiku-5-5` | Opus 主刀长任务、前端设计与审美;Fable 审计、诊断、卡住的难题;Sonnet 常规代码初审 | Fable 额度消耗约为 Opus 的 3–4 倍 |
21
21
  | GPT(Codex) | `gpt-6.2-astra`、`gpt-6.2-sol`、`gpt-6.1-terra`、`gpt-6-luna` | 推理、审查挑错、复杂排障;Astra 做前端版式与 3D;小修用 Sol | 易思考过度,强度从中档起步;中文常带防御腔,面向用户的中文让别家润色 |
22
- | Gemini(Antigravity) | `gemini-4-carbon`、`gemini-4-neon`、`gemini-4-argon`、`gemini-4-hydrogen` | 写小说、长篇中文用 Argon 或 Carbon;其他日常活用 Neon;Hydrogen 便宜跑量;幻觉低、超长文本强 | 执行慢,显示掉登录或额度耗尽多半是假的,多重试;输出排版差;`/swarm` 很费额度 |
22
+ | Gemini(Antigravity) | `gemini-4-carbon`、`gemini-4-neon`、`gemini-4-argon`、`gemini-4-hydrogen` | 写小说、长篇中文用 Argon 或 Carbon,Hydrogen 可作便宜备选;Neon 快、前端和长任务强,是写作以外的日常首选,但写作偏平;Hydrogen 便宜跑量;幻觉低、超长文本强 | 执行慢,显示掉登录或额度耗尽多半是假的,多重试;输出排版差;`/swarm` 很费额度 |
23
23
  | DeepSeek | `deepseek-flash` | 便宜快速,多步执行稳,适合量大的简单活 | 复杂长链条任务容易原地打转;强度用 high 即可;`deepseek-v4-pro` 停在 8 月版本、比 Flash 旧,现阶段不用 |
24
24
  | Kimi | — | 规划、前端还原、多步工具调用 | 慢、贵、常限流;跑分有人称有水分 |
25
25
  | GLM | — | 后端逻辑少出错,中文古风文笔好 | 慢 |
@@ -37,6 +37,7 @@
37
37
  | 代码能否被合并(FrontierCode 2.0) | Fable 5.2(49%) | Opus 5.5、6.2 Astra、6.2 Sol 在 44–46% |
38
38
  | 综合(AA 智能指数,转述) | Fable 5.2、6.2 Astra、Neon、Carbon、Opus 5.5(59–65) | 6.2 Sol 57,Hydrogen 54 |
39
39
  | 专项 | 行业推理:Fable 5.2、Neon、Sonnet 5.5;超长文本:Neon;3D 建模:6.2 Astra | 幻觉率:Hydrogen 8%,Sonnet 5.5 43% |
40
+ | 成本与速度(Vals Index 同一套题,每套成本 / 耗时) | 便宜又快:6.2 Sol $3 / 42 分钟,Neon $7 / 31 分钟,Hydrogen $10 / 32 分钟 | Carbon $11 / 48 分钟,Argon $13 / 45 分钟,Fable 5.2 $18 / 44 分钟;Sonnet 5.5 $16、Opus 5.5 $25,都要约 1.4 小时 |
40
41
 
41
42
  ## 生图模型
42
43
 
@@ -50,4 +51,12 @@
50
51
 
51
52
  ## 决策模型
52
53
 
53
- 只做是非、选择、打分并给出概率,用于批量判断与分流。AA 决策指数:Drex Max v1.1、GLiDE v1.2 并列 73 分,Drex Max 成本最低;Jev 1.14、Gemini Decision 1 都是 66 分,Jev 更便宜,Gemini Decision 1 能处理音频和视频;OpenAI、微软的决策模型低于 66 分。
54
+ 只做是非、选择、打分并给出概率,用于批量判断与分流。
55
+
56
+ | 模型 | AA 决策指数 | 成本 | 特点 |
57
+ |---|---|---|---|
58
+ | Drex Max v1.1(Nace.AI) | 73(并列第一) | 每百万任务 $103,约为 Gemini Decision 1 的三分之一 | — |
59
+ | GLiDE v1.2(Fastino) | 73(并列第一) | 未查 | — |
60
+ | Jev 1.14 | 66 | 比 Gemini Decision 1 便宜 | — |
61
+ | `gemini-decision-1`(Google) | 66 | 输入 $0.10/百万 token,输出免费;每百万任务 $345 | 能处理音频和视频,知识推理强,分类与信息提取一般 |
62
+ | OpenAI Decisions API、Microsoft-Decision-1 | 低于 66 | 与 Gemini Decision 1 同价(OpenAI) | — |
@@ -20,4 +20,4 @@
20
20
 
21
21
  ## 主动发言
22
22
 
23
- 不是房间派来的任务、而是用户在你自己的窗口里要你在房间发言时(主持人另外可在需要主动说明、派活或补交失效执行的结果时自行使用),用 `message post ROOM --proactive --body-file 草稿.md --access-file FILE` 提交(凭据用你最近一次任务的 access_file;转为本机托管后还没收到任务时,用原手动凭证发言会被拒,报错里给出本机服务写给你的主动发言凭据路径,改用它)。它不关联执行或请求,房间里标为“主动发言”;你有进行中的执行时改用本次执行回答;还有待处理的请求时也不能主动发言(手动接入的用 `--request` 回答,程序启动的等本机服务交给你);讨论进行中不可用。普通成员的主动发言不能派活;主持人可以同时 `--to` 派活或 `--continue`,从这条消息起算一条新任务链,同样受轮数上限约束。
23
+ 不是房间派来的任务、而是用户在你自己的窗口里要你在房间发言时(主持人另外可在需要主动说明、派活或补交失效执行的结果时自行使用),用 `message post ROOM --proactive --body-file 草稿.md --access-file FILE` 提交(凭据用你最近一次任务的 access_file;转为本机托管后还没收到任务时,用原手动凭证发言会被拒,报错里给出本机服务写给你的主动发言凭据路径,改用它)。它不关联执行或请求,房间里标为“主动发言”;你有进行中的执行时改用本次执行回答;还有待处理的请求时默认被拒(手动接入的用 `--request` 回答,程序启动的通常等本机服务交给你):这次发言就是其中某条普通请求的回答时,加 `--also-request 请求编号` 一并关闭它(编号在拒绝提示里;主持人交回、接力、评审类请求不能这样关);发言与它们无关、又必须现在说时,主持人可加 `--force`,这些请求不关闭、之后仍会交给你;讨论进行中不可用。普通成员的主动发言不能派活;主持人可以同时 `--to` 派活或 `--continue`,从这条消息起算一条新任务链,同样受轮数上限约束。
@@ -594,6 +594,13 @@ def report_ai(connection, member, payload):
594
594
  return {"reported": True}
595
595
 
596
596
 
597
+ def lend_until(connection, member, payload):
598
+ """The member's computer sets how long it lends its AI; only its own end changes, never what it may read (red line 1 exception)."""
599
+ expires_at = checked_expiry(payload.get("expires_at"), int(time.time()))
600
+ connection.execute("UPDATE external_members SET expires_at=?,updated_at=? WHERE member_id=?", (expires_at, int(time.time()), member["id"]))
601
+ return {"expires_at": expires_at}
602
+
603
+
597
604
  def leave_room(connection, member):
598
605
  """The external member leaves on its own; its credential stops working at once."""
599
606
  end_member(connection, member, "left")
@@ -641,6 +648,8 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
641
648
  return hooks["answer"](connection, room_id, answer_payload(member, payload), member), 201
642
649
  if route == ["ai"]:
643
650
  return report_ai(connection, member, payload), 200
651
+ if route == ["expiry"]:
652
+ return lend_until(connection, member, payload), 200
644
653
  if route == ["leave"]:
645
654
  return leave_room(connection, member), 200
646
655
  raise LookupError(Text("地址不存在"))
@@ -1316,7 +1316,9 @@ def check_proactive(connection, room_id, member, payload):
1316
1316
  """A member speaking on its own, e.g. its user asked in its own window, bound to no request or execution.
1317
1317
 
1318
1318
  The host's may dispatch and ask to continue, starting a chain of its own; other members' only speak. Refused while
1319
- the member has a live execution (it answers through that, so the round limit holds) or a discussion runs.
1319
+ the member has a live execution (it answers through that, so the round limit holds), a discussion runs, or requests
1320
+ still wait for the member. A waiting request the post answers is named in `also_request_ids` and closed with it;
1321
+ only the host may speak past the others with `force`, and those stay pending.
1320
1322
  """
1321
1323
  if payload["proactive"] is not True:
1322
1324
  raise ValueError(Text("proactive 的值须为 true"))
@@ -1327,14 +1329,28 @@ def check_proactive(connection, room_id, member, payload):
1327
1329
  else Text("主动发言不关联请求,普通成员也不能派活,不能带:{fields}", fields="、".join(carried)))
1328
1330
  if connection.execute("SELECT 1 FROM member_executions WHERE member_id=? AND status IN ('dispatched','started')", (member["id"],)).fetchone():
1329
1331
  raise FileExistsError(Text("你有进行中的执行,请用本次执行回答,不能主动发言"))
1330
- pending = [row[0] for row in connection.execute("SELECT message_id FROM member_requests WHERE member_id=? AND status='pending' ORDER BY id",
1331
- (member["id"],))]
1332
- if pending:
1332
+ force, answered = payload.get("force"), payload.get("also_request_ids")
1333
+ if force not in (None, False) and (force is not True or member["role"] != "host"):
1334
+ raise ValueError(Text("force 只能由主持人使用,值为 true"))
1335
+ # Requests this post answers (`also_request_ids`, closed with it) do not hold it back; the rest do, unless the host
1336
+ # says the post is none of their answer (`force`): they may stay undelivered for long, and the room must still hear it.
1337
+ waiting = [row for row in connection.execute("SELECT id,message_id FROM member_requests WHERE member_id=? AND status='pending' ORDER BY id",
1338
+ (member["id"],)) if not isinstance(answered, list) or row["id"] not in answered]
1339
+ if waiting and force is not True:
1333
1340
  # Otherwise the same question is answered here and again when the request is delivered.
1334
- requests = "、".join(f"#{item}" for item in pending)
1335
- raise FileExistsError(Text("你还有待处理的请求({requests}),不能主动发言;用 --request 关闭它们后回答", requests=requests)
1336
- if member["access"] == "manual" else
1337
- Text("你还有待处理的请求({requests}),不能主动发言;本机服务会把它们交给你,届时一并回答", requests=requests))
1341
+ requests = "、".join(f"{row['id']}/#{row['message_id']}" for row in waiting)
1342
+ if member["access"] == "manual":
1343
+ raise FileExistsError(Text("你还有待处理的请求(请求编号/消息编号:{requests}),不能主动发言;用 --request 关闭它们后回答", requests=requests))
1344
+ # Name the ones this post may close, so one refusal is enough to write the right options.
1345
+ open_ids = {row["id"] for row in waiting}
1346
+ closable = "、".join(str(item["id"]) for item in queued_requests(connection, member["id"]) if item["id"] in open_ids)
1347
+ if member["role"] == "host" and closable:
1348
+ raise FileExistsError(Text("你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;这次发言就是请求 {closable} 的回答时,用 --also-request 请求编号 一并关闭(其余是交回、接力或评审类,不能这样关闭);与待处理请求无关而确需现在说时加 --force,没关闭的请求仍会交给你", requests=requests, closable=closable))
1349
+ if member["role"] == "host":
1350
+ raise FileExistsError(Text("你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;它们是交回、接力或评审类,不能由主动发言关闭;确需现在说时加 --force,这些请求仍会交给你", requests=requests))
1351
+ if closable:
1352
+ raise FileExistsError(Text("你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;这次发言就是请求 {closable} 的回答时,用 --also-request 请求编号 一并关闭", requests=requests, closable=closable))
1353
+ raise FileExistsError(Text("你还有待处理的请求(请求编号/消息编号:{requests}),不能主动发言;本机服务会把它们交给你,届时一并回答", requests=requests))
1338
1354
  if discussion.current_session(connection, room_id, active_only=True):
1339
1355
  raise FileExistsError(Text("讨论进行中,不能主动发言;按主持人的安排发言"))
1340
1356
  if payload.get("to"):
@@ -1349,6 +1365,8 @@ def check_proactive(connection, room_id, member, payload):
1349
1365
  def after_proactive(connection, room_id, message_id, member, payload):
1350
1366
  """Record a proactive post; the host's dispatch or continue starts a new chain at it, under the usual round limit."""
1351
1367
  connection.execute("INSERT INTO proactive_messages (message_id) VALUES (?)", (message_id,))
1368
+ # The member's own waiting requests this post answers are closed with it, so they are not delivered and answered again.
1369
+ close_also_requests(connection, room_id, member, message_id, payload.get("also_request_ids"))
1352
1370
  if member["role"] != "host":
1353
1371
  settle_batches(connection, room_id)
1354
1372
  return
@@ -1370,8 +1388,6 @@ def check_answer(connection, room_id, member, payload):
1370
1388
  Only the AI host dispatches work; other members' targets remain suggestions. A proactive post is checked apart.
1371
1389
  """
1372
1390
  if payload.get("proactive") is not None:
1373
- if payload.get("also_request_ids") is not None:
1374
- raise ValueError(Text("主动发言不关联执行,不能一并交付排队请求(also_request_ids)"))
1375
1391
  check_proactive(connection, room_id, member, payload)
1376
1392
  return None
1377
1393
  if payload.get("to") is not None:
@@ -3983,7 +3999,15 @@ def record_model_change(connection, room_id, member, payload):
3983
3999
  if not all(isinstance(value, str) and 0 < len(value.strip()) <= MODEL_TEXT_LIMIT for value in (before, after)):
3984
4000
  raise ValueError(Text("from 与 to 须为 1–100 字的模型说明"))
3985
4001
  name = member_display_names(connection, room_id).get(member["name"], member["name"])
3986
- text = Text("{name} 的模型已从 {before} 换为 {after},下次执行起生效。", name=name, before=before.strip(), after=after.strip())
4002
+ # Who changed it is part of the record: the host through host-control (named by the site from its credential), or
4003
+ # else the owner (user 2026-11-19, #5682: a bare record left the owner asking whether the host meant it).
4004
+ host = payload.get("by_host") or ""
4005
+ if host == name:
4006
+ text = Text("主持人 {host} 把自己的模型从 {before} 换为 {after},下次执行起生效。", host=host, before=before.strip(), after=after.strip())
4007
+ elif host:
4008
+ text = Text("主持人 {host} 把 {name} 的模型从 {before} 换为 {after},下次执行起生效。", host=host, name=name, before=before.strip(), after=after.strip())
4009
+ else:
4010
+ text = Text("用户把 {name} 的模型从 {before} 换为 {after},下次执行起生效。", name=name, before=before.strip(), after=after.strip())
3987
4011
  message_id = connection.execute("INSERT INTO messages(room_id,author,text,source,submission_id,created_at) VALUES(?,?,?,?,?,?)",
3988
4012
  (room_id, NOTICE_AUTHOR, text, "notice", f"model-{member['id']}-{uuid.uuid4().hex}",
3989
4013
  time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()))).lastrowid
package/backend/server.py CHANGED
@@ -83,7 +83,7 @@ DIRECTORY_OPERATIONS = ("move", "folder")
83
83
  # Local entry commands for external members: the owner's invites (room credential) and this computer's invited records.
84
84
  INVITE_COMMANDS = ("room-invite", "room-invites", "room-invite-revoke")
85
85
  INVITED_COMMANDS = ("invited-list", "invited-join", "invited-trust", "invited-ai", "invited-pause", "invited-approve", "invited-refuse",
86
- "invited-leave", "invited-remove", "invited-room")
86
+ "invited-lend", "invited-leave", "invited-remove", "invited-room")
87
87
  ADMIN_OPERATIONS = ("rename", "archive", "restore", "delete")
88
88
  DIRECTORY_PICKER_TIMEOUT = 600 # the folder dialog waits for the person at the computer
89
89
  # Files are streamed to players in pieces of this size.
@@ -3629,7 +3629,7 @@ class DiscussionHandler(BaseHTTPRequestHandler):
3629
3629
  elif parts[3:] == ["members"] and method == "POST":
3630
3630
  result = add_member(connection, room_id, token, self.read_payload(), utc_now())
3631
3631
  elif len(parts) == 5 and parts[3] == "members" and method == "POST":
3632
- result = member_action(connection, room_id, int(parts[4]), token, self.read_payload())
3632
+ result = member_action(connection, room_id, int(parts[4]), token, {**self.read_payload(), "by_host": self.acting_host(connection, room_id)})
3633
3633
  elif len(parts) == 6 and parts[3] == "members" and parts[5] == "interrupt" and method == "POST":
3634
3634
  result = interrupt_member(connection, room_id, int(parts[4]), token, self.acting_host(connection, room_id))
3635
3635
  elif len(parts) == 6 and parts[3] == "members" and parts[5] == "chat" and method in ("GET", "POST"):
package/docs/en/runner.md CHANGED
@@ -89,22 +89,23 @@ Invite an AI on another computer into your room: it reads only the project files
89
89
  **Before you start**: both computers install CoDiscuss and run the local service; your computer is [connected to a hosted site](#from-a-hosted-site) with the relay deployed, and the other side reaches your room through that site's encrypted relay. While your computer is off or codiscuss is not running, the other side gets nothing.
90
90
 
91
91
  **Invite (your computer)**:
92
- 1. In the new-room panel or Invite members, click "External expert +" on the External row (once per expert), then on the card's back select what they can see (Room messages / Messages and project) and the membership duration after check-in. "Messages and project" opens all of the room's project folders.
92
+ 1. In the new-room panel or Invite members, click "External expert +" on the External row (once per expert), then on the card's back select what they can see (Room messages / Messages and project). How long the AI is lent is the other side's choice when joining; you do not set it. "Messages and project" opens all of the room's project folders.
93
93
  2. Choose Invite (automatic when creating the room). The seat appears immediately in the right-hand roster. When added from the invite dialog, the dialog stays on an "added" step where you can choose Copy invitation link right away. Above the message box, "<name> awaiting check-in: send the invitation link to the invitee" offers Copy invitation link (also in the member menu), or Invitation details for the QR code; share either. The link lasts 10 minutes and binds one member; regenerating it invalidates the previous link. While Invitation details is open, an expired link is replaced with a new one automatically. Without a connected hosted site, the seat shows that it is waiting for a link and explains why; generate it from the seat menu after connecting. Before check-in, the panel shows the automatic expiry deadline and Remove seat. Usage, read logs and access adjustments appear after check-in.
94
- 3. Redemption completes check-in and starts the membership duration, with **no extra approval step**. Pending seats receive no work and do not participate in group replies or discussions; they end automatically after 7 days. An expired link leaves the seat intact.
95
- 4. `@` it in the room; its answers appear in the conversation as usual. "Read log and access" in the member menu lists every file it read (recorded by your computer) and lets you extend, switch to messages only, or revoke; revoking takes effect immediately. Once a member has ended (expired, left or revoked) it stays dimmed below the roster with the reason; Invite back makes a new link that brings the same member back, keeping its name and history in the room. If the other side still keeps its invited-room record, that record and its settings carry on; if it was deleted, a new one starts.
94
+ 3. Redemption completes check-in and starts the loan time, with **no extra approval step**. Pending seats receive no work and do not participate in group replies or discussions; they end automatically after 7 days. An expired link leaves the seat intact.
95
+ 4. `@` it in the room; its answers appear in the conversation as usual. "Read log and access" in the member menu lists every file it read (recorded by your computer) and lets you switch to messages only, or revoke; revoking takes effect immediately. The time left is set by the other side and only shown here. The external expert's card under Members and settings on the Room page shows the same details and actions. Once a member has ended (expired, left or revoked) it stays dimmed below the roster with the reason; Invite back makes a new link that brings the same member back, keeping its name and history in the room. If the other side still keeps its invited-room record, that record and its settings carry on; if it was deleted, a new one starts.
96
96
  5. After check-in, its avatar shows the vendor of the other side's AI, and "Read log and access" shows the software and model; both update when the other side switches AI. The other computer reports this itself, so treat it as identification only. A custom endpoint shows the external expert icon.
97
97
 
98
98
  **Join (the other computer)**:
99
- 1. Open the link and choose "Join with CoDiscuss on this computer" to go to the local page; or choose "+" under "External rooms" in the left panel and paste the link, scan the QR code with the camera, choose a QR code image, or paste a screenshot of it; or run `codiscuss join <link> --adapter TOOL`.
100
- 2. Pick the AI and set it up on its expert card: a new conversation or one this software already holds (joining with its context; manual start is unavailable), model and effort, its own prompt, and the two settings below (Room only · Answer at once by default, with no further confirmation after joining):
99
+ 1. Open the link and choose "Join with CoDiscuss on this computer" to go to the local page; or choose "+" under "External rooms" in the left panel and paste the link, scan the QR code with the camera, choose a QR code image, or paste a screenshot of it; or run `codiscuss join <link> --adapter TOOL [--duration 1h|today|3d]`, and later change the loan time with `codiscuss invited lend ID 1h|today|3d`.
100
+ 2. Pick the AI and set it up on its expert card: a new conversation or one this software already holds (joining with its context; manual start is unavailable), model and effort, its own prompt, and the three settings below (Room only · Answer at once · 1 hour by default, with no further confirmation after joining):
101
101
 
102
102
  | Setting | Options |
103
103
  | --- | --- |
104
104
  | When named | Answer at once: no wake count or time limit · Ask me: woken only after you approve in the right panel each time; declining, or 15 minutes without an answer, shows "Not accepted by the other side" |
105
105
  | Local access | Room only: limited to CoDiscuss commands, running in an empty temporary folder · Unrestricted: can read local files and use the network |
106
+ | Lent for | 1 hour · Today · 3 days (3 days at most). The membership ends when it runs out; renew before then to continue |
106
107
 
107
- The external room page shows the other room's chat like a room's messages, read only (scroll up for earlier messages); the requests to your AI carry how they went on this computer. The other room's private chats, runs, settings and files are not available there. Both settings are kept per room; you can change them later in the external room's right panel, or pause or leave. Once the room has ended, you can delete its record from this computer. `codiscuss invited` offers the same commands, and a paired phone or tablet can set every option. The local service does the waking, so keep codiscuss running. When the AI ends without submitting an answer, the external room page shows the end of its run output on this computer under the failure reason (kept here only, never sent to the other side); `codiscuss external room ID --json` shows it too.
108
+ The external room page shows the other room's chat like a room's messages, read only (scroll up for earlier messages); the requests to your AI carry how they went on this computer. The other room's private chats, runs, settings and files are not available there. All three settings are kept per room; you can change them later in the external room's right panel (a new loan time counts from the change, so it can renew or shorten), or pause or leave. Once the room has ended, you can delete its record from this computer. `codiscuss invited` offers the same commands, and a paired phone or tablet can set every option. The local service does the waking, so keep codiscuss running. When the AI ends without submitting an answer, the external room page shows the end of its run output on this computer under the failure reason (kept here only, never sent to the other side); `codiscuss external room ID --json` shows it too.
108
109
 
109
110
  **Supported tools**: Room only needs a tool that can be limited to CoDiscuss commands. Claude Code (background runs) supports it, tested on version 2.1.325 (other versions not individually checked), so does the Antigravity CLI, tested on version 1.5.12 (its web search cannot be turned off; anything else you always allowed in agy is denied in these tasks, while your own use of agy is unchanged), and so do model APIs, backed by unit tests; Codex and the Antigravity desktop app do not support it and can only run Unrestricted; desktop apps cannot join as external members.
110
111
 
package/docs/runner.md CHANGED
@@ -120,22 +120,23 @@ codiscuss local connect https://你的站点
120
120
  **前提**:两台电脑都安装共议并运行本机服务;你的电脑已[连接线上网站](#线上网页连接本机)并部署了中转,对方经这个网站的加密中转访问你的房间。你的电脑关机或 codiscuss 未运行时,对方什么也拿不到。
121
121
 
122
122
  **邀请(你的电脑)**:
123
- 1. 建房面板或右栏“邀请成员”里点“外部”一行的“外部专家 +”(可加多位),翻到卡片背面设置“对方能看到”(房间消息 / 消息和项目)和签到后的有效期。选“消息和项目”时开放本房间的全部项目目录。
123
+ 1. 建房面板或右栏“邀请成员”里点“外部”一行的“外部专家 +”(可加多位),翻到卡片背面设置“对方能看到”(房间消息 / 消息和项目)。借出多久由对方加入时决定,你不用设。选“消息和项目”时开放本房间的全部项目目录。
124
124
  2. 点“邀请”(建房时自动添加),右栏名单立即显示待签到成员。从邀请弹窗添加时,弹窗会停在“已加入”一步,可直接点“复制邀请链接”。输入框上方会出现“成员名 待签到:把邀请链接发给对方”,点“复制邀请链接”直接复制(成员菜单里也有这一项),或点“邀请详情”查看二维码,发给对方。链接 10 分钟有效,只能绑定一位成员;重新生成会立即作废旧链接。“邀请详情”开着时,链接到期会自动换成新的。未绑定线上站点时显示“待生成链接”及原因,绑定站点后从席位菜单生成。待签到面板显示自动结束期限,可“移除席位”;签到后才显示用量、读取记录和授权调整。
125
- 3. 对方兑换即完成签到,成员有效期从兑换时开始,**没有额外批准步骤**。未签到不收任务、不参与全体回应或讨论,7 天后自动结束;链接过期不会删除席位。
126
- 4. 在房间里 `@` 它,回答照常出现在对话中。成员菜单的“读取记录与权限”列出它读过的每个文件(由你的电脑记录),可延长、改为只看消息或撤销授权,撤销立即生效。成员结束后(到期、对方退出或撤销)仍灰显在名单下方并写明原因,点“重新邀请”可生成新链接把原成员请回:名字和房间里的历史不变;对方若还保留那条被邀请记录,记录与设置也接着用,删了则新建。
125
+ 3. 对方兑换即完成签到,借出时间从兑换时开始,**没有额外批准步骤**。未签到不收任务、不参与全体回应或讨论,7 天后自动结束;链接过期不会删除席位。
126
+ 4. 在房间里 `@` 它,回答照常出现在对话中。成员菜单的“读取记录与权限”列出它读过的每个文件(由你的电脑记录),可改为只看消息或撤销授权,撤销立即生效;剩余时间由对方设定,你这边只能看。房间页“成员与设置”里的外部专家卡片显示同样的信息与操作。成员结束后(到期、对方退出或撤销)仍灰显在名单下方并写明原因,点“重新邀请”可生成新链接把原成员请回:名字和房间里的历史不变;对方若还保留那条被邀请记录,记录与设置也接着用,删了则新建。
127
127
  5. 签到后头像显示对方 AI 的厂家,“读取记录与权限”里可看到软件和模型;对方换 AI 后自动更新。这些信息由对方电脑自报,仅供辨认。自定义接口显示外部专家图标。
128
128
 
129
129
  **加入(对方电脑)**:
130
- 1. 打开链接,点“用本机共议加入”跳到本机网页;或在左栏“外部房间”点“+”粘贴链接,也可以用相机扫码、选择二维码图片或粘贴二维码截图;命令行为 `codiscuss join <链接> --adapter 软件`。
131
- 2. 选派哪个 AI,在它的专家卡片上设置:新会话或续接这个软件已有的会话(带着原上下文加入;手动启动不可用)、模型与强度、专属提示词,以及下面两项(默认“只在房间里发言 · 直接回答”,加入后无需再确认):
130
+ 1. 打开链接,点“用本机共议加入”跳到本机网页;或在左栏“外部房间”点“+”粘贴链接,也可以用相机扫码、选择二维码图片或粘贴二维码截图;命令行为 `codiscuss join <链接> --adapter 软件 [--duration 1h|today|3d]`,之后用 `codiscuss invited lend ID 1h|today|3d` 改借出时间。
131
+ 2. 选派哪个 AI,在它的专家卡片上设置:新会话或续接这个软件已有的会话(带着原上下文加入;手动启动不可用)、模型与强度、专属提示词,以及下面三项(默认“只在房间里发言 · 直接回答 · 1 小时”,加入后无需再确认):
132
132
 
133
133
  | 设置 | 选项 |
134
134
  | --- | --- |
135
135
  | 被点名时 | 直接回答:不设次数与期限上限 · 先问我:每次在右栏同意才唤醒,拒绝或 15 分钟未处理,对方看到“对方未同意” |
136
136
  | 本机权限 | 只在房间里发言:只能用共议命令,在空的临时目录运行 · 不受限:可读本机文件、联网 |
137
+ | 借出时间 | 1 小时 · 今天 · 3 天(最长 3 天)。到期后成员资格结束,要继续须在到期前续期 |
137
138
 
138
- 外部房间的页面像房间消息页一样显示对方房间的聊天记录(只读,往上滚动可看更早的消息),点名你 AI 的请求标有在这台电脑上的处理结果;对方房间的私聊、执行、房间设置与文件都不开放。两项设置都按房间分别保存,之后可在外部房间的右栏调整,也可暂停或退出,房间结束后可删除这台电脑上的记录;`codiscuss invited` 有同样的命令,已配对的手机或平板也能设置全部选项。唤醒由本机服务完成,请保持 codiscuss 运行。AI 没提交回答就结束时,外部房间的页面会在失败原因下列出这台电脑上运行输出的末尾(只存在本机,不发给对方),`codiscuss invited room ID --json` 也能看到。
139
+ 外部房间的页面像房间消息页一样显示对方房间的聊天记录(只读,往上滚动可看更早的消息),点名你 AI 的请求标有在这台电脑上的处理结果;对方房间的私聊、执行、房间设置与文件都不开放。三项设置都按房间分别保存,之后可在外部房间的右栏调整(借出时间从调整时起重新计算,可续期也可改短),也可暂停或退出,房间结束后可删除这台电脑上的记录;`codiscuss invited` 有同样的命令,已配对的手机或平板也能设置全部选项。唤醒由本机服务完成,请保持 codiscuss 运行。AI 没提交回答就结束时,外部房间的页面会在失败原因下列出这台电脑上运行输出的末尾(只存在本机,不发给对方),`codiscuss invited room ID --json` 也能看到。
139
140
 
140
141
  **支持的软件**:“只在房间里发言”要求软件能限制为只用共议命令,目前支持 Claude Code(后台运行,已在 2.1.325 版实测,其他版本未逐一验证)、Antigravity CLI(已在 1.5.12 版实测;它的网页搜索无法禁止;你在 agy 里“始终允许”过的其他操作,在受限任务里会被禁止,平时使用不受影响)与模型 API(以单元测试为据);Codex 与 Antigravity 桌面版不支持,只能选“不受限”;桌面 App 不能作为外部成员加入。
141
142
 
@@ -371,12 +371,12 @@
371
371
  "已开启": "On",
372
372
  "你自己使用这台电脑的入口。": "Your own ways into this computer.",
373
373
  "{value1} 有新版本": "New version of {value1}",
374
- "托管账号从这份副本运行。更新共议时会自动同步;Claude Code 等程序单独升级后,在这里同步一次。": "Hosted accounts run from this copy. Updating CoDiscuss syncs it automatically; sync here once after upgrading Claude Code or another program on its own.",
374
+ "托管账号从这份副本运行。管理面板启动和更新共议时会自动同步;没有同步上时在这里同步。": "Hosted accounts run from this copy. It syncs automatically when the admin panel starts and when CoDiscuss updates; sync here if that did not work.",
375
375
  "登录入口未运行,使用者暂时无法登录": "The sign-in entry is not running, so users cannot sign in for now",
376
376
  "扫码配对过的设备可以在外面使用这台电脑": "Devices paired by QR code can use this computer from elsewhere",
377
377
  "需先在“本机 → 线上网站”绑定": "Bind under This computer → Online site first",
378
378
  "经线上网站中转": "Through the online site",
379
- "不需要域名:经共议线上网站中转到这台电脑,手机和外地的电脑都能打开。需要这台电脑已在“本机 → 线上网站”绑定。": "No domain needed: relayed through the CoDiscuss online site to this computer, so phones and computers elsewhere can open it. This computer must be bound under This computer → Online site.",
379
+ "不需要域名:经共议线上网站中转到这台电脑,手机和外地的电脑都能打开。需要先把这台电脑绑定到线上网站。": "No domain needed: relayed through the CoDiscuss online site to this computer, so phones and computers elsewhere can open it. Bind this computer to the online site first.",
380
380
  "已开启经线上网站中转": "Relay through the online site turned on",
381
381
  "已关闭经线上网站中转": "Relay through the online site turned off",
382
382
  "其他设备远程使用、邀请外部专家、托管账号经线上网站登录都需要": "Needed for using this computer from other devices, inviting external experts, and hosted accounts signing in through the online site",
@@ -394,5 +394,6 @@
394
394
  "这条排队消息已发出或已删除": "This queued message was already sent or deleted.",
395
395
  "未能编辑,消息仍在排队:{value1}": "Couldn't edit it. The message is still queued: {value1}",
396
396
  "消息仍在排队,输入框里是副本,发送前请先删除排队中的原消息": "The message is still queued and the composer holds a copy. Delete the queued original before sending.",
397
- "未能确认这条排队消息的状态,内容已保留在输入框,请确认未发出后再发送": "Couldn't confirm this queued message's status. Its text is kept in the composer. Check that it wasn't sent before sending it again."
397
+ "未能确认这条排队消息的状态,内容已保留在输入框,请确认未发出后再发送": "Couldn't confirm this queued message's status. Its text is kept in the composer. Check that it wasn't sent before sending it again.",
398
+ "请先登录": "Please sign in"
398
399
  }
@@ -201,7 +201,9 @@
201
201
  "主持人 {name} 额度已用尽,处理 {messages} 的执行 #{execution_id} 失败,重置时间:{resets}。房间暂停推进:可等重置后重试这次执行,或在另一位成员卡片上点“设为主持人”换人。": "The host {name} is out of quota: execution #{execution_id} for {messages} failed. Resets at: {resets}. The room has stopped moving: retry this execution after the reset, or click “Make host” on another member's card to hand the role over.",
202
202
  "主持人 {name} 额度已用尽,处理 {messages} 的执行 #{execution_id} 失败,重置时间未知。房间暂停推进:可等额度恢复后重试这次执行,或在另一位成员卡片上点“设为主持人”换人。": "The host {name} is out of quota: execution #{execution_id} for {messages} failed. The reset time is unknown. The room has stopped moving: retry this execution once the quota is back, or click “Make host” on another member's card to hand the role over.",
203
203
  "from 与 to 须为 1–100 字的模型说明": "from and to must each describe a model in 1–100 characters",
204
- "{name} 的模型已从 {before} 换为 {after},下次执行起生效。": "{name}'s model changed from {before} to {after}, effective from its next execution.",
204
+ "用户把 {name} 的模型从 {before} 换为 {after},下次执行起生效。": "The user changed {name}'s model from {before} to {after}, effective from its next execution.",
205
+ "主持人 {host} 把 {name} 的模型从 {before} 换为 {after},下次执行起生效。": "Host {host} changed {name}'s model from {before} to {after}, effective from its next execution.",
206
+ "主持人 {host} 把自己的模型从 {before} 换为 {after},下次执行起生效。": "Host {host} changed its own model from {before} to {after}, effective from its next execution.",
205
207
  "action 须为 done;宣告 Goal 卡住用 goal block": "action must be done. Use goal block to declare a blocked Goal",
206
208
  "action 须为 renew、fail、release、report、segments、interject、interjection、retry_wait、retry_start、retry_now、retry_stop 或 retry": "action must be renew, fail, release, report, segments, interject, interjection, retry_wait, retry_start, retry_now, retry_stop, or retry",
207
209
  "action 须为 start、continue、wait、state、done、block、pause、resume、clear 或 update": "action must be start, continue, wait, state, done, block, pause, resume, clear, or update",
@@ -282,8 +284,12 @@
282
284
  "任务链剩余额度不足,需用户续额或主持人另行处理": "The task chain has insufficient remaining capacity. The user must extend it or the host must handle this separately",
283
285
  "会话阶段须为 initial 或 discussing": "The session phase must be initial or discussing",
284
286
  "你有进行中的执行,请用本次执行回答,不能主动发言": "You have an active run. Reply through that run instead of posting a proactive message",
285
- "你还有待处理的请求({requests}),不能主动发言;本机服务会把它们交给你,届时一并回答": "You still have pending requests ({requests}) and cannot post a proactive message. The local service will deliver them to you so you can answer together",
286
- "你还有待处理的请求({requests}),不能主动发言;用 --request 关闭它们后回答": "You still have pending requests ({requests}) and cannot post a proactive message. Close them with --request when replying",
287
+ "你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;这次发言就是请求 {closable} 的回答时,用 --also-request 请求编号 一并关闭(其余是交回、接力或评审类,不能这样关闭);与待处理请求无关而确需现在说时加 --force,没关闭的请求仍会交给你": "You still have pending requests (request id/message id: {requests}). The local service will deliver them to you so you can answer together. If this post is the answer to request {closable}, close it with --also-request REQUEST_ID (the others are hand-backs, relay steps or reviews and cannot be closed this way); if it is unrelated to the pending requests and you must speak now, add --force, and the requests left open will still be delivered to you",
288
+ "你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;它们是交回、接力或评审类,不能由主动发言关闭;确需现在说时加 --force,这些请求仍会交给你": "You still have pending requests (request id/message id: {requests}). The local service will deliver them to you so you can answer together. They are hand-backs, relay steps or reviews and cannot be closed by a proactive post; if you must speak now, add --force, and those requests will still be delivered to you",
289
+ "你还有待处理的请求(请求编号/消息编号:{requests}),本机服务会把它们交给你,届时一并回答;这次发言就是请求 {closable} 的回答时,用 --also-request 请求编号 一并关闭": "You still have pending requests (request id/message id: {requests}). The local service will deliver them to you so you can answer together. If this post is the answer to request {closable}, close it with --also-request REQUEST_ID",
290
+ "你还有待处理的请求(请求编号/消息编号:{requests}),不能主动发言;本机服务会把它们交给你,届时一并回答": "You still have pending requests (request id/message id: {requests}) and cannot post a proactive message. The local service will deliver them to you so you can answer together",
291
+ "force 只能由主持人使用,值为 true": "force may only be used by the host, with the value true",
292
+ "你还有待处理的请求(请求编号/消息编号:{requests}),不能主动发言;用 --request 关闭它们后回答": "You still have pending requests (request id/message id: {requests}) and cannot post a proactive message. Close them with --request when replying",
287
293
  "依次接力不存在": "Relay not found",
288
294
  "依次接力不能同时声明预授权评审;评审者直接排进顺序即可": "A relay cannot also declare a preauthorized review. Include the reviewer directly in the sequence",
289
295
  "依次接力须用 to 按顺序点名至少两位不同成员,每位只出现一次": "A relay requires at least two distinct members named in order in to, each appearing once",
@@ -767,7 +773,6 @@
767
773
  "正文已变化,请从头重读,不要与先前读到的片段拼接": "The text has changed; read it again from the start and do not join it with parts read earlier",
768
774
  "该附件所在的消息超出本请求读取上界 #{until}": "The message this attachment belongs to is past this request's reading boundary #{until}",
769
775
  "本请求只能读到 #{until},房间最新消息为 #{latest};之后的消息在独立观点阶段结束后才能读": "This request can read only up to #{until}; the room's latest message is #{latest}, and later messages can be read once the independent-opinion stage ends",
770
- "主动发言不关联执行,不能一并交付排队请求(also_request_ids)": "A proactive post is bound to no execution, so it cannot deliver queued requests (also_request_ids)",
771
776
  "用户已回答问题 #{question_id}(消息 #{message_id}),但依次派活 #{relay} 后面没有可接手的在场成员(或主持人已更换),接力已停下。请主持人决定接下来怎么做。": "The user answered question #{question_id} (message #{message_id}), but relay #{relay} has no member present to take the next step (or its host changed), so the relay stopped. Host: decide what comes next.",
772
777
  "multiSelect 与 free_text 须为布尔值": "multiSelect and free_text must be booleans",
773
778
  "header 须为最多 {limit} 字的短标签": "header must be a short label of at most {limit} characters",
@@ -37,7 +37,7 @@
37
37
  "这个账号开启了入口保护,但入口读不到它的密钥": "This account has entry protection enabled, but the entry cannot read its key",
38
38
  "实例没有按入口保护启动起来(启动失败,或密钥对不上)": "Instance did not start with entry protection (startup failed or the key does not match)",
39
39
  "实例没有启动起来": "Instance did not start",
40
- "还没有安装隔离账号的程序副本,请先在“概览 → 登录入口 → 托管账号入口”中同步": "Program copies for isolated accounts are not installed yet. Sync them under Overview → Sign-in entry → Hosted account entry first.",
40
+ "还没有安装隔离账号的程序副本,请先在“概览 → 本机 → 程序副本”中安装": "Program copies for isolated accounts are not installed yet. Install them under Overview → This computer → Program copy first.",
41
41
  "技能库里没有 {value1}": "Skill library does not contain {value1}",
42
42
  "未知操作:{value1}": "Unknown action: {value1}",
43
43
  "未知程序:{value1}": "Unknown app: {value1}",
@@ -37,8 +37,6 @@
37
37
  "等退出通知送达后可删除": "Can be deleted once the leave notice arrives",
38
38
  "1 小时": "1 hour",
39
39
  "今天": "Today",
40
- "30 天": "30 days",
41
- "7 天": "7 days",
42
40
  "已到期": "Expired",
43
41
  "剩余 {count} 天": "{count} d left",
44
42
  "剩余 {count} 小时": "{count} h left",
@@ -61,7 +59,6 @@
61
59
  "阿里云百炼": "Alibaba Cloud Model Studio",
62
60
  "开放目录": "Open directories",
63
61
  "只读:已跟踪与未忽略的文件,固定排除 .env、密钥、凭据、data/ 与 .git。": "Read-only: tracked and non-ignored files; .env, keys, credentials, data/ and .git are always excluded.",
64
- "有效期": "Valid for",
65
62
  "项目内容会发给对方模型服务商": "Project content goes to their model provider",
66
63
  "消息会发给对方模型服务商": "Messages go to their model provider",
67
64
  "生成邀请需要本机服务,请在这台电脑打开本机网站。": "Creating an invitation needs the local service; open the local website on this computer.",
@@ -71,8 +68,6 @@
71
68
  "已经读出去的内容收不回,会留在对方 AI 的会话里。": "What was already read cannot be taken back; it stays in the other AI's session.",
72
69
  "外部成员 · {name}": "External member · {name}",
73
70
  "调整": "Adjust",
74
- "延长": "Extend",
75
- "已延长": "Extended",
76
71
  "已降为只讨论,之后不能再读项目文件": "Downgraded to discussion only; it can no longer read project files",
77
72
  "读取记录": "Read log",
78
73
  "还没有读取记录": "No reads yet",
@@ -221,5 +216,21 @@
221
216
  "启动新成员": "Start new members",
222
217
  "已复制邀请链接": "Invitation link copied",
223
218
  "{value1} 待签到:把邀请链接发给对方": "{value1} awaiting check-in: send the invitation link to the invitee",
224
- "选择一个 AI 派去对方房间,点卡片翻面可设置软件、模型和本机权限。": "Pick an AI to send to the other room; flip its card to set software, model and local access."
219
+ "选择一个 AI 派去对方房间,点卡片翻面可设置软件、模型和本机权限。": "Pick an AI to send to the other room; flip its card to set software, model and local access.",
220
+ "3 天": "3 days",
221
+ "借出时间": "Lent for",
222
+ "借出多久由你决定,最长 3 天;加入后可在外部房间里续期或改短。": "You decide how long to lend it, up to 3 days; after joining you can renew or shorten it in the external room.",
223
+ "借出时间已更新": "Loan time updated",
224
+ "由对方决定": "Set by the invitee",
225
+ "借出多久由对方加入时决定,你可随时撤销。": "The invitee decides how long to lend its AI when joining; you can revoke at any time.",
226
+ "对方设定": "set by the invitee",
227
+ "借出到": "Lent until",
228
+ "对方未说明": "Not stated",
229
+ "{name} 能看到的内容": "What {name} can see",
230
+ "可改为只看消息;再开放项目须重新邀请": "Can be narrowed to messages only; opening the project again needs a new invitation",
231
+ "再开放项目须重新邀请": "Opening the project again needs a new invitation",
232
+ "借出多久由对方决定,你可随时撤销": "The invitee decides how long it is lent; you can revoke at any time",
233
+ "由对方加入时决定": "Set by the invitee when joining",
234
+ "不变": "Unchanged",
235
+ "从现在起重新计算,最长 3 天": "Counted again from now, 3 days at most"
225
236
  }
@@ -347,6 +347,9 @@ async function read_form(request) {
347
347
  function cross_origin(request) {
348
348
  const origin = request.headers.origin;
349
349
  if (!origin) return false;
350
+ // The instance's pages send no referrer, so their own forms post `Origin: null`; the browser still says it is the
351
+ // same site (#5688: signing out failed as "from another website").
352
+ if (origin === 'null' && request.headers['sec-fetch-site'] === 'same-origin') return false;
350
353
  try { return new URL(origin).host !== request.headers.host; } catch { return true; }
351
354
  }
352
355
 
@@ -437,17 +440,20 @@ export function create_gateway({ data, now = Date.now }) {
437
440
  async function login(request, response) {
438
441
  const form = await read_form(request);
439
442
  const name = String(form.get('name') || '').trim().toLowerCase();
440
- const failed = failures.get(name);
443
+ // Counted per name and source: a stranger who knows the name only locks themselves out, not the account (#5696).
444
+ const source = String(request.headers['cf-connecting-ip'] || request.socket.remoteAddress || 'unknown');
445
+ const failure_key = `${name}|${source}`;
446
+ const failed = failures.get(failure_key);
441
447
  if (failed && failed.until > now()) return send(response, 429, { 'Content-Type': 'text/html; charset=utf-8' }, login_page({ action: LOGIN_PATH, refusal: 'locked', name }));
442
448
  // One snapshot both checks the password and fixes the session to it: a reset made meanwhile by the panel leaves this
443
449
  // session on the old version, so it never grants access.
444
450
  const account = NAME_PATTERN.test(name) ? read_accounts(data)[name] : null;
445
451
  if (!password_matches(account, form.get('password'))) {
446
452
  const count = (failed?.count || 0) + 1;
447
- if (NAME_PATTERN.test(name)) failures.set(name, { count, until: count >= MAX_FAILURES ? now() + LOCK_MS : 0 });
453
+ if (NAME_PATTERN.test(name)) failures.set(failure_key, { count, until: count >= MAX_FAILURES ? now() + LOCK_MS : 0 });
448
454
  return send(response, 401, { 'Content-Type': 'text/html; charset=utf-8' }, login_page({ action: LOGIN_PATH, refusal: 'wrong', name }));
449
455
  }
450
- failures.delete(name);
456
+ failures.delete(failure_key);
451
457
  if (account.disabled) return send(response, 403, { 'Content-Type': 'text/html; charset=utf-8' }, login_page({ action: LOGIN_PATH, refusal: 'disabled', name }));
452
458
  const token = randomBytes(32).toString('hex');
453
459
  sessions.set(token_key(token), { name, expires: now() + SESSION_SECONDS * 1000, hash: account.hash, version: session_version(account) });
@@ -467,10 +473,12 @@ export function create_gateway({ data, now = Date.now }) {
467
473
  const account = account_of(request);
468
474
  if (await direct(request, response, Boolean(account))) return;
469
475
  // The site asks this to tell a page opened through the entry from one opened at the instance itself.
470
- if (path === SESSION_PATH && request.method === 'GET') return account ? send_json(response, 200, { signed_in: true }) : send_json(response, 401, { error: '请先登录' });
476
+ // It also names the account, so the site shows who is signed in when no display name was set (#5688).
477
+ if (path === SESSION_PATH && request.method === 'GET') return account ? send_json(response, 200, { signed_in: true, account: account.name }) : send_json(response, 401, { error: '请先登录', code: 'entry_login' });
471
478
  if (account) return forward(request, response, account.port, { protected: account.protected === true, key: account.protected === true ? instance_key(data, account.name) : '' });
472
479
  const page = request.method === 'GET' && String(request.headers.accept || '').includes('text/html');
473
- return page ? send(response, 302, { Location: LOGIN_PATH }) : send_json(response, 401, { error: '请先登录' });
480
+ // A page goes to the sign-in; the site's own requests are told so, and it goes there itself (#5688).
481
+ return page ? send(response, 302, { Location: LOGIN_PATH }) : send_json(response, 401, { error: '请先登录', code: 'entry_login' });
474
482
  }
475
483
 
476
484
  return http.createServer((request, response) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.4.93",
3
+ "version": "0.4.95",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -508,7 +508,7 @@ function window_state(pid, env = process.env) {
508
508
 
509
509
  /**
510
510
  * Follow a message posted into an open window through the session log, from `offset` on, until the turn that took it
511
- * ends (`system/turn_duration`) or the window closes: report the API error that turn ended on as a failure, otherwise its
511
+ * ends (`system/turn_duration`, or the window's registry staying idle after the turn's last assistant message) or the window closes: report the API error that turn ended on as a failure, otherwise its
512
512
  * end. For a room task it notes once when the window has not taken it by `unstarted_after`; an answer it never submitted
513
513
  * then fails the execution. Given a `log_path`, it reports the turn's steps there and its texts as notes. It waits past a
514
514
  * turn end while a background agent the turn launched has not reported. For a `chat` turn it waits also for every interjection `expect`ed, and fails with the reason when the window does not take the message in time,
@@ -524,7 +524,7 @@ export function watch_window_turn({ file, offset, pid, marker, session_id = '',
524
524
  stop_poll = STOP_POLL_MS, stop_tool_wait = STOP_TOOL_WAIT_MS, stop_end_wait = STOP_END_WAIT_MS } = options;
525
525
  const since = Date.now(), awaited = new Set([marker]), open_tools = new Set(), background = new Set();
526
526
  let pending = Buffer.alloc(0), taken = false, noted = false, error = null, done = false, waiting_since = 0;
527
- let stop_asked = 0, stop_sent = 0, stop_timer = null;
527
+ let stop_asked = 0, stop_sent = 0, stop_timer = null, last_message = null, idle_since = 0;
528
528
  // `ended` says why a room task's turn ended without finishing (interrupted, window closed): it is an exit, not a
529
529
  // failure to retry, and its last remark is not an answer.
530
530
  const finish = (reason = '', ended = '') => {
@@ -539,7 +539,8 @@ export function watch_window_turn({ file, offset, pid, marker, session_id = '',
539
539
  };
540
540
  const tick = () => {
541
541
  if (done) return;
542
- for (const entry of read_appended()) {
542
+ const entries = read_appended();
543
+ for (const entry of entries) {
543
544
  for (const item of awaited) if (takes(entry, item)) { awaited.delete(item); taken = true; }
544
545
  if (!taken) continue;
545
546
  if (entry.type === 'user' && INTERRUPTED.test(prompt_text(entry.message?.content).trim())) {
@@ -551,7 +552,21 @@ export function watch_window_turn({ file, offset, pid, marker, session_id = '',
551
552
  if (!entry.isSidechain) { track_tools(entry); track_background(entry); }
552
553
  // A turn that left a background agent running ends while the window waits for it; its report starts the next turn.
553
554
  if (entry.type === 'system' && entry.subtype === 'turn_duration' && !awaited.size && !background.size) return finish();
555
+ // Only the turn's own messages count: bookkeeping entries (hook summaries, queue operations) may be stamped later.
556
+ if (!entry.isSidechain && ['assistant', 'user'].includes(entry.type) && entry.message) {
557
+ last_message = { type: entry.type, at: Date.parse(entry.timestamp) || 0 };
558
+ }
554
559
  }
560
+ // Claude Code after 2.1.322 records no `turn_duration`: the window's registry (`status`, `updatedAt` in ms) going idle
561
+ // after the turn's last message ends it too. That message must be the assistant's (a tool result is always followed
562
+ // by one), an idle state older than it is the one before the window took the message, and the state must hold for
563
+ // one poll interval with nothing new in the log, so a message still being written or a brief idle state ends nothing.
564
+ // (Counted in time, not polls: a requested stop polls every `stop_poll`.)
565
+ const resting = taken && !awaited.size && !background.size && !open_tools.size && last_message?.type === 'assistant'
566
+ ? window_state(pid, env) : null;
567
+ const idle = resting?.status === 'idle' && last_message.at > 0 && resting.updatedAt >= last_message.at;
568
+ if (!idle || entries.length) idle_since = idle ? Date.now() : 0;
569
+ else if (Date.now() - idle_since >= interval) return finish();
555
570
  if (!process_alive(pid)) return chat ? finish('这位成员的 Claude 窗口在这轮私聊结束前关闭了') : finish('', '所在的原窗口在这一轮结束前关闭了');
556
571
  if (stop_asked) return try_stop();
557
572
  const elapsed = Date.now() - since;
@@ -653,6 +668,9 @@ export function watch_window_turn({ file, offset, pid, marker, session_id = '',
653
668
  clearInterval(stop_timer);
654
669
  stop_timer = null; stop_asked = 0; stop_sent = 0;
655
670
  if (log_path) task.on_output?.(log_path, `${JSON.stringify({ type: 'codiscuss.stop', sent: false, reason })}\n`);
671
+ // Nothing is left to stop in a window that sits idle with no tool running: the turn is over even when the log shows
672
+ // no end the watch knows (a later Claude Code may record turns differently), so the member is not held busy for good.
673
+ if (taken && !open_tools.size && window_state(pid, env)?.status === 'idle') finish('', '停止时原窗口已空闲');
656
674
  }
657
675
  return {
658
676
  get done() { return done; },