ai_co_discuss 0.4.32 → 0.4.33
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-host/references/room.md +1 -0
- package/.agents/skills/discuss-participant/SKILL.md +1 -1
- package/backend/free_room.py +63 -4
- package/backend/schema.sql +6 -0
- package/backend/server.py +3 -3
- package/package.json +1 -1
- package/runner/discuss.py +7 -0
- package/runner/free_runner.mjs +53 -13
- package/web/admin.js +1 -1
- package/web/modern.css +1 -1
- package/web/modern.js +41 -41
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
- 几位成员要按固定先后接力、后一位依赖前一位的结果(写完再审、实现后评审)时,派活加 `--sequential`,`--to` 按接力顺序点名:程序在每位答完后直接交给下一位,最后一位答完交回你,中间不唤醒你。走完一圈算一轮(中间各棒不另计)。派活正文要把每一棒做什么、按什么标准交给下一棒写清楚,后面的成员靠它和前一棒的回答工作。
|
|
27
27
|
- 某一棒有几位互不依赖、可以同时做的成员(如几位评审各审一类问题)时,把他们写成同一棒:第一位用 `--to`,其余紧跟着用 `--with`(如 `--to 写手 --to 评审甲 --with 评审乙 --sequential --loop`)。这一棒的成员同时开工,全部结束才交下一棒,下一棒能读到他们每一份回答;组里有人失败,接力停下交回你,用户重试失败的那位后接着走。并行的成员看不到彼此的意见,派活正文要分清各自管什么。
|
|
28
28
|
- 派活时想让某位成员同时开工、但不必等它(如评审期间让记录员先整理别的材料),加 `--detach 成员`(可重复,不能与 `--to` 重名):它和这次派活一起开工,交回你或交下一棒都不等它;它做完不交回你,结果在房间里可读;失败时程序通知你。用在依次接力上时,它只随第一棒开工一次。撤回这次派活会一并撤回它。
|
|
29
|
+
- 派活后自己还要接着做、不等派出的成员(如让一位成员后台复核,自己继续改代码)时,派活加 `--keep-working`(API 不提供):这条回答收为派活卡,本轮不要结束,直接接着工作,房间会为后续工作另起一张卡;做完照常用本次凭据 `message post` 回答(可再派活)。派出的工作结束时以一条通知交回你,在你这次回答之后送达。不要先回答“我接着做”再结束本轮——那样后面的工作在房间里看不到。不能与 `--continue`、`--sequential`、`--next-review` 同用。
|
|
29
30
|
- 要“改完再审、审到通过为止”时再加 `--loop`:每走完一圈,交回你的 `handoff` 带 `sequence.phase: checkpoint`。本圈最后一位(最后一棒是同时做的一组时,其中任一位)明确要求返工时,用 `sequence continue ROOM --request 该交接请求编号 --as 本人` 开始下一圈(程序直接接着走,你本次即结束);认可、只剩可不采纳的建议、需要你或用户裁定时,不继续,直接验收或说明。开启智能调度时,它会先替你判断检查点,只有明确返工才自动开始下一圈,其余仍交给你;任务的 `scheduler_suggestions` 记着它的判断。`sequence view ROOM ID` 可读本圈各棒原文。每开始新的一圈算一轮,轮数用尽时循环停下,由用户决定是否继续。
|
|
30
31
|
- 要在接力中途停下来由你把关(验收一稿再交下一位),或只让中间一段循环(写 ⇄ 审到通过再交记录员)时,用检查点,均须与 `--sequential` 同用:`--checkpoint 成员` 在该成员那一棒结束后交回你(`sequence.phase: gate`);`--repeat 成员=起点成员` 在该成员那一棒结束后交回你,作为循环检查点(`sequence.phase: checkpoint`),再来一圈从起点成员那一棒开始,起点不能早于前一个检查点。交回时 `sequence.gate` 给出 `repeat_from`(再来一圈从第几棒开始)与 `can_proceed`(后面还有棒)。处理:要返工就 `sequence continue … --request 交接请求编号`(循环检查点再来一圈);认可并往下走就 `sequence continue … --proceed`(普通检查点不加 `--proceed` 也是往下走);要结束接力、裁定或说明时不继续,直接回答。往下走和再来一圈各算一轮。带检查点的接力不能在右栏调整顺序。
|
|
31
32
|
- 用户要作为接力中的一棒亲自参与(如跑团时用户扮演一位玩家、写作时用户当一位审稿人)时,用 `--wait-user 成员`(或 `成员=起点成员`,与 `--sequential` 同用):该成员那一棒结束后接力停下等用户,不交回你;用户下一条未点名任何人的消息直接接着往下一棒走(写了起点就从起点那一棒再来一圈),这条消息交给下一棒先读,并从它起算新任务链。用户点名某人的消息不影响等待;停止全部或撤回这次派活会结束等待。最后一棒之后等用户须写起点。在派活正文里告诉用户轮到他时要做什么。
|
|
@@ -28,7 +28,7 @@ description: "AI CoDiscuss 的通用参与技能,所有参与者(包括主
|
|
|
28
28
|
2. **执行失效后不再写入**:暂停、到期或被打断的旧任务保留草稿并结束,不换身份、职责或编号绕过拒绝,也不去掉 `--execution` 改作普通发言。只被本机服务判为失败(未被停止、未被重试)的执行,做完后照常带原 `--execution` 提交,网站会收下;仍被拒绝时按拒绝信息处理。任务文件的 `stopped_executions` 列出你此前被用户停止或跳过的执行:会话里如有它们未完成的工作,不接着做、不为它们补交,只处理本次请求。(失效的执行若还能产生可见结果,用户的打断与暂停就失去意义。)
|
|
29
29
|
3. **写入前定好 `--submission-id`**:同次重试沿用编号和原内容,新内容换新编号;`message post` 可省略,CLI 按房间、身份、关联与内容生成,用同一份草稿重试即得同一编号;结果不明时先按原编号查询,再按 [写入与恢复](references/writing.md) 处理。(网站靠它去重,换号会产生重复发言。)
|
|
30
30
|
4. **不创建定时任务、不操作其他软件、不发状态回执**(就绪、开始、完成、停止等说明),除非用户要求或出现需要记录的异常;回执不能作为观点、完成或共识的证据。(这些动作有副作用,回执只会淹没真正的回答。)
|
|
31
|
-
5.
|
|
31
|
+
5. **回复即交付**:一次请求只回答一次,回答后请求即结束。需要较长时间的工作做完再一次性回答,需要派活时在同一次回答里派;不在房间里回复进度,执行卡片会显示正在进行。(中途回复会提前结束请求,做完后就没有可绑定的请求来汇报。)主持人派活后自己还要接着做时例外,见 `discuss-host` 的 `--keep-working`。
|
|
32
32
|
|
|
33
33
|
## 命令入口与身份
|
|
34
34
|
|
package/backend/free_room.py
CHANGED
|
@@ -763,6 +763,12 @@ def host_event(event):
|
|
|
763
763
|
return {**event, "data": data}
|
|
764
764
|
|
|
765
765
|
|
|
766
|
+
# An execution (aliased `e`) on work the host handed out without waiting for it: a member it detached, or one it named
|
|
767
|
+
# in a dispatch after which it went on working (`keep_working`, its own request on the same message).
|
|
768
|
+
BACKGROUND_SQL = """EXISTS(SELECT 1 FROM member_requests r WHERE r.execution_id=e.id AND r.purpose='ask' AND r.created_by='host'
|
|
769
|
+
AND (r.batch_id=0 OR EXISTS(SELECT 1 FROM member_requests k WHERE k.message_id=r.message_id AND k.purpose='keep_working')))"""
|
|
770
|
+
|
|
771
|
+
|
|
766
772
|
def recent_executions(connection, room_id):
|
|
767
773
|
"""Return bounded public reports, including requests no longer in the recent request list."""
|
|
768
774
|
rows = connection.execute(f"""SELECT e.*,m.name AS member,
|
|
@@ -773,7 +779,8 @@ def recent_executions(connection, room_id):
|
|
|
773
779
|
(SELECT MIN({DISPATCHED_AFTER_SQL}) FROM member_requests r WHERE r.execution_id=e.id) AS dispatched_after,
|
|
774
780
|
(SELECT COUNT(*) FROM execution_notes WHERE execution_id=e.id) AS note_count,
|
|
775
781
|
(SELECT denials FROM execution_denials WHERE execution_id=e.id) AS denials,{CAPABILITY_COLUMNS},
|
|
776
|
-
(SELECT json_object('created_at',created_at) FROM late_answers WHERE execution_id=e.id) AS late_answer
|
|
782
|
+
(SELECT json_object('created_at',created_at) FROM late_answers WHERE execution_id=e.id) AS late_answer,
|
|
783
|
+
{BACKGROUND_SQL} AS background
|
|
777
784
|
FROM member_executions e JOIN room_members m ON m.id=e.member_id WHERE e.room_id=? ORDER BY e.id DESC LIMIT ?""", (room_id, RECENT_EXECUTIONS))
|
|
778
785
|
executions = []
|
|
779
786
|
for row in rows:
|
|
@@ -786,7 +793,7 @@ def recent_executions(connection, room_id):
|
|
|
786
793
|
"anchor_message_id": row["anchor_message_id"], "dispatched_after": row["dispatched_after"], "requests": requests,
|
|
787
794
|
"notes": row["note_count"], "denials": json.loads(row["denials"] or "[]"),
|
|
788
795
|
"capabilities": reported_capabilities(row), "stop_result": row["stop_result"] or "",
|
|
789
|
-
"late_answer": json.loads(row["late_answer"]) if row["late_answer"] else None,
|
|
796
|
+
"late_answer": json.loads(row["late_answer"]) if row["late_answer"] else None, "background": bool(row["background"]),
|
|
790
797
|
"interjections": execution_interjections(connection, row["id"], row["status"]),
|
|
791
798
|
"retry": execution_retry(connection, row["id"])})
|
|
792
799
|
return executions
|
|
@@ -1023,7 +1030,7 @@ def recipients(connection, room_id, payload):
|
|
|
1023
1030
|
|
|
1024
1031
|
|
|
1025
1032
|
# What a proactive post may not carry: it answers no request. Only the host's may also dispatch, as an answer does.
|
|
1026
|
-
PROACTIVE_EXCLUDED = ("execution_id", "request_ids", "next_review", "turn_id")
|
|
1033
|
+
PROACTIVE_EXCLUDED = ("execution_id", "request_ids", "next_review", "turn_id", "keep_working")
|
|
1027
1034
|
HOST_ONLY_PROACTIVE = ("to", "handoff", "no_handoff", "continue", "sequential", "loop", "parallel", "gates", "detach", "need_rounds", "rounds_reason")
|
|
1028
1035
|
|
|
1029
1036
|
|
|
@@ -1119,6 +1126,7 @@ def check_answer(connection, room_id, member, payload):
|
|
|
1119
1126
|
if payload.get("handoff") not in (None, False) and (payload["handoff"] is not True or member["role"] != "host" or not payload.get("to")):
|
|
1120
1127
|
raise ValueError("handoff 只能由主持人与 to 一起使用,值为 true")
|
|
1121
1128
|
check_no_handoff(member, payload)
|
|
1129
|
+
check_keep_working(member, payload)
|
|
1122
1130
|
check_need_rounds(member, payload)
|
|
1123
1131
|
reason = payload.get("continue")
|
|
1124
1132
|
if reason is not None and (member["role"] != "host" or not isinstance(reason, str) or not reason.strip()
|
|
@@ -1150,6 +1158,10 @@ def check_answer(connection, room_id, member, payload):
|
|
|
1150
1158
|
row = connection.execute("SELECT * FROM member_executions WHERE room_id=? AND id=?", (room_id, execution_id)).fetchone()
|
|
1151
1159
|
if not row or row["member_id"] != member["id"]:
|
|
1152
1160
|
raise PermissionError("执行编号不属于本成员")
|
|
1161
|
+
if row["status"] == "completed":
|
|
1162
|
+
# The host dispatched with keep_working and went on in the same turn: its answer belongs to where that turn went.
|
|
1163
|
+
row = live_continuation(connection, row) or row
|
|
1164
|
+
payload["execution_id"] = row["id"]
|
|
1153
1165
|
revived = revive_failed(connection, room_id, row) if row["status"] == "failed" else None
|
|
1154
1166
|
if revived:
|
|
1155
1167
|
row = revived
|
|
@@ -1173,6 +1185,42 @@ def check_dispatch(member, payload, purposes):
|
|
|
1173
1185
|
"""A host answering only its share of an everyone request answers as a member, so it may not dispatch others."""
|
|
1174
1186
|
if member["role"] == "host" and payload.get("to") and purposes and all(purpose == "all" for purpose in purposes):
|
|
1175
1187
|
raise ValueError("这次是请全体成员各自回应,其他成员已收到请求;主持人只回答自己的部分,不能用 --to 派活")
|
|
1188
|
+
if payload.get("keep_working") and any(purpose in ("discuss", "discuss_host") for purpose in purposes):
|
|
1189
|
+
raise ValueError("讨论中的发言不能用 keep_working")
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
def check_keep_working(member, payload):
|
|
1193
|
+
"""`keep_working`: the runner-delivered host dispatches and goes on in the same turn instead of ending it."""
|
|
1194
|
+
if payload.get("keep_working") in (None, False):
|
|
1195
|
+
return
|
|
1196
|
+
# A relay checkpoint or a review hands back on the dispatch message itself, where the host's own request now hangs.
|
|
1197
|
+
if (payload["keep_working"] is not True or member["role"] != "host" or member["access"] != "runner" or not payload.get("to")
|
|
1198
|
+
or any(payload.get(field) not in (None, False) for field in ("continue", "sequential", "next_review"))):
|
|
1199
|
+
raise ValueError("keep_working 只能由本机接入的主持人在派活(to)时使用,值为 true,不能与 continue、sequential 或 next_review 同用")
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
def live_continuation(connection, row):
|
|
1203
|
+
"""The live execution that a host's `keep_working` moved this answered execution's turn onto, or None."""
|
|
1204
|
+
while row and row["status"] == "completed":
|
|
1205
|
+
link = connection.execute("SELECT next_id FROM execution_continuations WHERE execution_id=?", (row["id"],)).fetchone()
|
|
1206
|
+
row = link and connection.execute("SELECT * FROM member_executions WHERE id=?", (link[0],)).fetchone()
|
|
1207
|
+
return row if row and row["status"] in ACTIVE else None
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
def keep_working(connection, room_id, host, message_id, chain_id, execution_id):
|
|
1211
|
+
"""The host dispatched with `keep_working`: its answered execution ends with this message, and a new one, on a request
|
|
1212
|
+
hanging on it, carries the same software turn on, so that work shows as its own card under the dispatch."""
|
|
1213
|
+
now = int(time.time())
|
|
1214
|
+
previous = connection.execute("SELECT * FROM member_executions WHERE id=?", (execution_id,)).fetchone()
|
|
1215
|
+
next_id = connection.execute("""INSERT INTO member_executions (room_id,member_id,client_id,session_id,lease_until,created_at,cwd)
|
|
1216
|
+
VALUES (?,?,?,?,?,?,?)""", (room_id, host["id"], f"keep-working-{execution_id}", previous["session_id"],
|
|
1217
|
+
now + LEASE_SECONDS, now, previous["cwd"])).lastrowid
|
|
1218
|
+
connection.execute("""INSERT INTO execution_capabilities (execution_id,room_id,stoppable,progress,steer,resume)
|
|
1219
|
+
SELECT ?,room_id,stoppable,progress,steer,resume FROM execution_capabilities WHERE execution_id=?""", (next_id, execution_id))
|
|
1220
|
+
insert_request(connection, room_id, host["id"], message_id, chain_id, "keep_working", "host")
|
|
1221
|
+
connection.execute("UPDATE member_requests SET status='delivering',execution_id=? WHERE message_id=? AND member_id=?",
|
|
1222
|
+
(next_id, message_id, host["id"]))
|
|
1223
|
+
connection.execute("INSERT INTO execution_continuations (execution_id,next_id) VALUES (?,?)", (execution_id, next_id))
|
|
1176
1224
|
|
|
1177
1225
|
|
|
1178
1226
|
def insert_request(connection, room_id, member_id, message_id, chain_id, purpose, created_by, batch_id=0):
|
|
@@ -1530,8 +1578,14 @@ def settle_batches(connection, room_id):
|
|
|
1530
1578
|
continue
|
|
1531
1579
|
# Every other answer and every failure comes back to the host, so it can carry on, retry, reassign or tell the user.
|
|
1532
1580
|
# The hand-back closes the round it belongs to, so it is never held back: the last round still gets its summary.
|
|
1533
|
-
|
|
1581
|
+
own = connection.execute("SELECT purpose FROM member_requests WHERE message_id=? AND member_id=?", (batch["batch_id"], host["id"])).fetchone()
|
|
1582
|
+
if not own:
|
|
1534
1583
|
insert_request(connection, room_id, host["id"], batch["batch_id"], batch["chain_id"], "handoff", "host")
|
|
1584
|
+
elif own["purpose"] == "keep_working":
|
|
1585
|
+
# The host went on working after this dispatch, on a request of its own on the same message: the hand-back
|
|
1586
|
+
# reaches it as a notice, delivered once that work ends.
|
|
1587
|
+
wake_host(connection, room_id, batch["chain_id"], f"#{batch['batch_id']} 派出的工作已结束,请主持人接着处理。",
|
|
1588
|
+
f"handoff:{batch['batch_id']}")
|
|
1535
1589
|
else:
|
|
1536
1590
|
# The batch already came back once (it had failed) and the owner retried it: its new answers reach the host as a notice.
|
|
1537
1591
|
retried = connection.execute("SELECT MAX(id) FROM member_requests WHERE room_id=? AND batch_id=?", (room_id, batch["batch_id"])).fetchone()[0]
|
|
@@ -2079,6 +2133,8 @@ def after_free_message(connection, room_id, message_id, actor, payload):
|
|
|
2079
2133
|
elif actor["role"] == "host" and payload.get("to"):
|
|
2080
2134
|
dispatch(connection, room_id, actor, message_id, payload["to"], chain_id, payload.get("handoff") is True or bool(payload.get("next_review")),
|
|
2081
2135
|
payload.get("no_handoff") is True, {"need": need_plan(payload)}, payload.get("detach"))
|
|
2136
|
+
if payload.get("keep_working") is True:
|
|
2137
|
+
keep_working(connection, room_id, actor, message_id, chain_id, payload["execution_id"])
|
|
2082
2138
|
if actor["role"] == "host":
|
|
2083
2139
|
remember_continue(connection, room_id, actor, message_id, chain_id, payload)
|
|
2084
2140
|
settle_batches(connection, room_id)
|
|
@@ -2309,7 +2365,10 @@ def inbox(connection, room_id, token):
|
|
|
2309
2365
|
pending = [{**request, **review_request_context(connection, request), **sequence_request_context(connection, request)} for request in pending]
|
|
2310
2366
|
(members if row["access"] == "runner" else observers).append({**member_view, "pending": pending})
|
|
2311
2367
|
# Pending interjections ride along so the runner hands them to the running software at its next check.
|
|
2368
|
+
# `continues`: the answered execution whose software turn this one carries on (keep_working); the runner moves it over.
|
|
2312
2369
|
executions = [{**public_execution(row), "member": row["name"], "retry": execution_retry(connection, row["id"]),
|
|
2370
|
+
"continues": (connection.execute("SELECT execution_id FROM execution_continuations WHERE next_id=?",
|
|
2371
|
+
(row["id"],)).fetchone() or [None])[0],
|
|
2313
2372
|
"interjections": [dict(item) for item in connection.execute(
|
|
2314
2373
|
"SELECT id,text FROM execution_interjections WHERE execution_id=? AND status='pending' ORDER BY id", (row["id"],))]}
|
|
2315
2374
|
for row in connection.execute(
|
package/backend/schema.sql
CHANGED
|
@@ -723,6 +723,12 @@ CREATE TABLE IF NOT EXISTS free_direct_batches (
|
|
|
723
723
|
batch_id INTEGER NOT NULL,
|
|
724
724
|
PRIMARY KEY (room_id,batch_id)
|
|
725
725
|
);
|
|
726
|
+
-- A host that dispatched with `keep_working` goes on working in the same software turn: its answered execution is
|
|
727
|
+
-- followed by `next_id`, a new one the runner moves that turn onto; a later answer to the first goes to the live one.
|
|
728
|
+
CREATE TABLE IF NOT EXISTS execution_continuations (
|
|
729
|
+
execution_id INTEGER PRIMARY KEY REFERENCES member_executions(id) ON DELETE CASCADE,
|
|
730
|
+
next_id INTEGER NOT NULL REFERENCES member_executions(id) ON DELETE CASCADE
|
|
731
|
+
);
|
|
726
732
|
-- What the program handed to the host once (a failure, a possible conflict, its own continue): `key` keeps it to one
|
|
727
733
|
-- wake-up per event, `chain_id` counts it as a round of that chain, `message_id` is the notice its request hangs on.
|
|
728
734
|
CREATE TABLE IF NOT EXISTS free_host_wakes (
|
package/backend/server.py
CHANGED
|
@@ -1237,7 +1237,7 @@ def check_message_references(connection, room_id, message):
|
|
|
1237
1237
|
|
|
1238
1238
|
|
|
1239
1239
|
CAPTURE_REFUSED_FIELDS = ("to", "handoff", "continue", "sequential", "loop", "parallel", "gates", "detach", "need_rounds",
|
|
1240
|
-
"next_review", "review_scope", "proactive", "request_ids", "reply_to", "attachment_ids")
|
|
1240
|
+
"next_review", "review_scope", "proactive", "request_ids", "reply_to", "attachment_ids", "keep_working")
|
|
1241
1241
|
|
|
1242
1242
|
|
|
1243
1243
|
def check_captured_reply(payload):
|
|
@@ -1249,7 +1249,7 @@ def check_captured_reply(payload):
|
|
|
1249
1249
|
def append_free_message(connection, room, payload, actor):
|
|
1250
1250
|
"""Append a free-room message: the owner's creates requests, a member's completes its execution."""
|
|
1251
1251
|
if payload.get("kind") == "moderation":
|
|
1252
|
-
if any(payload.get(field) for field in ("next_review", "review_scope", "review_roster", "sequential", "loop", "parallel", "gates", "detach", "need_rounds")):
|
|
1252
|
+
if any(payload.get(field) for field in ("next_review", "review_scope", "review_roster", "sequential", "loop", "parallel", "gates", "detach", "need_rounds", "keep_working")):
|
|
1253
1253
|
raise ValueError("主持说明不能声明评审授权、依次接力或申请轮数;请在派活时提交")
|
|
1254
1254
|
return append_free_moderation(connection, room, payload, actor)
|
|
1255
1255
|
if payload.get("kind") not in (None, "chat"):
|
|
@@ -1695,7 +1695,7 @@ def protocol_text(room):
|
|
|
1695
1695
|
"用户管理和讨论开关使用房主凭据;本地成员使用本人的 --access-file,不借用其他身份。凭据私下交付,不公开 token。API 参与者遵循相同请求与执行约束,source=api;本地 CLI 使用 source=cli。",
|
|
1696
1696
|
"runner 成员等待本机接入程序交付任务,用 execution view 核对本次执行和请求,再以 message post --as 本人 --kind chat --execution 本次编号 --access-file FILE 回答。执行失效后保留草稿,不能去掉编号改作普通发言;认领、续租与后续投递由接入程序处理。",
|
|
1697
1697
|
"manual 本地成员首次用 member register 注册,会话 ID 由 CLI 自动取得;回答用 --request 请求编号,不编造执行编号。讨论不使用原生定时;原会话不能托管时由用户触发。",
|
|
1698
|
-
"房间里的 host 可用 --to 点名成员,route 表示未点名的用户请求,handoff 表示派出任务已结束;链上 AI 派活受房间预算限制。--to 多位并加 --sequential 时按点名顺序依次接力,每棒一轮,最后交回主持人;--with 成员 与紧挨在前的 --to 同一棒同时做,这一组全部结束才交下一棒;--detach 成员
|
|
1698
|
+
"房间里的 host 可用 --to 点名成员,route 表示未点名的用户请求,handoff 表示派出任务已结束;链上 AI 派活受房间预算限制。--to 多位并加 --sequential 时按点名顺序依次接力,每棒一轮,最后交回主持人;--with 成员 与紧挨在前的 --to 同一棒同时做,这一组全部结束才交下一棒;--detach 成员 与这次派活同时开工但不等它(失败时通知主持人);--keep-working 派活后自己不结束这一轮、接着工作:这条回答收为派活卡,后续工作另起一张卡,做完照常回答(同一执行凭据即可),派出的工作结束时以通知交回;不能与 --continue、--sequential、--next-review 同用;再加 --loop 则交回为检查点,用 sequence continue --request 交接请求编号 开始下一圈,不继续即直接验收。普通成员的 --to 或正文 @ 只保存回应建议,不直接唤醒;不点名自己、不扩大授权。",
|
|
1699
1699
|
"讨论中的用户 @ 直接提问独立排队,不计讨论轮次、不与讨论发言合并。initial 阶段先独立判断;服务端按讨论请求的 read_until 限制读取。直接提问和主持任务不继承该阅读限制。",
|
|
1700
1700
|
"主持安排前先 turn roster 读取在场专家、waiting、unregistered 和 revision,再 turn create --roster revision;单项和多项都要带凭据,多项计划须覆盖本轮 waiting。继续排队同样先读 roster,再 turn continue --roster revision。状态或新消息变化后旧凭据被拒绝,重新读取再判断;每个回答保存后由程序推进下一项。",
|
|
1701
1701
|
"局部追问先 turn roster 读取 host_requests 的请求与原消息编号,再 turn ask --request ID --expert NAME --roster revision --submission-id UUID;普通提问不计轮次、不改讨论队列,可问已发言者和主持人,只结束指定请求。",
|
package/package.json
CHANGED
package/runner/discuss.py
CHANGED
|
@@ -331,6 +331,9 @@ def message_commands(subcommands, registry):
|
|
|
331
331
|
help="旧参数,保留兼容:主持人派出的工作现在总会交回你")
|
|
332
332
|
post.add_argument("--no-handoff", action="store_true",
|
|
333
333
|
help="自由房间主持人:只点名一位成员、它的回答已足以直接给用户时用;做完不交回你,失败仍交回")
|
|
334
|
+
post.add_argument("--keep-working", action="store_true",
|
|
335
|
+
help="自由房间主持人:与 --to 同用,派活后不结束这一轮、接着自己工作(不等派出的成员);这条回答收为派活卡,后续工作另起一张卡,"
|
|
336
|
+
"做完照常回答(沿用本次凭据),派出的工作结束时以通知交回你;不能与 --continue、--sequential、--next-review 同用")
|
|
334
337
|
post.add_argument("--proactive", action="store_true",
|
|
335
338
|
help="自由房间成员:不是房间派来的任务、而是你的用户在你自己的窗口里要你发言时用(主持人也可在需要主动说明、派活或补交失效执行的结果时自行使用);不关联执行或请求,有进行中的执行或讨论进行中不可用;主持人还可同时 --to 派活或 --continue,从这条消息起算新任务链")
|
|
336
339
|
post.add_argument("--continue", dest="continue_reason", metavar="REASON",
|
|
@@ -769,6 +772,10 @@ def plan_message(args):
|
|
|
769
772
|
payload["proactive"] = True
|
|
770
773
|
if args.no_handoff:
|
|
771
774
|
payload["no_handoff"] = True
|
|
775
|
+
if args.keep_working:
|
|
776
|
+
if not args.to:
|
|
777
|
+
raise CliError("--keep-working 须与 --to 一起使用")
|
|
778
|
+
payload["keep_working"] = True
|
|
772
779
|
if args.need_rounds is not None or args.rounds_reason is not None:
|
|
773
780
|
payload["need_rounds"] = args.need_rounds
|
|
774
781
|
payload["rounds_reason"] = args.rounds_reason
|
package/runner/free_runner.mjs
CHANGED
|
@@ -323,6 +323,8 @@ export class FreeRoomRunner {
|
|
|
323
323
|
// Execution id -> { phase, at, sent_phase, sent_at }: what the member's software last showed it doing.
|
|
324
324
|
this.activity = new Map();
|
|
325
325
|
this.segments = new SegmentLog();
|
|
326
|
+
// Execution id -> the execution its software turn moved onto when its host dispatched with keep_working.
|
|
327
|
+
this.continued = new Map();
|
|
326
328
|
this.context_errors = new Map();
|
|
327
329
|
this.adopt(config);
|
|
328
330
|
this.store.db.exec(`CREATE TABLE IF NOT EXISTS free_deliveries(member TEXT PRIMARY KEY, client_id TEXT NOT NULL,
|
|
@@ -397,6 +399,11 @@ export class FreeRoomRunner {
|
|
|
397
399
|
if (!inbox.archived) await this.continue_goal(room);
|
|
398
400
|
this.inbox = inbox;
|
|
399
401
|
const active = new Map(inbox.executions.map(item => [item.id, item]));
|
|
402
|
+
// Before anything treats the answered execution as ended (and stops its software), move a turn its host kept working in.
|
|
403
|
+
for (const next of inbox.executions) {
|
|
404
|
+
const row = next.continues ? this.row(next.member) : null;
|
|
405
|
+
if (row && row.execution_id === next.continues && LIVE.includes(row.status)) await this.carry_on(next.member, next.continues, next.id);
|
|
406
|
+
}
|
|
400
407
|
const present = new Set(inbox.members.map(member => member.name));
|
|
401
408
|
// A member sent away or removed no longer appears; its live work was already voided on the website.
|
|
402
409
|
for (const row of this.store.db.prepare('SELECT * FROM free_deliveries').all()) {
|
|
@@ -810,7 +817,9 @@ export class FreeRoomRunner {
|
|
|
810
817
|
if ((before || extras.length) && !this.snapshots.has(execution.id)) this.snapshots.set(execution.id, { member: member.name, directory, before, extras });
|
|
811
818
|
const generation = (this.generations.get(execution.id) || 0) + 1;
|
|
812
819
|
this.generations.set(execution.id, generation);
|
|
813
|
-
|
|
820
|
+
// The turn's events follow it when a keep_working dispatch moves it onto a new execution.
|
|
821
|
+
const live = () => this.live_id(execution.id);
|
|
822
|
+
const current = () => this.generations.get(live()) === generation;
|
|
814
823
|
const binding = this.store.binding(member.name);
|
|
815
824
|
// A member whose session a rewind restarted is bound to '' and must not fall back to the session it was invited with.
|
|
816
825
|
if (binding.session_id === undefined && adapter.session_id) binding.session_id = adapter.session_id;
|
|
@@ -853,32 +862,32 @@ export class FreeRoomRunner {
|
|
|
853
862
|
...(this.config.image_generation ? { image_generation: true } : {}),
|
|
854
863
|
...(task.goal ? { goal: task.goal } : {}) },
|
|
855
864
|
on_binding: session => this.store.bind(member.name, session),
|
|
856
|
-
on_process: child => this.track(member.name, child,
|
|
857
|
-
on_output: (path, chunk) => { appendFileSync(path, chunk, { mode: 0o600 }); this.touch(
|
|
858
|
-
on_activity: (phase, tool) => { worked = true; this.touch(
|
|
865
|
+
on_process: child => this.track(member.name, child, live()),
|
|
866
|
+
on_output: (path, chunk) => { appendFileSync(path, chunk, { mode: 0o600 }); this.touch(live()); this.segments.mark(live()); },
|
|
867
|
+
on_activity: (phase, tool) => { worked = true; this.touch(live(), phase); this.segments.mark(live(), phase, tool); },
|
|
859
868
|
on_note: text => {
|
|
860
|
-
this.note(
|
|
861
|
-
if (worked && current()) this.replies.set(
|
|
869
|
+
this.note(live(), text);
|
|
870
|
+
if (worked && current()) this.replies.set(live(), text);
|
|
862
871
|
},
|
|
863
872
|
// Files the agent edited with its own tools, read from its events; an empty call says the list is tracked.
|
|
864
873
|
on_edits: paths => {
|
|
865
|
-
const snapshot = this.snapshots.get(
|
|
874
|
+
const snapshot = this.snapshots.get(live());
|
|
866
875
|
if (snapshot) paths.forEach(path => (snapshot.edited ||= new Set()).add(path));
|
|
867
876
|
if (snapshot && !paths.length) snapshot.edited ||= new Set();
|
|
868
877
|
},
|
|
869
878
|
// A stopped process may report after the next execution started; only its own execution takes the result.
|
|
870
879
|
on_failure: (error, { not_started = false, retryable = true } = {}) => {
|
|
871
880
|
if (!current()) return;
|
|
872
|
-
if (not_started) this.not_started.add(
|
|
873
|
-
if (!retryable) this.not_retryable.add(
|
|
874
|
-
try { if (this.row(member.name)?.execution_id ===
|
|
881
|
+
if (not_started) this.not_started.add(live());
|
|
882
|
+
if (!retryable) this.not_retryable.add(live());
|
|
883
|
+
try { if (this.row(member.name)?.execution_id === live()) this.save(member.name, { error }); } catch { /* Store may already be closed at shutdown. */ }
|
|
875
884
|
},
|
|
876
|
-
on_exit: denial => { if (current()) this.exited.set(
|
|
885
|
+
on_exit: denial => { if (current()) this.exited.set(live(), denial || ''); },
|
|
877
886
|
// Shown beside the answer or failure so the owner can allow them; a lost report only hides the list.
|
|
878
887
|
on_denials: denials => {
|
|
879
888
|
// A refused operation means the turn may be unfinished: its last remark is never captured as the answer.
|
|
880
|
-
if (denials?.length && current()) this.denied.add(
|
|
881
|
-
api(this.config, `/executions/${
|
|
889
|
+
if (denials?.length && current()) this.denied.add(live());
|
|
890
|
+
api(this.config, `/executions/${live()}`, { action: 'denials', denials }).catch(() => {});
|
|
882
891
|
},
|
|
883
892
|
});
|
|
884
893
|
if (result.session_id) this.store.bind(member.name, result.session_id);
|
|
@@ -1012,6 +1021,37 @@ export class FreeRoomRunner {
|
|
|
1012
1021
|
this.save(member.name, { last_renew: Date.now() });
|
|
1013
1022
|
}
|
|
1014
1023
|
}
|
|
1024
|
+
/** The execution a turn delivered as `id` now belongs to, following keep_working moves. */
|
|
1025
|
+
live_id(id) {
|
|
1026
|
+
while (this.continued.has(id)) id = this.continued.get(id);
|
|
1027
|
+
return id;
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* The host answered with keep_working and its software turn goes on: move that turn, with what this runner keeps for
|
|
1031
|
+
* it, onto the execution the website opened, instead of stopping it. The answered execution reports its file changes
|
|
1032
|
+
* and progress as they stand; the new one watches from now.
|
|
1033
|
+
*/
|
|
1034
|
+
async carry_on(name, old, id) {
|
|
1035
|
+
this.continued.set(old, id);
|
|
1036
|
+
for (const map of [this.generations, this.steers, this.activity, this.replies, this.exited, this.execution_processes]) {
|
|
1037
|
+
if (map.has(old)) { map.set(id, map.get(old)); map.delete(old); }
|
|
1038
|
+
}
|
|
1039
|
+
for (const set of [this.denied, this.not_started, this.not_retryable]) if (set.delete(old)) set.add(id);
|
|
1040
|
+
const snapshot = this.snapshots.get(old);
|
|
1041
|
+
if (snapshot) this.snapshots.set(id, { member: snapshot.member, directory: snapshot.directory,
|
|
1042
|
+
before: snapshot.before ? workspace_snapshot(snapshot.directory) : null,
|
|
1043
|
+
extras: (snapshot.extras || []).map(item => ({ directory: item.directory, before: workspace_snapshot(item.directory) })),
|
|
1044
|
+
...(snapshot.edited ? { edited: new Set() } : {}) });
|
|
1045
|
+
for (const prefix of ['owner', 'delivery']) {
|
|
1046
|
+
const value = this.store.db.prepare('SELECT value FROM metadata WHERE key=?').get(`${prefix}:${old}`)?.value;
|
|
1047
|
+
if (!value) continue;
|
|
1048
|
+
this.store.db.prepare('INSERT OR REPLACE INTO metadata VALUES (?,?)').run(`${prefix}:${id}`, value);
|
|
1049
|
+
this.store.db.prepare('DELETE FROM metadata WHERE key=?').run(`${prefix}:${old}`);
|
|
1050
|
+
}
|
|
1051
|
+
await this.report_segments(old, true);
|
|
1052
|
+
this.segments.start(id);
|
|
1053
|
+
this.save(name, { execution_id: id, last_renew: 0 });
|
|
1054
|
+
}
|
|
1015
1055
|
/**
|
|
1016
1056
|
* An execution the owner paused from the private chat, or that takes an interjection only by a pause: stop its
|
|
1017
1057
|
* software turn and keep the execution live; once that turn has ended and the owner's words wait, resume the same
|