ai_co_discuss 0.5.21 → 0.5.23
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/codiscuss-draft-cleanup/SKILL.md +16 -0
- package/.agents/skills/codiscuss-draft-cleanup/cleanup.py +70 -0
- package/.agents/skills/codiscuss-draft-cleanup/scan.py +70 -0
- package/.agents/skills/discuss-host/references/control.md +2 -2
- package/.agents/skills/discuss-host/references/workflow.md +4 -2
- package/.agents/skills/discuss-participant/SKILL.md +2 -0
- package/.agents/skills/local-stt-setup/SKILL.md +9 -8
- package/.agents/skills/local-tts-setup/SKILL.md +10 -9
- package/.agents/skills/share-card/SKILL.md +7 -6
- package/.agents/skills/share-card/references/share-card.md +34 -8
- package/.agents/skills/workflow-creator/SKILL.md +22 -14
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/backend/free_room.py +64 -8
- package/backend/message_queue.py +9 -0
- package/backend/schema.sql +13 -1
- package/backend/server.py +289 -59
- package/docs/en/guide/admin.md +18 -0
- package/docs/en/guide/members.md +7 -1
- package/docs/en/guide/remote.md +1 -1
- package/docs/en/guide/rooms.md +14 -6
- package/docs/en/guide/voice.md +2 -0
- package/docs/en/guide/workflows.md +9 -5
- package/docs/en/guide/working.md +6 -4
- package/docs/guide/admin.md +18 -0
- package/docs/guide/members.md +7 -1
- package/docs/guide/remote.md +1 -1
- package/docs/guide/rooms.md +13 -6
- package/docs/guide/voice.md +2 -0
- package/docs/guide/workflows.md +9 -5
- package/docs/guide/working.md +6 -4
- package/frontend/locales/en/admin.json +58 -1
- package/frontend/locales/en/app.json +18 -1
- package/frontend/locales/en/backend.json +6 -0
- package/frontend/locales/en/core.json +4 -2
- package/frontend/locales/en/discussion.json +4 -1
- package/frontend/locales/en/room.json +85 -1
- package/gateway/gateway.mjs +49 -9
- package/package.json +3 -1
- package/runner/account_space.mjs +10 -0
- package/runner/adapters/antigravity_app.mjs +31 -4
- package/runner/adapters/antigravity_cli.mjs +9 -2
- package/runner/adapters/api.mjs +3 -2
- package/runner/adapters/api_pi.mjs +3 -2
- package/runner/adapters/api_pi_extension.mjs +5 -3
- package/runner/adapters/claude.mjs +32 -9
- package/runner/adapters/cli.mjs +2 -2
- package/runner/adapters/codex_app.mjs +192 -69
- package/runner/adapters/codex_cli.mjs +10 -5
- package/runner/adapters/common.mjs +414 -11
- package/runner/adapters/index.mjs +6 -0
- package/runner/admin_cli.mjs +22 -5
- package/runner/admin_panel.mjs +118 -5
- package/runner/admin_storage.mjs +105 -0
- package/runner/discussion_launch.mjs +328 -128
- package/runner/discussion_runner.mjs +12 -3
- package/runner/discussion_service.mjs +224 -37
- package/runner/discussion_skills.mjs +1 -1
- package/runner/expert_prompts.mjs +2 -2
- package/runner/experts.mjs +227 -0
- package/runner/file_diff.mjs +1 -1
- package/runner/free_runner.mjs +236 -51
- package/runner/i18n_en.mjs +39 -0
- package/runner/os_users.mjs +33 -1
- package/runner/project_files.mjs +7 -1
- package/runner/project_migration.mjs +245 -0
- package/runner/relay_channel.mjs +1 -1
- package/runner/remote_launch.mjs +4 -3
- package/runner/share_card.mjs +17 -1
- package/runner/share_shared.mjs +26 -9
- package/runner/site_deploy.mjs +2 -1
- package/runner/slash_names.mjs +12 -1
- package/runner/speech_directories.mjs +20 -0
- package/runner/storage_guard.mjs +383 -0
- package/runner/tts_providers.mjs +22 -21
- package/runner/workflows.mjs +211 -57
- package/web/admin.css +1 -1
- package/web/admin.js +8 -8
- package/web/app.js +589 -80
- package/web/i18n.js +4 -4
- package/web/markdown.css +1 -1
- package/web/modern.css +1 -1
- package/web/modern.js +68 -66
- package/workflows/decision-council/flow.json +216 -25
- package/workflows/trpg-classic/flow.json +151 -21
package/backend/free_room.py
CHANGED
|
@@ -106,7 +106,7 @@ TIMELINE_SQL = f"""SELECT x.*,(SELECT COALESCE(NULLIF(s.text,''),substr(a.text,1
|
|
|
106
106
|
(SELECT substr(q.text,1,160) FROM messages q WHERE q.id=(SELECT MIN(r.message_id) FROM member_requests r WHERE r.execution_id=e.id)) AS task,
|
|
107
107
|
(SELECT MAX(r.answer_id) FROM member_requests r WHERE r.execution_id=e.id) AS answer_id,
|
|
108
108
|
(SELECT n.text FROM execution_notes n WHERE n.execution_id=e.id ORDER BY n.seq DESC LIMIT 1) AS last_note,
|
|
109
|
-
|
|
109
|
+
json_array_length(NULLIF(e.edited,'')) AS changes,e.model,e.effort
|
|
110
110
|
FROM member_executions e JOIN room_members m ON m.id=e.member_id WHERE e.id IN ({TIMELINE_FREE_IDS})) x"""
|
|
111
111
|
TIMELINE_SEGMENTS_SQL = f"""SELECT source,execution_id,phase,tool,start_ms,end_ms FROM execution_segments WHERE room_id=?1
|
|
112
112
|
AND source='free' AND execution_id IN ({TIMELINE_FREE_IDS}) ORDER BY source,execution_id,seq"""
|
|
@@ -407,7 +407,7 @@ def review_ready(connection, room_id, batch_id, token):
|
|
|
407
407
|
plan = dict(plan)
|
|
408
408
|
batch = connection.execute("SELECT * FROM free_batches WHERE room_id=? AND batch_id=?", (room_id, batch_id)).fetchone()
|
|
409
409
|
requests = [dict(row) for row in connection.execute("""SELECT r.id,r.member_id,m.name AS member,r.status,r.answer_id,
|
|
410
|
-
a.text AS answer,e.id AS execution_id,e.status AS execution_status,e.result,e.changes
|
|
410
|
+
a.text AS answer,e.id AS execution_id,e.status AS execution_status,e.result,e.edited AS changes
|
|
411
411
|
FROM member_requests r JOIN room_members m ON m.id=r.member_id LEFT JOIN messages a ON a.id=r.answer_id
|
|
412
412
|
LEFT JOIN member_executions e ON e.id=r.execution_id WHERE r.room_id=? AND r.batch_id=? ORDER BY r.id""", (room_id, batch_id))]
|
|
413
413
|
handoffs = review_handoffs(connection, room_id, batch_id, plan["host_id"])
|
|
@@ -1373,6 +1373,10 @@ def recipients(connection, room_id, payload):
|
|
|
1373
1373
|
# Rooms created while the user could host get their AI host on the next message.
|
|
1374
1374
|
sync_participants(connection, room_id)
|
|
1375
1375
|
active = active_members(connection, room_id)
|
|
1376
|
+
if payload.get("relay"):
|
|
1377
|
+
host = next((row for row in active.values() if row["role"] == "host"), None)
|
|
1378
|
+
target = host or (next(iter(active.values())) if len(active) == 1 else None)
|
|
1379
|
+
return [(target["id"], "ask")] if target else []
|
|
1376
1380
|
if payload.get("to") is not None:
|
|
1377
1381
|
named = named_members(active, payload["to"])
|
|
1378
1382
|
host = next((row for row in active.values() if row["role"] == "host"), None)
|
|
@@ -2731,8 +2735,13 @@ def reaches_host(connection, room_id, payload):
|
|
|
2731
2735
|
|
|
2732
2736
|
def relay_positions(connection, room_id):
|
|
2733
2737
|
"""Every relay step batch of the room with its step number, read once per view."""
|
|
2734
|
-
|
|
2735
|
-
|
|
2738
|
+
positions = {}
|
|
2739
|
+
for sequence in connection.execute("SELECT steps FROM free_sequences WHERE room_id=?", (room_id,)):
|
|
2740
|
+
counted = {}
|
|
2741
|
+
for entry in json.loads(sequence["steps"]):
|
|
2742
|
+
counted[entry[0]] = counted.get(entry[0], 0) + 1
|
|
2743
|
+
positions[entry[2]] = entry[3] + 1 if len(entry) > 3 else counted[entry[0]]
|
|
2744
|
+
return positions
|
|
2736
2745
|
|
|
2737
2746
|
|
|
2738
2747
|
def line_of(connection, request, positions=None):
|
|
@@ -2825,6 +2834,10 @@ def after_free_message(connection, room_id, message_id, actor, payload):
|
|
|
2825
2834
|
# host was waiting on: the goal is back to being worked on and a later pending gets its fallback again.
|
|
2826
2835
|
# A message the host takes also replaces whatever it meant to continue with. One naming other members only
|
|
2827
2836
|
# starts their own lines: it answers nothing the host asked, so the host's plan and goal state stay (user 2026-11-20).
|
|
2837
|
+
if payload.get("relay"):
|
|
2838
|
+
for member_id, purpose in recipients(connection, room_id, payload):
|
|
2839
|
+
insert_request(connection, room_id, member_id, message_id, message_id, purpose, "user")
|
|
2840
|
+
return
|
|
2828
2841
|
if reaches_host(connection, room_id, payload):
|
|
2829
2842
|
connection.execute("""UPDATE room_goals SET armed=1,phase='doing',phase_note='',phase_until=0,pending_fallback=0
|
|
2830
2843
|
WHERE room_id=? AND status='active'""", (room_id,))
|
|
@@ -3163,6 +3176,7 @@ def inbox(connection, room_id, token):
|
|
|
3163
3176
|
def pending_requests(connection, member_id):
|
|
3164
3177
|
"""A member's pending requests with the context its software needs: discussion turn, review, relay, hand-back, question."""
|
|
3165
3178
|
pending = [dict(item) for item in connection.execute("""SELECT r.id,r.message_id,r.purpose,r.batch_id,
|
|
3179
|
+
(SELECT source_room_id FROM message_relays WHERE message_id=r.message_id) AS relay_room,
|
|
3166
3180
|
sr.id AS session_request_id,sr.session_id,sr.round,sr.position,sr.read_until,sr.question AS source_question,
|
|
3167
3181
|
t.cause_kind,t.cause_message_id AS source_message_id,t.cause_request_id,
|
|
3168
3182
|
(SELECT action FROM group_routes WHERE message_id=r.message_id) AS group_action
|
|
@@ -4096,15 +4110,20 @@ def interrupt_for_message(connection, room_id, message_id):
|
|
|
4096
4110
|
if blocked:
|
|
4097
4111
|
raise FileExistsError(Text("{value1} 正在执行且无法打断,这条消息继续排队,等它答完后发送", value1='、'.join(blocked)))
|
|
4098
4112
|
now = int(time.time())
|
|
4113
|
+
source = connection.execute("""SELECT r.title FROM message_relays m JOIN rooms r ON r.id=m.source_room_id
|
|
4114
|
+
WHERE m.message_id=?""", (message_id,)).fetchone()
|
|
4115
|
+
notice = (Text("关联房间「{room}」的主持人刚发来消息 #{message_id},请先读原文。", room=source[0], message_id=message_id)
|
|
4116
|
+
if source else Text("用户刚发来消息 #{message_id},请先读原文,在这一轮的回答里一并处理。", message_id=message_id))
|
|
4099
4117
|
for row in steerable:
|
|
4100
4118
|
execution = connection.execute("SELECT * FROM member_executions WHERE id=?", (row["execution_id"],)).fetchone()
|
|
4101
|
-
add_interjection(connection, room_id, execution, {"text": str(
|
|
4119
|
+
add_interjection(connection, room_id, execution, {"text": str(notice),
|
|
4102
4120
|
"submission_id": f"queue-{message_id}-{row['member_id']}"}, now)
|
|
4103
4121
|
connection.execute("UPDATE member_requests SET status='delivering',execution_id=? WHERE id=?", (row["execution_id"], row["request_id"]))
|
|
4104
4122
|
for row in stopped:
|
|
4105
|
-
stop_member_work(connection, row["member_id"], Text("已打断:你立即发送了新消息,它会连同这条一起处理"), "user_stop", keep_pending=True, requeue=True)
|
|
4123
|
+
stop_member_work(connection, row["member_id"], notice if source else Text("已打断:你立即发送了新消息,它会连同这条一起处理"), "user_stop", keep_pending=True, requeue=True)
|
|
4106
4124
|
if stopped:
|
|
4107
4125
|
settle_batches(connection, room_id)
|
|
4126
|
+
return bool(busy)
|
|
4108
4127
|
|
|
4109
4128
|
|
|
4110
4129
|
def withdrawals(connection, room_id):
|
|
@@ -4118,7 +4137,7 @@ def owner_message(connection, room_id, message_id):
|
|
|
4118
4137
|
row = connection.execute("SELECT * FROM messages WHERE room_id=? AND id=?", (room_id, message_id)).fetchone()
|
|
4119
4138
|
if not row:
|
|
4120
4139
|
raise LookupError(Text("消息不存在"))
|
|
4121
|
-
if row["author"] != "用户":
|
|
4140
|
+
if row["author"] != "用户" or connection.execute("SELECT 1 FROM message_relays WHERE message_id=?", (message_id,)).fetchone():
|
|
4122
4141
|
raise ValueError(Text("只能撤回或编辑用户自己的消息"))
|
|
4123
4142
|
if connection.execute("SELECT 1 FROM room_directory WHERE room_id=? AND archived=1", (room_id,)).fetchone():
|
|
4124
4143
|
raise ValueError(Text("房间已存档;恢复后才能撤回或编辑"))
|
|
@@ -4325,6 +4344,41 @@ def linked_room_values(connection, room_id, other, host):
|
|
|
4325
4344
|
return host.strip()
|
|
4326
4345
|
|
|
4327
4346
|
|
|
4347
|
+
def record_relay_send(connection, room_id, token, payload):
|
|
4348
|
+
"""Record one successful linked-room send in the sending room without creating a member request."""
|
|
4349
|
+
require_owner(connection, room_id, token)
|
|
4350
|
+
begin_write(connection)
|
|
4351
|
+
target = payload.get("target_room_id")
|
|
4352
|
+
host = linked_room_values(connection, room_id, target, payload.get("host"))
|
|
4353
|
+
if not connection.execute("SELECT 1 FROM room_links WHERE room_id=? AND other_room_id=?", (room_id, target)).fetchone():
|
|
4354
|
+
raise PermissionError(Text("只有互相关联的房间之间才能代主持人发言"))
|
|
4355
|
+
text, member = payload.get("text"), payload.get("member", "")
|
|
4356
|
+
if not isinstance(text, str) or not text.strip() or len(text.strip()) > 32000 or not isinstance(member, str):
|
|
4357
|
+
raise ValueError(Text("发信留痕须包含有效的正文与成员名称"))
|
|
4358
|
+
identifier = payload.get("submission_id")
|
|
4359
|
+
if not isinstance(identifier, str) or not re.fullmatch(r"[A-Za-z0-9_-]{8,100}", identifier):
|
|
4360
|
+
raise ValueError(Text("submission_id 必须是 8–100 位字母、数字、下划线或连字符"))
|
|
4361
|
+
sent, queued, interrupted = payload.get("target_message_id"), payload.get("queued_id"), payload.get("interrupted", False)
|
|
4362
|
+
if (any(type(value) is not int or value < 1 for value in (sent, queued) if value is not None)
|
|
4363
|
+
or type(interrupted) is not bool or (queued and (sent or interrupted))):
|
|
4364
|
+
raise ValueError(Text("发信留痕的送达或排队状态无效"))
|
|
4365
|
+
previous = connection.execute("""SELECT m.id,m.text,s.target_room_id FROM messages m
|
|
4366
|
+
LEFT JOIN room_relay_sends s ON s.message_id=m.id WHERE m.room_id=? AND m.submission_id=?""",
|
|
4367
|
+
(room_id, identifier)).fetchone()
|
|
4368
|
+
if previous:
|
|
4369
|
+
if previous["target_room_id"] != target or previous["text"] != text:
|
|
4370
|
+
raise FileExistsError(Text("这个提交编号已被另一条内容使用,请为新发言生成新编号"))
|
|
4371
|
+
return {"message_id": previous["id"], "duplicate": True}
|
|
4372
|
+
message_id = connection.execute("""INSERT INTO messages(room_id,author,text,source,submission_id,created_at)
|
|
4373
|
+
VALUES(?,?,?,'room_relay_sent',?,?)""", (room_id, NOTICE_AUTHOR, text, identifier,
|
|
4374
|
+
time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()))).lastrowid
|
|
4375
|
+
connection.execute("INSERT INTO message_details (message_id,kind,submitted_by) VALUES (?,'notice',?)", (message_id, NOTICE_AUTHOR))
|
|
4376
|
+
connection.execute("""INSERT INTO room_relay_sends
|
|
4377
|
+
(message_id,room_id,target_room_id,target_message_id,queued_id,interrupted,host,member) VALUES (?,?,?,?,?,?,?,?)""",
|
|
4378
|
+
(message_id, room_id, target, sent, queued, interrupted, host, member))
|
|
4379
|
+
return {"message_id": message_id, "duplicate": False}
|
|
4380
|
+
|
|
4381
|
+
|
|
4328
4382
|
def record_room_link(connection, room_id, token, payload):
|
|
4329
4383
|
"""Leave a card naming a room this room's host created (`child`) or the room whose host created this one (`parent`).
|
|
4330
4384
|
|
|
@@ -4367,6 +4421,8 @@ def check_relay(connection, room_id, relay):
|
|
|
4367
4421
|
if not isinstance(relay, dict):
|
|
4368
4422
|
raise ValueError(Text("relay 须为含 room_id 与 host 的对象"))
|
|
4369
4423
|
host = linked_room_values(connection, room_id, relay.get("room_id"), relay.get("host"))
|
|
4424
|
+
if not isinstance(relay.get("member", ""), str):
|
|
4425
|
+
raise ValueError(Text("relay.member 须为成员名称"))
|
|
4370
4426
|
source, limit = relay["room_id"], relay.get("limit", 0)
|
|
4371
4427
|
if type(limit) is not int or not 0 <= limit <= MAX_RELAY_LIMIT:
|
|
4372
4428
|
raise ValueError(Text("relay.limit 须为 0–100 的整数,0 表示不限"))
|
|
@@ -4386,7 +4442,7 @@ def check_relay(connection, room_id, relay):
|
|
|
4386
4442
|
def save_message_relay(connection, room_id, message_id, relay):
|
|
4387
4443
|
"""Label an owner-credential message the host of another room sent: `relay = {room_id, host}`."""
|
|
4388
4444
|
host = check_relay(connection, room_id, relay)
|
|
4389
|
-
connection.execute("INSERT INTO message_relays (message_id,source_room_id,host) VALUES (
|
|
4445
|
+
connection.execute("INSERT INTO message_relays (message_id,source_room_id,host,member) VALUES (?,?,?,?)", (message_id, relay["room_id"], host, relay.get("member", "")))
|
|
4390
4446
|
|
|
4391
4447
|
|
|
4392
4448
|
def record_model_change(connection, room_id, member, payload):
|
package/backend/message_queue.py
CHANGED
|
@@ -51,6 +51,13 @@ def queue_view(connection, room_id):
|
|
|
51
51
|
(room_id, json.dumps(payload.get("attachment_ids", []))))]
|
|
52
52
|
item = {"id": row["id"], "text": payload.get("text", ""), "attachments": files, "failure": row["failure"],
|
|
53
53
|
"texts": load_texts(connection, "queued_message", row["id"]), "created_at": row["created_at"]}
|
|
54
|
+
if relay := payload.get("relay"):
|
|
55
|
+
source = relay["room_id"]
|
|
56
|
+
details = connection.execute("""SELECT (SELECT title FROM rooms WHERE id=?) AS relay_title,
|
|
57
|
+
(SELECT relation FROM room_links WHERE room_id=? AND other_room_id=?) AS relay_relation,
|
|
58
|
+
COALESCE(NULLIF(?,''),(SELECT name FROM room_members WHERE room_id=? AND role='host' AND status='active')) AS relay_member""",
|
|
59
|
+
(source, room_id, source, relay.get("member", ""), source)).fetchone()
|
|
60
|
+
item.update(relay_room=source, relay_host=relay["host"], **dict(details))
|
|
54
61
|
if named_members(connection, room_id, payload) is not None:
|
|
55
62
|
item["to"] = payload["to"]
|
|
56
63
|
if payload.get("message_id"):
|
|
@@ -309,6 +316,8 @@ def queued_row(connection, room_id, item_id):
|
|
|
309
316
|
def edit_item(connection, row, text, check):
|
|
310
317
|
"""Replace a queued message's text; `check` validates the edited payload as a message would be."""
|
|
311
318
|
payload = json.loads(row["payload"])
|
|
319
|
+
if payload.get("relay"):
|
|
320
|
+
raise PermissionError(Text("只能编辑用户自己的消息"))
|
|
312
321
|
if payload.get("message_id"):
|
|
313
322
|
raise FileExistsError(Text('这条消息已发出,只是还在等忙碌的成员;可以删除后重新发送'))
|
|
314
323
|
payload["text"] = str(text if text is not None else "").strip()
|
package/backend/schema.sql
CHANGED
|
@@ -118,12 +118,24 @@ CREATE TABLE IF NOT EXISTS room_links (
|
|
|
118
118
|
host TEXT NOT NULL,
|
|
119
119
|
UNIQUE(room_id, other_room_id)
|
|
120
120
|
);
|
|
121
|
+
-- Sender-side receipts survive deletion of the destination room.
|
|
122
|
+
CREATE TABLE IF NOT EXISTS room_relay_sends (
|
|
123
|
+
message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE,
|
|
124
|
+
room_id TEXT NOT NULL REFERENCES rooms(id) ON DELETE CASCADE,
|
|
125
|
+
target_room_id TEXT NOT NULL,
|
|
126
|
+
target_message_id INTEGER,
|
|
127
|
+
queued_id INTEGER,
|
|
128
|
+
interrupted INTEGER NOT NULL DEFAULT 0,
|
|
129
|
+
host TEXT NOT NULL,
|
|
130
|
+
member TEXT NOT NULL DEFAULT ''
|
|
131
|
+
);
|
|
121
132
|
-- An owner-credential message the host of another room sent here through `host-control room-post`: where it came from.
|
|
122
133
|
-- Only a label; the write itself is the owner's, so it routes and wakes like the owner's own message.
|
|
123
134
|
CREATE TABLE IF NOT EXISTS message_relays (
|
|
124
135
|
message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE,
|
|
125
136
|
source_room_id TEXT NOT NULL,
|
|
126
|
-
host TEXT NOT NULL
|
|
137
|
+
host TEXT NOT NULL,
|
|
138
|
+
member TEXT NOT NULL DEFAULT ''
|
|
127
139
|
);
|
|
128
140
|
-- Site administrator account (single user) and its login sessions. Raw tokens and passwords are never stored.
|
|
129
141
|
CREATE TABLE IF NOT EXISTS site_admin (
|