ai_co_discuss 0.5.15 → 0.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/discuss-participant/SKILL.md +1 -1
- package/.agents/skills/discuss-session/references/host-closing.md +2 -1
- package/backend/mode_room.py +1 -1
- package/backend/session_room.py +20 -2
- package/docs/en/guide/rooms.md +1 -1
- package/docs/en/guide/working.md +3 -1
- package/docs/guide/rooms.md +1 -1
- package/docs/guide/working.md +3 -1
- package/frontend/locales/en/app.json +14 -3
- package/frontend/locales/en/backend.json +2 -0
- package/frontend/locales/en/room.json +4 -1
- package/package.json +1 -1
- package/runner/discuss.py +4 -1
- package/runner/discussion_launch.mjs +1 -1
- package/runner/expert_prompts.mjs +9 -0
- package/runner/free_runner.mjs +25 -3
- package/runner/i18n_en.mjs +4 -1
- package/runner/remote_policy.mjs +2 -1
- package/runner/site_deploy.mjs +35 -10
- package/web/admin.js +1 -1
- package/web/app.js +72 -10
- package/web/i18n.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +41 -41
|
@@ -52,7 +52,7 @@ description: "AI CoDiscuss 的通用参与技能,所有参与者(包括主
|
|
|
52
52
|
|
|
53
53
|
用请求者使用的语言回答,结论先行;篇幅与结构由你按问题决定。正文约 300 字以上或分多段时写摘要:给只听语音播报的人,约 15 秒念完(不超过约 80 字),用能直接念出口的话、不用列表和编号。
|
|
54
54
|
|
|
55
|
-
**给人看的成品默认作为附件交付**:这次新建或改出、请求者要看或要拿走的结果(文档、表格、幻灯片、PDF
|
|
55
|
+
**给人看的成品默认作为附件交付**:这次新建或改出、请求者要看或要拿走的结果(文档、表格、幻灯片、PDF、图片、音视频、放不进正文的大网页,或它们的打包;要在正文里直接运行的页面写成 `visual` 代码块,不另附),上传为附件,正文用 `[文件 #n]`(图片 `[图片 #n]`)引用(n 是该文件在本条 `--attachment` 中的先后序号,从 1 起,不是附件 ID;提交后程序换成房间内的统一编号);改了已交付的成品就附上新版。(附件随消息保存、卡片内直接预览,分享页、其他设备和外部成员都看得到;项目文件之后会变,也只有能读这台电脑的人看得到。)项目源码与配置的修改、中间产物和日志不附(执行卡片已显示文件差异)。用户说了只放项目里的也不附,正文用反引号写出它的项目路径(如 `合同.docx`),回答下方会出现该文件的卡片。
|
|
56
56
|
|
|
57
57
|
附件先 `attachment upload ROOM --file FILE --submission-id 上传编号`,再 `message post --attachment ID`(最多 10 个,单个 20 MiB,须在执行资格结束前上传)。
|
|
58
58
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
1. 保存有原文依据的最终判断、state 与简报(`until` 须覆盖实际读过的最新材料);需要留主持说明时按参与技能写入。主持说明本身不结束讨论。
|
|
15
15
|
2. `room conclusion ROOM` 申请收束状态,得到阻碍项 `blockers` 与 `revision`。
|
|
16
|
-
3. 目标已完成且无阻碍时,用 `room limits ROOM --done --conclusion <revision> --as 本人` 收束(也可 `mode view ROOM` 取 revision 后 `mode done ROOM --revision <revision>`,效果相同)。到限则用 `room limits ROOM --check --as 本人`。有未处理留言、state 落后或仍有排队安排会被拒绝;状态变化后 revision
|
|
16
|
+
3. 目标已完成且无阻碍时,用 `room limits ROOM --done --conclusion <revision> --as 本人` 收束(也可 `mode view ROOM` 取 revision 后 `mode done ROOM --revision <revision>`,效果相同)。到限则用 `room limits ROOM --check --as 本人`。有未处理留言、state 落后或仍有排队安排会被拒绝;状态变化后 revision 失效需重取。成功后讨论结束,本次执行随之完成,不再补 chat 回执。
|
|
17
|
+
4. 讨论期间用户交代了“讨论结束后”要做的事(派人实现、测试、写文档等)时,收束时加 `--continue "继续做什么"`:讨论结束、房间空闲后程序再唤醒你一次,届时按普通房间请求派活。不带它就没有人会再唤醒你,回过一句“收到”不算交接。
|
|
17
18
|
|
|
18
19
|
最终总结按议题组织结论、不同意见、重要条件与未验证影响,不强制固定栏目。用户要求独立报告时再调用仓库的 discuss-report,报告不表示建议已获采纳。
|
package/backend/mode_room.py
CHANGED
|
@@ -103,6 +103,6 @@ def finish_mode(connection, room_id, token, payload):
|
|
|
103
103
|
if mode["mode"] == "discussion":
|
|
104
104
|
if require_member(connection, room_id, token)["role"] != "host":
|
|
105
105
|
raise PermissionError(Text("只有主持人能宣告讨论完成"))
|
|
106
|
-
conclude_session_by_host(connection, room_id, {"conclusion": payload.get("revision")})
|
|
106
|
+
conclude_session_by_host(connection, room_id, {"conclusion": payload.get("revision"), "continue": payload.get("continue")})
|
|
107
107
|
return mode_view(connection, room_id)
|
|
108
108
|
raise FileExistsError(Text("房间没有进行中的 Goal 或讨论"))
|
package/backend/session_room.py
CHANGED
|
@@ -5,7 +5,8 @@ import json
|
|
|
5
5
|
import re
|
|
6
6
|
import time
|
|
7
7
|
|
|
8
|
-
from .free_room import active_members, finish_execution, member_display_names,
|
|
8
|
+
from .free_room import (MAX_CONTINUE_REASON, active_members, finish_execution, member_display_names, remember_continue, require_member,
|
|
9
|
+
require_owner, resume_host, wake_host)
|
|
9
10
|
from .texts import Text, load_texts, save_text, text_payload
|
|
10
11
|
from .runtime import begin_write, enforce_session_limits, limit_values, room_limits_view, token_hash
|
|
11
12
|
|
|
@@ -502,7 +503,24 @@ def conclude_session_by_host(connection, room_id, payload):
|
|
|
502
503
|
("pending_input", "state_outdated", "active_speakers"): Text("暂不能收束:有未处理的用户留言或设置变更;状态整理至 #{state_until},未覆盖最新发言 #{last_answer};先更新 state 与简报;仍有专家正在发言", state_until=state_until, last_answer=last_answer),
|
|
503
504
|
}
|
|
504
505
|
raise ValueError(errors[blockers])
|
|
505
|
-
|
|
506
|
+
reason = payload.get("continue")
|
|
507
|
+
if reason is not None and (not isinstance(reason, str) or not reason.strip() or len(reason) > MAX_CONTINUE_REASON):
|
|
508
|
+
raise ValueError(Text("continue 写明讨论结束后继续做什么,最多 {max_continue_reason} 字", max_continue_reason=MAX_CONTINUE_REASON))
|
|
509
|
+
host = connection.execute("SELECT * FROM room_members WHERE room_id=? AND role='host' AND status='active'", (room_id,)).fetchone()
|
|
510
|
+
turn = connection.execute("""SELECT r.message_id,r.chain_id FROM session_requests sr JOIN member_requests r ON r.id=sr.member_request_id
|
|
511
|
+
WHERE sr.session_id=? AND sr.purpose='discuss_host' AND sr.member_id=? AND sr.status='open' AND r.status='delivering'
|
|
512
|
+
ORDER BY r.id DESC LIMIT 1""", (session["id"], host["id"])).fetchone() if host else None
|
|
513
|
+
# The host ending the discussion is its own turn's result, not work the ending cancels: the turn completes, so the
|
|
514
|
+
# runner lets the software finish instead of stopping it as if the user had.
|
|
515
|
+
if host:
|
|
516
|
+
_complete_host_work(connection, session["id"], host["id"], Text("主持人已收束讨论"))
|
|
517
|
+
result = _conclude_session(connection, session, "goal_done")
|
|
518
|
+
if host and reason:
|
|
519
|
+
# Work the user left for after the discussion wakes the host once the room is idle, like a free-room `continue`.
|
|
520
|
+
message_id, chain_id = (turn["message_id"], turn["chain_id"]) if turn else (session["started_message_id"],) * 2
|
|
521
|
+
remember_continue(connection, room_id, host, message_id, chain_id, {"continue": reason})
|
|
522
|
+
resume_host(connection, room_id)
|
|
523
|
+
return result
|
|
506
524
|
|
|
507
525
|
|
|
508
526
|
def _host_interjections(connection, session_id):
|
package/docs/en/guide/rooms.md
CHANGED
|
@@ -59,7 +59,7 @@ You can also send a message from the blank home page to create a room and send i
|
|
|
59
59
|
|
|
60
60
|
Either way, readers see the room’s **Messages** and **Runs** views from the beginning, as they look here: cards and run details open; each time **Runs** is opened it replays the session from the start, and “End replay” returns to the final state. The other tabs, such as **Private**, **Room** and **Files**, are dimmed and show only a sample; but nothing can be sent or changed, and the page shows the room as it was when it was made. Private chats, the event log, scheduling decisions, refused actions, queued messages, paths on this computer, session IDs and credentials are left out, as are retracted or rewound messages; failure reasons read only “Run failed”, and the room’s project folders are rewritten in message text as paths inside the project. The rest of the message text is shared as written, so check it before sending.
|
|
61
61
|
|
|
62
|
-
Attachments are left out by default, and attachment tags in messages read “not included in the share”. When the room has attachments, the confirmation offers “Include attachments”: ticked, every attachment (images, videos, web pages, documents and so on) goes into the page as it is, for readers to view and download; project files a member’s answer delivered (the file cards under the answer) come along too, as attachments of that answer. Text attachments are checked for keys and local folders too; the contents of images, videos and other files cannot be checked, so look through them yourself. A share link carries the attachments the page can preview — images, audio, video, PDF, Word/Excel/PowerPoint (docx, xlsx, pptx), text and code, zip archives, and web pages — for readers to open right in the page; scripts that run on a double click, such as js, bat and ps1, go with .txt added to their names. Programs and old doc/xls/ppt files stay off the share site and their messages read “not included in the share”, while a downloaded web page file still carries them. Web page attachments run on the share page as they do in the room, and demos a member’s answer refers to show inside the message; they run in an isolated frame that cannot read the share page, send requests or submit forms. Attachments do not count toward the 5 MB of text: a share link uploads them one by one, up to
|
|
62
|
+
Attachments are left out by default, and attachment tags in messages read “not included in the share”. When the room has attachments, the confirmation offers “Include attachments”: ticked, every attachment (images, videos, web pages, documents and so on) goes into the page as it is, for readers to view and download; project files a member’s answer delivered (the file cards under the answer) come along too, as attachments of that answer. Text attachments are checked for keys and local folders too; the contents of images, videos and other files cannot be checked, so look through them yourself. A share link carries the attachments the page can preview — images, audio, video, PDF, Word/Excel/PowerPoint (docx, xlsx, pptx), text and code, zip archives, and web pages — for readers to open right in the page; scripts that run on a double click, such as js, bat and ps1, go with .txt added to their names. Programs and old doc/xls/ppt files stay off the share site and their messages read “not included in the share”, while a downloaded web page file still carries them. Web page attachments run on the share page as they do in the room, and demos a member’s answer refers to show inside the message; they run in an isolated frame that cannot read the share page, send requests or submit forms. Once ticked, the attachments are listed by kind (archives, video, audio, images, documents, web pages, text and code) with their count and size; untick a whole kind, or click “Choose files” to unfold it and tick files one by one (largest first), and its tags in messages read “not included in the share”. Attachments do not count toward the 5 MB of text: a share link uploads them one by one, up to 300 MB in all (100 MB per file), with the publish button showing the progress; above that, untick some attachments. A downloaded web page file carries at most 100 MB of attachments.
|
|
63
63
|
- **Import rooms.** In directory options or a folder menu, select “Import rooms” and choose a ZIP. Review the preview and confirm the rooms to import. A room marked “Already exists; skipped” is left as is. On the same computer, invite members back to resume their sessions. Claude Code members switch to manual connection on import. Re-register them from their original window to avoid splitting the session. Imported discussion history is kept, but discussions are not restarted and members are not woken automatically.
|
|
64
64
|
- **Branch from a message.** In an AI message menu, select “Branch from here” to create a room containing the history through that message. Connections that support session branching resume from the branched session in the new room. The original room is kept.
|
|
65
65
|
- **Let the host create rooms.** With “Create rooms” ticked in “Host permissions”, the host can move part of the work into a new room. Members use only software configured on this computer, with read-only project access by default and at most write. The project folder must be the original room’s folder or a folder inside it. Unless you name another host, the new room is hosted by the same expert as the original host. Each room gets a “Linked room” card; select “Open room” to go to the other one. The new room takes your default host permissions, except that it cannot create rooms. A room can create a limited number of rooms (3 by default, adjustable in “Host permissions”). The hosts of two linked rooms can speak in each other’s room; those messages are labelled “From host … of room "…"” and wake the other room like your own messages. There is no limit by default. To cap it, set “Linked-room message limit” under “Advanced settings” in the new-room form (it applies to every linked room on this computer); counting from your last message in either room, messages beyond it are refused until you send a message.
|
package/docs/en/guide/working.md
CHANGED
|
@@ -79,7 +79,7 @@ When a member needs you to make a decision, a question card appears above the co
|
|
|
79
79
|
|
|
80
80
|
### 7. Inspect a run and troubleshoot a room
|
|
81
81
|
|
|
82
|
-
- Open **Runs** in the tabs at the top of the room and select **Waterfall**. The timeline shows when each member started, how long it ran, and where it spent time waiting. Select a member's name for the run's status, start time, and duration. Select a segment to inspect the recorded details for that phase. Idle stretches longer than 5 minutes are collapsed into narrow bands in **Traces**; to review the whole process at its real length, switch to **Concurrency**: at the top, **Running on its own** is the share of the span with a member at work, and **No input needed** is the share of runs started by the host, a relay or a wake-up rather than by your message; one left-to-right axis with nothing collapsed, where the height above shows how many members were running at once (stacked by member color; point at a block for that run's details), idle stretches are labeled with their length, and tasks are shown as bands below. Select a task to view it in **Traces**. Zoom with Ctrl + wheel or the **− / +** buttons (pinch on phones and tablets), drag to pan when zoomed, and double-click to reset. **Traces** also supports pinch to zoom and sideways drag on phones and tablets. Select “Replay the session” at the top right to play the latest task back in order, with adjustable speed and a scrubber, and “End replay” to return to the current state; it also works while a member is still running, playing up to now. **Show earlier runs** keeps paging back to the room's first run, and **Show all** lists every run in the room at once.
|
|
82
|
+
- Open **Runs** in the tabs at the top of the room and select **Waterfall**. The timeline shows when each member started, how long it ran, and where it spent time waiting. Select a member's name for the run's status, start time, and duration. Select a segment to inspect the recorded details for that phase. Idle stretches longer than 5 minutes are collapsed into narrow bands in **Traces**; to review the whole process at its real length, switch to **Concurrency**: at the top, **Running on its own** is the share of the span with a member at work, and **No input needed** is the share of runs started by the host, a relay or a wake-up rather than by your message, and **Longest unattended** is the longest the AI kept going after one of your messages, until the room stopped or you wrote again; one left-to-right axis with nothing collapsed, where the height above shows how many members were running at once (stacked by member color; point at a block for that run's details), idle stretches are labeled with their length, and tasks are shown as bands below. Select a task to view it in **Traces**. Zoom with Ctrl + wheel or the **− / +** buttons (pinch on phones and tablets), drag to pan when zoomed, and double-click to reset. While zoomed in, a replay keeps the view on the playback line; dragging the view turns **Follow** off, and selecting **Follow** turns it back on. **Traces** also supports pinch to zoom and sideways drag on phones and tablets. Select “Replay the session” at the top right to play the latest task back in order, with adjustable speed and a scrubber, and “End replay” to return to the current state; it also works while a member is still running, playing up to now. **Show earlier runs** keeps paging back to the room's first run, and **Show all** lists every run in the room at once.
|
|
83
83
|
- To handle a permission denial, return to the conversation and expand the run report on its failure or reply card. **Allow and resend** appears when the report includes a rule that can be allowed, the local service is available, and the original request can be found. Review the rule before selecting it. The original message returns to the composer for you to confirm and send.
|
|
84
84
|
- If a member never woke up or an action was rejected, open **Runs → Events**. The **Event log** shows operations in time order, their outcomes, and the resulting state changes. Select a row to inspect its original record and related events. From a terminal on the local computer, run `codiscuss room events <ROOM_ID>` to read the same log.
|
|
85
85
|
|
|
@@ -93,6 +93,8 @@ A page a member delivers can go to a public address, `https://<id>.bimcanvas.com
|
|
|
93
93
|
|
|
94
94
|
To have a member put its work online directly, say “deploy” or “publish as a website” in your message; otherwise members only prepare it and upload nothing.
|
|
95
95
|
|
|
96
|
+
Addresses without an extension (such as `/about`) opened in a browser return the home page for the site's own front-end routing; missing files with an extension return 404. Reference assets with paths starting with `/`.
|
|
97
|
+
|
|
96
98
|
## Notes
|
|
97
99
|
|
|
98
100
|
- **A regular member’s `@` mention does not assign work.** When members mention one another, it is only a reference and does not wake the other member. When a regular member mentions the host, the host is woken after other room work finishes.
|
package/docs/guide/rooms.md
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
|
|
60
60
|
两种方式看到的都是这个房间的“消息”和“执行”两页,从头阅读,外观与本机一致,卡片和执行详情都能点开;每次进入“执行”都会从头自动回放协作过程,点“结束回放”回到最终状态。“私聊”“房间”“文件”等标签灰显,只展示示意。但不能发消息或做任何操作;内容停在生成那一刻。私聊、事件记录、调度决策、被拒操作、排队消息、本机路径、会话编号与凭据不会写进去,已撤回或回退的消息也不带;失败原因只写“执行失败”,房间项目目录在正文里改写成项目内的相对路径。消息正文其余部分原样公开,发出前请核对。
|
|
61
61
|
|
|
62
|
-
附件默认不带,消息里的附件标记显示为“未包含在分享中”。房间有附件时,确认框里有“包含附件”,勾选后所有附件(图片、视频、网页、文档等)原样放进分享页,读者可以查看和下载;成员回答里交付的项目文件(回答下方的文件卡片)也会作为该条回答的附件一起带上。文本类附件会一并检查疑似密钥和本机目录;图片、视频等文件的内容程序查不了,请自己核对。发布链接带上页面能预览的附件:图片、音视频、PDF、Word/Excel/PowerPoint(docx、xlsx、pptx)、文本与代码、zip 压缩包和网页,读者在分享页里直接打开;js、bat、ps1 等双击就会运行的脚本改名为 .txt 后带上。程序和旧版 doc/xls/ppt
|
|
62
|
+
附件默认不带,消息里的附件标记显示为“未包含在分享中”。房间有附件时,确认框里有“包含附件”,勾选后所有附件(图片、视频、网页、文档等)原样放进分享页,读者可以查看和下载;成员回答里交付的项目文件(回答下方的文件卡片)也会作为该条回答的附件一起带上。文本类附件会一并检查疑似密钥和本机目录;图片、视频等文件的内容程序查不了,请自己核对。发布链接带上页面能预览的附件:图片、音视频、PDF、Word/Excel/PowerPoint(docx、xlsx、pptx)、文本与代码、zip 压缩包和网页,读者在分享页里直接打开;js、bat、ps1 等双击就会运行的脚本改名为 .txt 后带上。程序和旧版 doc/xls/ppt 不放到分享站,消息里显示“未包含在分享中”,下载的网页文件仍会带上。网页附件在分享页里照常运行,成员回答里引用的演示直接显示在消息中;它在隔离的框架里运行,读不到分享页,也不能联网请求或提交表单。勾选后下方按类型(压缩包、视频、音频、图片、文档、网页、文本与代码)列出数量和大小,可取消整类,也可点“逐个选择”展开该类、按文件勾选(大的在前),取消的附件在消息里显示“未包含在分享中”。附件不计入文字的 5 MB,发布链接时逐个上传,合计最多 300 MB(单个最多 100 MB),发布按钮会显示上传进度;超过时取消勾选部分附件。网页文件最多带 100 MB 附件。
|
|
63
63
|
- **导入房间**:目录选项或文件夹菜单 → “导入房间”,选择 ZIP 文件,在预览中确认要导入的房间;标为“已存在,跳过”的房间会保留原样。在同一台电脑导入后,请回成员会续接原会话(Claude Code 成员会改为手动接入,请回后在原窗口重新注册,避免会话分叉)。导入保留历史讨论记录,不会自动继续原讨论或重新唤醒成员。
|
|
64
64
|
- **从某条消息分支**:AI 发言菜单 → “从这里分支”,新建一个保留截至该条发言记录的房间。支持会话分叉的接入方式会在新房间续接分叉后的会话;原房间保留。
|
|
65
65
|
- **让主持人新建房间**:在“主持人权限”里勾选“新建房间”后,主持人可以把一部分工作拆到新房间:成员只用本机已配置的软件,项目权限默认只读、最高可写,项目目录只能是原房间的目录或其子目录;你没指定时由与原主持人同款的专家主持。两个房间各留一张“关联房间”卡片,点“打开房间”互相跳转。新房间的主持人权限按你的默认设置,但不能再新建房间;一个房间可新建的数量有上限(默认 3 个,可在“主持人权限”里调整)。两个关联房间的主持人可以互相发言,这些消息标注“来自房间「…」的主持人 …”,按你的消息唤醒对方房间;默认不限条数;担心两边来回不停,可在新建房间面板“高级设置”里设“关联房间互传上限”(对本机所有关联房间生效),从你上次在任一房间发言算起超过这个条数会被拒绝,你发一条消息即可让它们继续。
|
package/docs/guide/working.md
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
|
|
80
80
|
### 7. 查看过程与排查
|
|
81
81
|
|
|
82
|
-
- 打开房间后,在左栏点“执行”,选“瀑布”查看执行时间线。横向时间条显示各成员何时开始、运行了多久、哪些时间花在等待上。点成员名字看这次执行的状态、开始时间和总时长;点时间条中的某一段可看该阶段已记录的细节。超过 5
|
|
82
|
+
- 打开房间后,在左栏点“执行”,选“瀑布”查看执行时间线。横向时间条显示各成员何时开始、运行了多久、哪些时间花在等待上。点成员名字看这次执行的状态、开始时间和总时长;点时间条中的某一段可看该阶段已记录的细节。超过 5 分钟的空闲在“执行轨迹”里折叠成窄带;要按真实时长回顾整个过程,切到“并发全景”:顶部先给出两个比例——“自动执行”是有成员在干活的时长占整段的比例,“无需介入”是不由你的消息触发、而由主持人派活、接力或程序唤醒自动接上的执行所占的比例,“最长无人值守”是从你的一条消息起、到房间停下或你再次发消息为止,AI 连续自动推进最久的一段;从左到右一条不折叠的时间轴,上方的高度是同一时刻有几位成员在执行(按成员颜色叠加,鼠标指向色块看那次执行的详情),空闲处标出时长,下方按任务分段,点某个任务在执行轨迹中查看。Ctrl + 滚轮或右上角“− / +”缩放(手机和平板上双指捏合),放大后拖动平移,双击还原;放大后回放时画面默认跟着回放线走,手动拖动画面会关闭“跟随”,再点它即可恢复;“执行轨迹”在手机和平板上同样可以双指缩放、放大后左右拖动;点右上角“回放协作过程”按时间顺序重放最近这次任务,可调速度或拖动进度,点“结束回放”回到当前状态;有成员还在执行时也能回放,放到现在为止。点“显示更早的执行”可一直往前翻到房间第一次执行,点“显示全部”一次列出房间的所有执行。
|
|
83
83
|
- 想处理权限拒绝,回到对话区,展开对应失败卡或回答卡的执行报告。只有记录了可放行的规则、本机服务可用且能找回原请求时,才显示“允许并重发”。核对规则再点它,原消息会回到输入框,确认后发送。
|
|
84
84
|
- 排查“为什么没唤醒”或“哪一步被拒绝”时,在顶部“执行”页切到“事件”。“事件记录”按时间列出房间收到的操作、处理结果和引起的状态变化。点一行看原始记录与同一对象的相关事件。本机终端也可运行 `codiscuss room events <房间ID>` 查看。
|
|
85
85
|
|
|
@@ -93,6 +93,8 @@
|
|
|
93
93
|
|
|
94
94
|
想让成员做完直接上线,在消息里明确说“部署”或“发布成网站”;没说时成员只准备、不上传。
|
|
95
95
|
|
|
96
|
+
网站里没有扩展名的地址(如 `/about`)在浏览器里打开时都返回首页,由网页自己的前端路由处理;带扩展名但不存在的文件返回 404。页面引用的资源请用以 `/` 开头的路径。
|
|
97
|
+
|
|
96
98
|
## 要注意什么
|
|
97
99
|
|
|
98
100
|
- **普通成员的 `@` 不派活**:普通成员互相 `@` 只是引用,不会唤醒对方;普通成员 `@` 主持人时,等房间里其他工作都结束后才唤醒主持人。
|
|
@@ -447,17 +447,22 @@
|
|
|
447
447
|
"附件原样公开。文本类附件已一并检查;图片、视频和其他文件的内容程序查不了,请自己核对。": "Attachments are published as they are. Text attachments were checked too; the contents of images, videos and other files cannot be checked, so look through them yourself.",
|
|
448
448
|
"不包含时,消息里的附件标记显示为“未包含在分享中”。": "Without them, attachment tags in messages read “not included in the share”.",
|
|
449
449
|
"正在检查文本类附件…": "Checking text attachments…",
|
|
450
|
+
"{kind} {count} 个 · {size}": "{kind} · {count} · {size}",
|
|
451
|
+
"已选 {size};发布链接最多带 300 MB 附件(单个 100 MB),网页文件最多 100 MB。": "{size} selected; a share link carries at most 300 MB of attachments (100 MB per file), and a web page file at most 100 MB.",
|
|
452
|
+
"文本与代码": "Text and code",
|
|
453
|
+
"逐个选择": "Choose files",
|
|
450
454
|
"附件读取失败({status})": "Could not read the attachment ({status})",
|
|
451
455
|
"附件 {name} 在发布期间有变化,请重新打开“分享为网页…”再发布": "The attachment {name} changed while publishing; open “Share as web page…” again and publish",
|
|
452
456
|
"附件 {name} 上传失败:{value1}": "Uploading the attachment {name} failed: {value1}",
|
|
453
|
-
"
|
|
457
|
+
"附件 {name} 有 {size},超过分享链接单个附件 100 MB 的上限;请取消勾选它。": "The attachment {name} is {size}, over the 100 MB per-file limit for share links; untick it.",
|
|
458
|
+
"附件合计 {size},超过分享链接 300 MB 的上限;请取消勾选部分附件。": "The attachments total {size}, more than the 300 MB a share link can carry; untick some attachments.",
|
|
454
459
|
"这个房间的文字整理后有 {size},超过分享链接 5 MB 的上限;请改用“下载网页文件”。": "The room’s text comes to {size} after cleaning, more than the 5 MB a share link can carry; use “Download web page file” instead.",
|
|
455
460
|
"链接已发布,但附件没有传完,读者会看到“附件读取失败”;可再点“更新链接”重传。{value1}": "The link is published, but not all attachments were sent, so readers will see “Could not read the attachment”; click “Update link” to send them again. {value1}",
|
|
456
461
|
"正在上传附件 {done}/{total}": "Uploading attachments {done}/{total}",
|
|
457
462
|
"{names} 不能放到分享站:发布链接时不带,消息里显示“未包含在分享中”;下载网页文件仍会带上。": "{names} cannot go on the share site: a published link leaves them out and their messages read “not included in the share”; a downloaded web page file still carries them.",
|
|
458
463
|
" 等 {count} 个": " and others, {count} in all",
|
|
459
464
|
"读取失败,没能检查,请自己核对": "Could not be read or checked; look through it yourself",
|
|
460
|
-
"附件共 {size},超过网页文件能带的 100 MB
|
|
465
|
+
"附件共 {size},超过网页文件能带的 100 MB;请取消勾选部分附件,或改用“发布链接”。": "The attachments total {size}, more than the 100 MB a page file can carry; untick some attachments or use “Publish link”.",
|
|
461
466
|
"这个房间连同附件整理后有 {size},超过分享链接 5 MB 的上限;请取消“包含附件”,或改用“下载网页文件”。": "This room with its attachments comes to {size}, over the 5 MB limit for share links; untick “Include attachments” or use “Download web page” instead.",
|
|
462
467
|
"#{id} 的附件 {name}": "Attachment {name} of #{id}",
|
|
463
468
|
"分享页面不包含这个附件": "This shared page does not include this attachment",
|
|
@@ -574,5 +579,11 @@
|
|
|
574
579
|
"排除后部署": "Deploy without them",
|
|
575
580
|
"部署": "Deploy",
|
|
576
581
|
"网站地址": "Website address",
|
|
577
|
-
"{time} 前有效,到期前可在左栏“已发布”或回答下方续期。": "Live until {time}; renew before then from “Published” in the sidebar or under the answer."
|
|
582
|
+
"{time} 前有效,到期前可在左栏“已发布”或回答下方续期。": "Live until {time}; renew before then from “Published” in the sidebar or under the answer.",
|
|
583
|
+
"已上线": "Live",
|
|
584
|
+
"尚未上线": "Not live yet",
|
|
585
|
+
"待部署": "Ready to deploy",
|
|
586
|
+
"{count} 个文件 · {size}": "{count} files · {size}",
|
|
587
|
+
"第 {version} 版 · {count} 个文件 · {size}": "Version {version} · {count} files · {size}",
|
|
588
|
+
"{time} 到期": "expires {time}"
|
|
578
589
|
}
|
|
@@ -552,6 +552,8 @@
|
|
|
552
552
|
"用户暂停讨论": "The user paused the discussion.",
|
|
553
553
|
"用户打断": "The user interrupted the execution.",
|
|
554
554
|
"讨论已结束": "The discussion ended.",
|
|
555
|
+
"主持人已收束讨论": "The host concluded the discussion.",
|
|
556
|
+
"continue 写明讨论结束后继续做什么,最多 {max_continue_reason} 字": "continue must describe what to do after the discussion ends, in up to {max_continue_reason} characters",
|
|
555
557
|
"用户取消讨论安排": "The user cancelled the discussion plan.",
|
|
556
558
|
"评审未投递:{reason}": "Review was not delivered: {reason}",
|
|
557
559
|
"专家 {name} 的讨论请求失败:{reason}。请决定跳过、重排或暂停。": "The discussion request for expert {name} failed: {reason}. Decide whether to skip, reorder, or pause.",
|
|
@@ -230,13 +230,16 @@
|
|
|
230
230
|
"自动执行 {value1}(占 {value2}%)": "Running on its own {value1} ({value2}%)",
|
|
231
231
|
"有成员在执行的时长占整个跨度的比例;其余是房间空闲、等你回应的时间": "Share of the span with at least one member running; the rest is the room idle, waiting for you",
|
|
232
232
|
"无需介入 {value1}/{value2} 次({value3}%)": "No input needed {value1}/{value2} runs ({value3}%)",
|
|
233
|
+
"最长无人值守 {value1}": "Longest unattended {value1}",
|
|
234
|
+
"跟随": "Follow",
|
|
235
|
+
"放大时让画面跟着回放线走": "Keep the view on the playback line while zoomed in",
|
|
236
|
+
"从你的一条消息起,到房间停下或你再次发消息为止,AI 连续自动推进最久的一段:{value1} – {value2}": "The longest the AI kept going on its own after one of your messages, until the room stopped or you wrote again: {value1} – {value2}",
|
|
233
237
|
"不是由你的消息触发、而是由主持人派活、接力、交回或程序唤醒自动接上的执行": "Runs started not by your message but by the host's dispatch, a relay, a hand-back or a wake-up",
|
|
234
238
|
"空闲 {value1}": "Idle {value1}",
|
|
235
239
|
"{value1} · 用时 {value2}": "{value1} · took {value2}",
|
|
236
240
|
"上方高度为同时在执行的成员数,指向色块看那次执行的详情;下方为任务分段,点任务在执行轨迹中查看": "Height shows how many members were running at once; point at a block for that run's details. Bands below are tasks; select one to view it in Traces.",
|
|
237
241
|
"显示更早的执行": "Show earlier runs",
|
|
238
242
|
"显示全部": "Show all",
|
|
239
|
-
"回放最近这次任务": "Replay the latest task",
|
|
240
243
|
"暂停回放": "Pause replay",
|
|
241
244
|
"从头回放": "Replay from start",
|
|
242
245
|
"回放速度": "Replay speed",
|
package/package.json
CHANGED
package/runner/discuss.py
CHANGED
|
@@ -336,6 +336,8 @@ def room_commands(subcommands, registry):
|
|
|
336
336
|
limits.add_argument("--check", action="store_true")
|
|
337
337
|
limits.add_argument("--done", action="store_true", help="主持人宣告目标已完成:结束讨论,房间照常协作;须带 --conclusion")
|
|
338
338
|
limits.add_argument("--conclusion", help="room conclusion 返回的 revision;--done 必填")
|
|
339
|
+
limits.add_argument("--continue", dest="continue_reason", metavar="REASON",
|
|
340
|
+
help="与 --done 同用:讨论期间用户留下了收束后要做的事时,写明继续做什么(≤300 字);讨论结束、房间空闲后再唤醒主持人一次")
|
|
339
341
|
create = add_leaf(subcommands, registry, "room create", "创建话题;不自动启动讨论或监控")
|
|
340
342
|
create.add_argument("--folder-id", help="直接在指定文件夹中创建;省略则未归类")
|
|
341
343
|
add_topic(create, create=True)
|
|
@@ -803,7 +805,8 @@ def plan_room(args):
|
|
|
803
805
|
if args.action == "limits":
|
|
804
806
|
if args.done:
|
|
805
807
|
return RequestPlan(base + "/limits", "POST", {"actor": require_actor(args), "action": "done",
|
|
806
|
-
**({"conclusion": args.conclusion} if args.conclusion else {})
|
|
808
|
+
**({"conclusion": args.conclusion} if args.conclusion else {}),
|
|
809
|
+
**({"continue": args.continue_reason} if args.continue_reason else {})}, "overview")
|
|
807
810
|
return RequestPlan(base + "/limits", "POST", {"actor": require_actor(args), "action": "check"}, "overview") if args.check else RequestPlan(base + "/limits")
|
|
808
811
|
if args.action == "update":
|
|
809
812
|
payload = topic_payload(args)
|
|
@@ -484,7 +484,7 @@ export function browse_sessions(raw, { accept = null, list = software_sessions,
|
|
|
484
484
|
if (!adapter_of(input.adapter)) throw new Error(`适配器只能为 ${ADAPTER_IDS.join('/')}`);
|
|
485
485
|
if (input.action === 'preview') {
|
|
486
486
|
const result = preview(input.adapter, input.session_id);
|
|
487
|
-
if (accept && !accept(result.cwd)) throw new Error('
|
|
487
|
+
if (accept && !accept(result.cwd)) throw new Error(t('出于安全考虑,其他设备只能查看这台电脑“常用项目”目录里的会话,「{path}」不在其中。请回到这台电脑上打开共议网页,在“新建房间”的项目目录里填入这个路径并点“加入常用项目”,之后再试。', { path: result.cwd || '' }));
|
|
488
488
|
return { adapter: input.adapter, ...result };
|
|
489
489
|
}
|
|
490
490
|
if (input.action !== undefined && input.action !== 'list') throw new Error('action 只能为 list 或 preview');
|
|
@@ -96,6 +96,15 @@ const REFUSED_COMMAND_SHOWN = 200;
|
|
|
96
96
|
export const correctable_refusals = denials => (denials || []).filter(item => item.retry_hint)
|
|
97
97
|
.map(item => ({ command: String(item.detail || '').slice(0, REFUSED_COMMAND_SHOWN), hint: item.retry_hint }));
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* What a member hears when the program resumes its session after this computer's room service restarted (an update,
|
|
101
|
+
* a crash) and ended its turn midway: the same execution goes on, checking the workspace before redoing anything.
|
|
102
|
+
*/
|
|
103
|
+
export function restart_resume_prompt(execution_id) {
|
|
104
|
+
return `你正在做的这次房间任务(执行 #${execution_id},仍在进行)被本机服务重启打断,上一轮在中途结束,回答还没有提交。`
|
|
105
|
+
+ '先核对工作区与上一轮最后在做的操作(中途被打断的命令可能只执行了一部分),已经做完的部分不必重做,接着完成原任务,最后照常提交这次执行的回答。';
|
|
106
|
+
}
|
|
107
|
+
|
|
99
108
|
/**
|
|
100
109
|
* What a member hears when the program resumes its session after refused commands: every refusal so far in this
|
|
101
110
|
* execution, oldest first, each with what to change, and how many corrections are left.
|
package/runner/free_runner.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { adapter_of, BRANCHABLE_ADAPTERS, branch_session, capabilities_of, chose
|
|
|
7
7
|
import { api as raw_api, overlapping_directories, read_rule } from './discussion_runner.mjs';
|
|
8
8
|
import { SegmentLog } from './execution_progress.mjs';
|
|
9
9
|
import { capture_base, file_diffs } from './file_diff.mjs';
|
|
10
|
-
import { correctable_refusals, free_task_text, MAX_REFUSAL_RETRIES, refusal_retry_prompt, TASK_SUBCOMMANDS, with_expert_prompt } from './expert_prompts.mjs';
|
|
10
|
+
import { correctable_refusals, free_task_text, MAX_REFUSAL_RETRIES, refusal_retry_prompt, restart_resume_prompt, TASK_SUBCOMMANDS, with_expert_prompt } from './expert_prompts.mjs';
|
|
11
11
|
import { entry_access, site_fetch } from './entry_client.mjs';
|
|
12
12
|
import { atomic_json } from './files.mjs';
|
|
13
13
|
import { image_settings } from './image_service.mjs';
|
|
@@ -1551,7 +1551,10 @@ export class FreeRoomRunner {
|
|
|
1551
1551
|
if (Number.isInteger(pid) && !pids.includes(pid)) pids.push(pid);
|
|
1552
1552
|
this.store.db.prepare('INSERT OR REPLACE INTO metadata VALUES (?,?)').run(key, JSON.stringify({ instance: this.instance, pids }));
|
|
1553
1553
|
}
|
|
1554
|
-
|
|
1554
|
+
/** Drop the records an ended execution leaves: its process owners and whether a restart already resumed it. */
|
|
1555
|
+
forget_owner(execution_id) {
|
|
1556
|
+
this.store.db.prepare('DELETE FROM metadata WHERE key IN (?,?)').run(`owner:${execution_id}`, `restart-resumed:${execution_id}`);
|
|
1557
|
+
}
|
|
1555
1558
|
/** Once a new task received the stop reminders, retire acknowledged unconfirmed reports for its old turns. */
|
|
1556
1559
|
clear_stopped(name) {
|
|
1557
1560
|
for (const id of this.stopped_executions(name)) {
|
|
@@ -1643,7 +1646,10 @@ export class FreeRoomRunner {
|
|
|
1643
1646
|
catch (error) { if (!/HTTP (404|409)/.test(error.message)) throw error; }
|
|
1644
1647
|
}
|
|
1645
1648
|
}
|
|
1646
|
-
/**
|
|
1649
|
+
/**
|
|
1650
|
+
* Check the website before reading local evidence. Recovery never sends the task again or schedules a retry; a turn
|
|
1651
|
+
* that did not end on its own may only go on in its session (resume_after_restart).
|
|
1652
|
+
*/
|
|
1647
1653
|
async recover_orphan(member, row, execution) {
|
|
1648
1654
|
const latest = await api(this.config, `/executions/${execution.id}`);
|
|
1649
1655
|
if (!['dispatched', 'started'].includes(latest.status)) {
|
|
@@ -1667,8 +1673,24 @@ export class FreeRoomRunner {
|
|
|
1667
1673
|
}
|
|
1668
1674
|
return this.fail(member.name, execution.id, room_text("{value1} 会话已结束,但未提交本次回答;请核对原会话确认是否已有内容", { value1: member.name }));
|
|
1669
1675
|
}
|
|
1676
|
+
if (!row.error && result.status !== 'failed' && await this.resume_after_restart(member, latest)) return;
|
|
1670
1677
|
return this.fail(member.name, execution.id, RESTART_REASON);
|
|
1671
1678
|
}
|
|
1679
|
+
/**
|
|
1680
|
+
* A turn a restart ended midway goes on once in its own session, told to check the workspace first, instead of
|
|
1681
|
+
* failing (user 2026-11-23, #8366); the task is never sent again whole, since part of it may already have run.
|
|
1682
|
+
* Only software that can resume a session, and only a member already bound to one.
|
|
1683
|
+
*/
|
|
1684
|
+
async resume_after_restart(member, execution) {
|
|
1685
|
+
const key = `restart-resumed:${execution.id}`;
|
|
1686
|
+
if (!capabilities_of(this.config.participants[member.name]?.adapter).resume || !this.store.binding(member.name).session_id
|
|
1687
|
+
|| this.store.db.prepare('SELECT value FROM metadata WHERE key=?').get(key)) return false;
|
|
1688
|
+
this.store.db.prepare('INSERT OR REPLACE INTO metadata VALUES (?,?)').run(key, '1');
|
|
1689
|
+
this.store.db.prepare('DELETE FROM metadata WHERE key=?').run(`retry-reason:${execution.id}`);
|
|
1690
|
+
this.save(member.name, { status: 'delivering', error: '' });
|
|
1691
|
+
await this.invoke(member, execution, { resume: restart_resume_prompt(execution.id) });
|
|
1692
|
+
return true;
|
|
1693
|
+
}
|
|
1672
1694
|
/** Retry only deliveries known not to have started, or a manual member's refused delivery. */
|
|
1673
1695
|
async retry_or_fail(name, execution, reason) {
|
|
1674
1696
|
const attempt = (execution.retry?.attempt || 0) + 1;
|
package/runner/i18n_en.mjs
CHANGED
|
@@ -29,6 +29,7 @@ export default {
|
|
|
29
29
|
"正在连接 {host}。": "Connecting to {host}.",
|
|
30
30
|
"心跳超过 {seconds} 秒未回应": "no heartbeat response for {seconds} seconds",
|
|
31
31
|
"连接已断开,关闭代码 {code}": "connection closed with code {code}",
|
|
32
|
+
"请求 {address} 失败({code})": "Request to {address} failed ({code})",
|
|
32
33
|
"连接被重置,请检查本机网络或代理": "connection reset; check this computer’s network or proxy",
|
|
33
34
|
"连接超时,请检查本机网络或代理": "connection timed out; check this computer’s network or proxy",
|
|
34
35
|
"无法解析网站域名": "website hostname could not be resolved",
|
|
@@ -605,5 +606,7 @@ export default {
|
|
|
605
606
|
"本机尚未注册发布身份,无法操作该站点": "This computer has not registered a publishing identity yet and cannot manage this site",
|
|
606
607
|
"未知的站点命令:{command}": "Unknown site command: {command}",
|
|
607
608
|
"AI CoDiscuss 网站部署\n\n注意:发布到公网须有用户在本房间的明确授权;未经用户明确要求发布时,仅使用 stage 在本机预检登记。\n\n用法:\n codiscuss site stage (--dir 目录 | --file 文件.html) [--room 房间] [--title 标题] [--exclude 路径]\n codiscuss site publish (--dir 目录 | --file 文件.html | --stage 编号) [--site 站点编号] [--room 房间] [--title 标题] [--exclude 路径]\n codiscuss site list [--room 房间]\n codiscuss site renew <站点编号> [--room 房间]\n codiscuss site rollback <站点编号> [--version 版本号] [--room 房间]\n codiscuss site revoke <站点编号> [--room 房间]\n\n选项:\n --access-file FILE 任务凭据文件(默认读取 DISCUSS_ACCESS_FILE)\n --room ROOM 房间编号(凭据绑定时自动补齐)\n --url SITE 本机/房间网站地址(凭据绑定时自动补齐)\n --dir PATH 要发布的本机构建目录\n --file PATH 要发布的单个 HTML 文件\n --stage ID 对已预检的待部署编号执行发布\n --site ID 更新已有 10 位站点编号\n --title TEXT 站点标题\n --exclude PATH 排除的相对文件路径(可重复传多次)\n --version N 回滚目标版本号(省略则回滚到上一版)\n --json 以 JSON 输出(默认)\n -h, --help 显示帮助\n": "AI CoDiscuss Website Deployment\n\nNotice: publishing to the public internet requires explicit user authorization in this room; without it, only run `stage` for local preflight.\n\nUsage:\n codiscuss site stage (--dir DIR | --file FILE.html) [--room ROOM] [--title TITLE] [--exclude PATH]\n codiscuss site publish (--dir DIR | --file FILE.html | --stage ID) [--site SITE_ID] [--room ROOM] [--title TITLE] [--exclude PATH]\n codiscuss site list [--room ROOM]\n codiscuss site renew <SITE_ID> [--room ROOM]\n codiscuss site rollback <SITE_ID> [--version N] [--room ROOM]\n codiscuss site revoke <SITE_ID> [--room ROOM]\n\nOptions:\n --access-file FILE Task credential file (defaults to DISCUSS_ACCESS_FILE)\n --room ROOM Room ID (auto-filled when bound by credential)\n --url SITE Local/room site URL (auto-filled when bound by credential)\n --dir PATH Local build directory to deploy\n --file PATH Single HTML file to deploy\n --stage ID Publish a previously staged record\n --site ID Update an existing 10-character site ID\n --title TEXT Site title\n --exclude PATH Relative file path to exclude (repeatable)\n --version N Target version for rollback (defaults to previous version)\n --json Output JSON (default)\n -h, --help Show help\n",
|
|
608
|
-
"未知子命令:{sub};运行 codiscuss site --help 查看用法": "Unknown subcommand: {sub}; run `codiscuss site --help` for usage"
|
|
609
|
+
"未知子命令:{sub};运行 codiscuss site --help 查看用法": "Unknown subcommand: {sub}; run `codiscuss site --help` for usage",
|
|
610
|
+
"出于安全考虑,手机、平板等其他设备只能使用这台电脑“常用项目”里的目录,「{path}」不在其中,所以没有执行。请回到这台电脑上打开共议网页:在“新建房间”的项目目录里填入这个路径,点路径右侧的“加入常用项目”,之后其他设备就能直接选它;也可以加入它的上级目录。": "For security, phones, tablets and other devices can only use folders in this computer's “Saved projects”, and “{path}” is not one of them, so nothing was done. On this computer, open CoDiscuss, enter this path as the project folder under “New room”, then click “Add to saved projects” next to it; other devices can then pick it. You can also add a parent folder.",
|
|
611
|
+
"出于安全考虑,其他设备只能查看这台电脑“常用项目”目录里的会话,「{path}」不在其中。请回到这台电脑上打开共议网页,在“新建房间”的项目目录里填入这个路径并点“加入常用项目”,之后再试。": "For security, other devices can only view sessions in this computer's “Saved projects” folders, and “{path}” is not one of them. On this computer, open CoDiscuss, enter this path as the project folder under “New room”, click “Add to saved projects”, then try again.",
|
|
609
612
|
};
|
package/runner/remote_policy.mjs
CHANGED
|
@@ -56,7 +56,8 @@ export function remote_roots(projects) {
|
|
|
56
56
|
* service's own directory. Returns the real path.
|
|
57
57
|
*/
|
|
58
58
|
export function remote_directory(path, { roots, home }) {
|
|
59
|
-
|
|
59
|
+
// Say why and exactly how to allow it: the device asking cannot change the list itself (Design_远程访问安全.md).
|
|
60
|
+
const refused = new Error(t('出于安全考虑,手机、平板等其他设备只能使用这台电脑“常用项目”里的目录,「{path}」不在其中,所以没有执行。请回到这台电脑上打开共议网页:在“新建房间”的项目目录里填入这个路径,点路径右侧的“加入常用项目”,之后其他设备就能直接选它;也可以加入它的上级目录。', { path: typeof path === 'string' ? path : '' }));
|
|
60
61
|
if (!plain_absolute(path)) throw refused;
|
|
61
62
|
let real;
|
|
62
63
|
try { real = realpathSync(path); } catch { throw refused; }
|
package/runner/site_deploy.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { basename, extname, isAbsolute, join, relative, resolve } from 'node:pat
|
|
|
8
8
|
import { parseArgs } from 'node:util';
|
|
9
9
|
|
|
10
10
|
import { configuration_snapshot, read_registry, service_home } from './discussion_service.mjs';
|
|
11
|
+
import { site_fetch } from './entry_client.mjs';
|
|
11
12
|
import { atomic_json } from './files.mjs';
|
|
12
13
|
import { t } from './i18n.mjs';
|
|
13
14
|
|
|
@@ -196,6 +197,11 @@ function find_room_config(home, room_id, site = '') {
|
|
|
196
197
|
return null;
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
// Launch configs store the room's project directory as `cwd` (see adapters/common.mjs project_directory).
|
|
201
|
+
function room_project_directory(config) {
|
|
202
|
+
return config?.cwd || config?.workdir || '';
|
|
203
|
+
}
|
|
204
|
+
|
|
199
205
|
function room_allowed_roots(config, home) {
|
|
200
206
|
const roots = [];
|
|
201
207
|
const add = (dir) => {
|
|
@@ -206,9 +212,9 @@ function room_allowed_roots(config, home) {
|
|
|
206
212
|
} catch { /* ignore missing dir */ }
|
|
207
213
|
};
|
|
208
214
|
if (config) {
|
|
209
|
-
add(config
|
|
215
|
+
add(room_project_directory(config));
|
|
210
216
|
for (const extra of config.extra_directories || []) add(extra);
|
|
211
|
-
|
|
217
|
+
// Not `config.directory`: that is the launch's runtime folder, holding task files and member credentials.
|
|
212
218
|
}
|
|
213
219
|
// Draft directory for member-generated HTML files
|
|
214
220
|
add(join(home, 'drafts'));
|
|
@@ -226,8 +232,8 @@ function resolve_target_path(home, config, input) {
|
|
|
226
232
|
candidate = resolve(raw);
|
|
227
233
|
} else if (config) {
|
|
228
234
|
const root_index = Number.isInteger(input.root) ? input.root : 0;
|
|
229
|
-
const base_dir = (root_index === 0 ? config
|
|
230
|
-
|| config
|
|
235
|
+
const base_dir = (root_index === 0 ? room_project_directory(config) : (config.extra_directories || [])[root_index - 1])
|
|
236
|
+
|| room_project_directory(config);
|
|
231
237
|
if (!base_dir) {
|
|
232
238
|
throw new SiteCommandError(t('房间未设置项目目录,无法解析相对路径'), { code: 'invalid_path', http_status: 400 });
|
|
233
239
|
}
|
|
@@ -246,7 +252,9 @@ function resolve_target_path(home, config, input) {
|
|
|
246
252
|
// Enforce room directory boundary when a room config is present (and verify member read permission).
|
|
247
253
|
if (config) {
|
|
248
254
|
if (input.member) {
|
|
249
|
-
|
|
255
|
+
// `participants` is an object keyed by member name in launch configs.
|
|
256
|
+
const member_cfg = Object.entries(config.participants || {})
|
|
257
|
+
.find(([name, p]) => name === input.member || p?.label === input.member)?.[1];
|
|
250
258
|
if (member_cfg && member_cfg.project_access === 'none') {
|
|
251
259
|
throw new SiteCommandError(t('成员 {member} 无权读取该项目目录', { member: input.member }), { code: 'auth', http_status: 403 });
|
|
252
260
|
}
|
|
@@ -259,9 +267,9 @@ function resolve_target_path(home, config, input) {
|
|
|
259
267
|
const stat = statSync(real_target);
|
|
260
268
|
const kind = stat.isDirectory() ? 'directory' : 'file';
|
|
261
269
|
let display_dir = basename(real_target);
|
|
262
|
-
if (config
|
|
270
|
+
if (room_project_directory(config)) {
|
|
263
271
|
try {
|
|
264
|
-
const real_project = realpathSync(config
|
|
272
|
+
const real_project = realpathSync(room_project_directory(config));
|
|
265
273
|
if (inside_directory(real_project, real_target)) {
|
|
266
274
|
display_dir = relative(real_project, real_target).replaceAll('\\', '/') || '.';
|
|
267
275
|
}
|
|
@@ -362,6 +370,21 @@ export function scan_site_source(real_target, kind, exclude = []) {
|
|
|
362
370
|
};
|
|
363
371
|
}
|
|
364
372
|
|
|
373
|
+
/** Annotate transport failures without exposing credentials or query parameters. */
|
|
374
|
+
async function deployment_fetch(fetcher, url, init) {
|
|
375
|
+
try {
|
|
376
|
+
return await fetcher(url, init);
|
|
377
|
+
} catch (error) {
|
|
378
|
+
const target = new URL(url);
|
|
379
|
+
const address = target.origin + target.pathname;
|
|
380
|
+
const code = error.cause?.code || error.cause?.errors?.find(item => item.code)?.code || error.code;
|
|
381
|
+
if (!code && error.message !== 'fetch failed') throw error;
|
|
382
|
+
throw new SiteCommandError(t('请求 {address} 失败({code})', { address, code: code || 'NETWORK_ERROR' }), {
|
|
383
|
+
code: 'network_error', http_status: 503,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
365
388
|
/** Keep private device_token exclusively inside `~/.codiscuss/site-devices.json` (mode 0600). */
|
|
366
389
|
async function ensure_device_identity(home, origin, fetcher = fetch) {
|
|
367
390
|
mkdirSync(home, { recursive: true, mode: 0o700 });
|
|
@@ -370,7 +393,7 @@ async function ensure_device_identity(home, origin, fetcher = fetch) {
|
|
|
370
393
|
if (store[origin]?.device_id && store[origin]?.device_token) {
|
|
371
394
|
return store[origin];
|
|
372
395
|
}
|
|
373
|
-
const res = await fetcher
|
|
396
|
+
const res = await deployment_fetch(fetcher, `${origin}/api/devices`, {
|
|
374
397
|
method: 'POST',
|
|
375
398
|
headers: { 'Content-Type': 'application/json', 'Accept-Language': 'zh-CN' },
|
|
376
399
|
body: '{}',
|
|
@@ -416,7 +439,9 @@ async function room_api_request(site, path, { method = 'GET', token = '', body =
|
|
|
416
439
|
const headers = { 'Accept-Language': 'zh-CN' };
|
|
417
440
|
if (token) headers['X-Discussion-Token'] = token;
|
|
418
441
|
if (body !== undefined) headers['Content-Type'] = 'application/json';
|
|
419
|
-
|
|
442
|
+
// A protected local site only accepts requests that pass the entry handshake (entry_client.mjs).
|
|
443
|
+
const send = fetcher === fetch ? site_fetch : fetcher;
|
|
444
|
+
const res = await deployment_fetch(send, `${site.replace(/\/+$/, '')}${path}`, {
|
|
420
445
|
method,
|
|
421
446
|
headers,
|
|
422
447
|
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
@@ -436,7 +461,7 @@ async function worker_api(origin, path, { method = 'GET', token = '', body = und
|
|
|
436
461
|
} else if (body !== undefined) {
|
|
437
462
|
headers['Content-Type'] = 'application/json';
|
|
438
463
|
}
|
|
439
|
-
const res = await fetcher
|
|
464
|
+
const res = await deployment_fetch(fetcher, `${origin}${path}`, {
|
|
440
465
|
method,
|
|
441
466
|
headers,
|
|
442
467
|
...(raw_body !== undefined ? { body: raw_body } : body !== undefined ? { body: JSON.stringify(body) } : {}),
|