ai_co_discuss 0.5.15 → 0.5.16
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/working.md +3 -1
- package/docs/guide/working.md +3 -1
- package/frontend/locales/en/app.json +7 -1
- 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/expert_prompts.mjs +9 -0
- package/runner/free_runner.mjs +25 -3
- package/runner/site_deploy.mjs +18 -8
- package/web/i18n.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +51 -51
|
@@ -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/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/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
|
- **普通成员的 `@` 不派活**:普通成员互相 `@` 只是引用,不会唤醒对方;普通成员 `@` 主持人时,等房间里其他工作都结束后才唤醒主持人。
|
|
@@ -574,5 +574,11 @@
|
|
|
574
574
|
"排除后部署": "Deploy without them",
|
|
575
575
|
"部署": "Deploy",
|
|
576
576
|
"网站地址": "Website address",
|
|
577
|
-
"{time} 前有效,到期前可在左栏“已发布”或回答下方续期。": "Live until {time}; renew before then from “Published” in the sidebar or under the answer."
|
|
577
|
+
"{time} 前有效,到期前可在左栏“已发布”或回答下方续期。": "Live until {time}; renew before then from “Published” in the sidebar or under the answer.",
|
|
578
|
+
"已上线": "Live",
|
|
579
|
+
"尚未上线": "Not live yet",
|
|
580
|
+
"待部署": "Ready to deploy",
|
|
581
|
+
"{count} 个文件 · {size}": "{count} files · {size}",
|
|
582
|
+
"第 {version} 版 · {count} 个文件 · {size}": "Version {version} · {count} files · {size}",
|
|
583
|
+
"{time} 到期": "expires {time}"
|
|
578
584
|
}
|
|
@@ -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)
|
|
@@ -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/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
|
}
|
|
@@ -416,7 +424,9 @@ async function room_api_request(site, path, { method = 'GET', token = '', body =
|
|
|
416
424
|
const headers = { 'Accept-Language': 'zh-CN' };
|
|
417
425
|
if (token) headers['X-Discussion-Token'] = token;
|
|
418
426
|
if (body !== undefined) headers['Content-Type'] = 'application/json';
|
|
419
|
-
|
|
427
|
+
// A protected local site only accepts requests that pass the entry handshake (entry_client.mjs).
|
|
428
|
+
const send = fetcher === fetch ? site_fetch : fetcher;
|
|
429
|
+
const res = await send(`${site.replace(/\/+$/, '')}${path}`, {
|
|
420
430
|
method,
|
|
421
431
|
headers,
|
|
422
432
|
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|