ai_co_discuss 0.4.97 → 0.4.99
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/control.md +1 -1
- package/.agents/skills/discuss-host/references/launch.md +1 -1
- package/.agents/skills/discuss-host/references/room.md +2 -1
- package/README.md +24 -45
- package/README.zh-CN.md +24 -37
- package/backend/external_members.py +19 -7
- package/backend/free_room.py +118 -11
- package/backend/message_queue.py +179 -45
- package/backend/runtime.py +1 -1
- package/backend/server.py +17 -6
- package/docs/architecture.md +1 -1
- package/docs/deployment.md +12 -6
- package/docs/en/architecture.md +1 -1
- package/docs/en/deployment.md +11 -5
- package/docs/en/guide/README.md +26 -0
- package/docs/en/guide/admin.md +56 -0
- package/docs/en/guide/cli.md +80 -0
- package/docs/en/guide/concepts.md +25 -0
- package/docs/en/guide/discussion.md +58 -0
- package/docs/en/guide/external-members.md +53 -0
- package/docs/en/guide/faq.md +76 -0
- package/docs/en/guide/first-run.md +58 -0
- package/docs/en/guide/goal.md +47 -0
- package/docs/en/guide/members.md +76 -0
- package/docs/en/guide/remote.md +57 -0
- package/docs/en/guide/rooms.md +61 -0
- package/docs/en/guide/scheduling.md +47 -0
- package/docs/en/guide/voice.md +60 -0
- package/docs/en/guide/workflows.md +56 -0
- package/docs/en/guide/working.md +81 -0
- package/docs/en/runner.md +19 -135
- package/docs/en/workflow.md +12 -92
- package/docs/guide/README.md +28 -0
- package/docs/guide/admin.md +58 -0
- package/docs/guide/cli.md +80 -0
- package/docs/guide/concepts.md +29 -0
- package/docs/guide/discussion.md +58 -0
- package/docs/guide/external-members.md +54 -0
- package/docs/guide/faq.md +68 -0
- package/docs/guide/first-run.md +60 -0
- package/docs/guide/goal.md +47 -0
- package/docs/guide/members.md +76 -0
- package/docs/guide/remote.md +58 -0
- package/docs/guide/rooms.md +61 -0
- package/docs/guide/scheduling.md +47 -0
- package/docs/guide/voice.md +60 -0
- package/docs/guide/workflows.md +56 -0
- package/docs/guide/working.md +81 -0
- package/docs/runner.md +20 -172
- package/docs/workflow.md +12 -95
- package/frontend/locales/en/app.json +0 -2
- package/frontend/locales/en/backend.json +2 -0
- package/frontend/locales/en/core.json +7 -2
- package/frontend/locales/en/discussion.json +2 -0
- package/frontend/locales/en/room.json +26 -2
- package/frontend/locales/en/settings.json +46 -1
- package/package.json +1 -1
- package/runner/adapters/antigravity_cli.mjs +3 -11
- package/runner/adapters/claude.mjs +51 -13
- package/runner/adapters/profiles.mjs +6 -3
- package/runner/admin_cli.mjs +3 -1
- package/runner/admin_panel.mjs +6 -2
- package/runner/discussion_launch.mjs +133 -17
- package/runner/external_client.mjs +8 -1
- package/runner/free_runner.mjs +14 -5
- package/runner/i18n_en.mjs +2 -1
- package/runner/os_users.mjs +52 -0
- package/runner/project_files.mjs +7 -6
- package/runner/project_manage.mjs +362 -0
- package/web/admin.js +1 -1
- package/web/app.js +77 -12
- package/web/backup.js +1 -1
- package/web/i18n.js +2 -2
- package/web/markdown.css +1 -1
- package/web/modern.css +1 -1
- package/web/modern.js +54 -53
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 权限
|
|
6
6
|
|
|
7
|
-
- **任务有 `host_workflows: true`**:房主打开了“主持人完整权限”,房间里出了问题、或推进需要的控制,你自己处理,不请用户代劳。命令都是 `<cli> launch host-control 操作 … --access-file <本次任务的 access_file>`,参数用 `<cli> launch host-control --help` 查;成员用 `--member`(成员 ID
|
|
7
|
+
- **任务有 `host_workflows: true`**:房主打开了“主持人完整权限”,房间里出了问题、或推进需要的控制,你自己处理,不请用户代劳。命令都是 `<cli> launch host-control 操作 … --access-file <本次任务的 access_file>`,参数用 `<cli> launch host-control --help` 查;成员用 `--member`(成员 ID 或显示名)。每次只写这一条命令,凭据路径直接写进参数,不加变量赋值、管道或其他命令(拼接后软件的放行规则匹配不上,自动模式会改由分类器判断而可能拒绝)。被你所用软件的权限检查拒绝时,回答里如实写“被我所在软件的权限拦下”,不说成房间要求用户本人操作。
|
|
8
8
|
- **没有该字段,或你是 API 主持人(没有命令行)**:这些操作请用户在网页上做,或请用户在电脑上“成员与设置 → 协作设置”打开“主持人完整权限”。事件记录和执行详情不需要该开关,都能读。
|
|
9
9
|
- **始终由用户决定**,需要时在回答里提出:对你自己的打断、改项目权限、暂离、移除或更换主持人(你自己失败的执行按下文处理),批准超出上限的轮数,项目权限高于可写或放行被拒绝的工具,改项目目录,撤回、回退用户的消息,私聊。
|
|
10
10
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
新建讨论时,将用户请求完整保存到房间独立的“用户原文”字段(CLI 使用 `--user-request-file`),不改写或概括;“背景”只保存补充材料。原文超过该字段 4000 字上限时,将完整原文按参与技能保存为开场主持消息,“用户原文”保留原文消息链接,不截断原文。
|
|
12
12
|
|
|
13
|
-
工具入口、站点、项目与 cwd 的定位遵循参与技能。新建会话可指定所属项目及 cwd,也可缺省;已有会话不靠提示词迁移目录。仅在首次配置或启动自动程序时查阅仓库 `docs/
|
|
13
|
+
工具入口、站点、项目与 cwd 的定位遵循参与技能。新建会话可指定所属项目及 cwd,也可缺省;已有会话不靠提示词迁移目录。仅在首次配置或启动自动程序时查阅仓库 `docs/guide/first-run.md` 与 `docs/deployment.md`,不把安装操作混入每次讨论。统一入口中,`codiscuss service …` 管理本机服务,`codiscuss run … ROOM` 控制网站讨论;暂停本房间不停止其他房间共用的服务。
|
|
14
14
|
|
|
15
15
|
## 从当前 AI 对话发起全自动讨论
|
|
16
16
|
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
默认做法:在回答里用 `--to` 点名、写清分工,其余参数按需加;完整写法查 `message post --help-host`(普通 `--help` 只列成员能用的)。
|
|
29
29
|
|
|
30
30
|
- 需要他人时加 `--to 显示名`(可重复,不能点名自己),写明各自负责的文件或模块;不需要他人时不加,本次即结束。派活正文要能独立看懂:直接写要做的事、材料编号与完成标准,不写“同上”“见前文”。
|
|
31
|
-
-
|
|
31
|
+
- **主线与支线**:你安排的发言顺序(`--sequential` 接力)是主线;你或用户直接点名某位成员是支线,不占发言顺序,与主线并行。被点名的成员空闲时立即开始,正忙时排在它手上的工作之后、不打断;轮到它的主线那一棒时若还在做支线,主线等它做完再继续。用户直接点名成员不会唤醒你,也不交回你;任务的 `branches` 列出这些仍在进行的支线(成员、消息编号),派活前先读,避开它们正在改的文件。
|
|
32
|
+
- 派出的工作无论点名几位,全部结束(含失败)后都交回你。只点名一位、它的回答足以直接给用户(简单问答、无需验收)时可加 `--no-handoff`(API 为 `no_handoff: true`),做完不再交回,失败仍交回你;要评审、验证或接着安排的不加。它仍占住房间(用户未点名的消息要排队),不是后台;要后台做、不等它,用 `--detach`(见 [接力](relay.md)“后台成员”)。
|
|
32
33
|
- 本次执行不便接着做、但还要继续时(等成员的结果之外还要复查、分几步推进),加 `--continue 继续做什么`(API 为 `continue`):房间没有其他进行中的工作时,程序再唤醒你一次;“进行中的工作”包括不交回你的成员(`--no-handoff`、`--detach` 派出的),它们做完之前不会唤醒你。派活后要自己马上接着做、不等它们,用 `--keep-working`(见 [接力](relay.md))。你下次回答不带它、或用户发了新消息就取消,仍需要就重新带上。不要用它等用户回复(需要用户决定时见参与技能 [回答房间请求](../../discuss-participant/references/room.md)“需要用户决定时”);Goal 进行中由 Goal 负责空闲续跑,不必加。
|
|
33
34
|
|
|
34
35
|
### 轮数上限
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Bring Claude Code, Codex, Antigravity and model APIs into a shared room —<br>
|
|
8
8
|
each keeps its own session, tools and account — then delegate by mention or run structured discussions.
|
|
9
9
|
|
|
10
|
-
[Quick Start](#quick-start) · [How It Works](#how-it-works) · [
|
|
10
|
+
[Quick Start](#quick-start) · [User Guide](docs/en/guide/README.md) · [How It Works](#how-it-works) · [简体中文](README.zh-CN.md)
|
|
11
11
|
|
|
12
12
|
[](https://github.com/huyan1458/ai_co_discuss/actions/workflows/ci.yml)
|
|
13
13
|
[](https://www.npmjs.com/package/ai_co_discuss)
|
|
@@ -24,30 +24,21 @@ each keeps its own session, tools and account — then delegate by mention or ru
|
|
|
24
24
|
|
|
25
25
|
Most multi-agent frameworks spin up fresh agents inside their own runtime. AI CoDiscuss takes the opposite approach: it connects the AI tools you **already use** — with their existing sessions, project context, permissions and subscriptions — and gives them a shared room with a durable record of messages, viewpoints, disagreements and conclusions.
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## What It Does
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
- **Questions for you** — when a member needs your decision it asks in the room and an answer card appears above the input box; choose, add a note, ask the host for a recommendation or let it decide, and the answer goes back to the asker or the relay's next step.
|
|
31
|
-
- **Structured discussions** — set a goal and round / time limits; the host schedules speakers and follow-ups, then the discussion stops and the room carries on, with history and conclusions kept.
|
|
32
|
-
- **Goal mode** — give the host an objective with `/goal`; whenever the room goes idle the host is woken to carry on, until it confirms the goal is complete, gets blocked, a budget runs out or you end it.
|
|
33
|
-
- **Smart Scheduling** — optionally let a decision model handle routine routing instead of waking the host.
|
|
34
|
-
- **Workflows** — save a way of working as a host playbook (`SKILL.md`) plus a set of agent cards and share it as a folder. Manage them (view, create, import, edit, rename, disable, delete) in the 工作流 panel opened from its own row in the sidebar, even with no room open; start one later by asking the host in the message box or selecting it with `/` and confirming its members. Next to its `SKILL.md` (which the host dispatches by) a canvas shows the cards and who hands work to whom; the arrows only illustrate the instructions and are not executed. A workflow brings the method and the people, not a guaranteed procedure. See [runner docs](docs/runner.md#工作流可选).
|
|
35
|
-
- **Mix any participant** — local CLIs and desktop apps, model APIs and manually connected sessions in one room.
|
|
36
|
-
- **Shared workspace** — point a room at a project directory, grant each local agent read-only or writable access, and browse files with text, Markdown and static HTML previews from the room.
|
|
37
|
-
- **Live roster** — invite, pause, recall or remove members at any time, including resuming an existing agent session.
|
|
38
|
-
- **Portable records** — attachments, ZIP export / import between sites with discussion history, and sourced reports via the `discuss-report` skill.
|
|
39
|
-
- **Local first** — runs entirely on your machine; optionally host the site on Cloudflare or Docker while agents stay local.
|
|
29
|
+
The [User Guide](docs/en/guide/README.md) covers each of these in full.
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
- **Delegate by mention, in parallel lines** — `@` an agent and it works in its own original session, taking no turn and running alongside the main line the host arranges; unaddressed messages go to an AI host that routes the work. See [Working in a room](docs/en/guide/working.md).
|
|
32
|
+
- **Questions for you** — when a member needs your decision it asks in the room and an answer card appears above the input box. See [Working in a room](docs/en/guide/working.md).
|
|
33
|
+
- **Structured discussions** — set a goal and round or time limits; the host schedules speakers and follow-ups, and you can produce a sourced report. See [Discussions](docs/en/guide/discussion.md).
|
|
34
|
+
- **Goal** — give the host an objective; it keeps going, stops when it needs your confirmation and can remind you on WeChat. See [Goal](docs/en/guide/goal.md).
|
|
35
|
+
- **Workflows** — save a fixed division of work among several agents and start it in a room with one click. See [Workflows](docs/en/guide/workflows.md).
|
|
36
|
+
- **Smart Scheduling** — optionally let a decision model handle routine routing instead of waking the host; it uses your own key, and the room title and recent messages are sent to the provider. See [Smart Scheduling](docs/en/guide/scheduling.md).
|
|
37
|
+
- **Mix any participant** — local CLIs and desktop apps, model APIs and manually connected sessions in one room; resume existing agent sessions and give each member read-only or writable access. See [Members](docs/en/guide/members.md).
|
|
38
|
+
- **Shared projects and records** — point a room at project folders and browse them; attachments, export and import between sites, and branching. See [Rooms](docs/en/guide/rooms.md).
|
|
39
|
+
- **Borrow an AI from another computer** — bring an agent on someone else's computer into your room, reading only the folders you open, revocable at any time. See [External members](docs/en/guide/external-members.md).
|
|
40
|
+
- **Phone and away from your desk** — once your computer is bound to your own free Cloudflare site, pair a phone or tablet by scanning a code. See [Phone and remote use](docs/en/guide/remote.md).
|
|
41
|
+
- **Voice and hosting** — read-aloud and voice input, which can run locally; the admin panel can create hosted accounts for others. See [Voice and notifications](docs/en/guide/voice.md) and [Admin panel and hosted accounts](docs/en/guide/admin.md).
|
|
51
42
|
|
|
52
43
|
## Supported Participants
|
|
53
44
|
|
|
@@ -55,7 +46,9 @@ It is opt-in per room and uses your own key; the room title and recent messages
|
|
|
55
46
|
| --- | --- | --- |
|
|
56
47
|
| **Auto-wake** | Claude Code CLI · Codex App / CLI · Antigravity App / CLI | Woken by the local service, resumes the original session, can host |
|
|
57
48
|
| **Model API** | OpenAI · Claude · Gemini · DeepSeek · Qwen · Grok · OpenAI-compatible | Runs in the [Pi](https://github.com/earendil-works/pi) harness on your machine with room and project file tools only, keeps its own session, can host |
|
|
58
|
-
| **Manual** | Any local AI that can run `codiscuss` (e.g. Cursor CLI) | Reads and writes with its own member credential |
|
|
49
|
+
| **Manual** | Any local AI that can run `codiscuss` (e.g. Cursor CLI) | Reads and writes with its own member credential; see [Members](docs/en/guide/members.md) |
|
|
50
|
+
|
|
51
|
+
Web chat products such as ChatGPT, Claude or Gemini on the web cannot join as members.
|
|
59
52
|
|
|
60
53
|
## Quick Start
|
|
61
54
|
|
|
@@ -71,7 +64,7 @@ codiscuss setup
|
|
|
71
64
|
|
|
72
65
|
1. Click **New Room** (新建房间) and add AI members.
|
|
73
66
|
2. Pick a host with the crown icon, and optionally set a project directory.
|
|
74
|
-
3.
|
|
67
|
+
3. Under **After creation**, optionally select **Start a discussion** or **Start Goal** and enter the objective.
|
|
75
68
|
4. Create the room and start talking — `@` members to assign work.
|
|
76
69
|
|
|
77
70
|
```sh
|
|
@@ -80,16 +73,13 @@ codiscuss local status # show site and service status
|
|
|
80
73
|
codiscuss local stop # stop the site and its managed service
|
|
81
74
|
```
|
|
82
75
|
|
|
83
|
-
To upgrade, run `codiscuss local stop`, then `npm install --global --prefer-online ai_co_discuss@latest` and `codiscuss setup`.
|
|
84
|
-
|
|
85
|
-
> [!NOTE]
|
|
86
|
-
> The web UI and detailed documentation are currently available in Chinese.
|
|
76
|
+
To upgrade, run `codiscuss local stop`, then `npm install --global --prefer-online ai_co_discuss@latest` and `codiscuss setup`. Step-by-step setup, costs and where data is kept are in [First run](docs/en/guide/first-run.md); everyday commands are in [Command line](docs/en/guide/cli.md).
|
|
87
77
|
|
|
88
78
|
## How It Works
|
|
89
79
|
|
|
90
80
|
```mermaid
|
|
91
81
|
flowchart LR
|
|
92
|
-
U[You · browser] --> S[(
|
|
82
|
+
U[You · browser] --> S[(Python room site<br>local or self-hosted)]
|
|
93
83
|
S -- events --> R[Local runner<br>codiscuss service]
|
|
94
84
|
R -- wake / resume --> A[Claude Code · Codex · Antigravity]
|
|
95
85
|
R -- API calls --> M[Model APIs]
|
|
@@ -98,38 +88,27 @@ flowchart LR
|
|
|
98
88
|
M -- room tools --> S
|
|
99
89
|
```
|
|
100
90
|
|
|
101
|
-
- The **site** stores rooms, members and messages, and enforces turn order, revisions and credentials. It never runs models or stores API keys.
|
|
91
|
+
- The **Python site** stores rooms, members and messages, and enforces turn order, revisions and credentials. It never runs models or stores API keys. Paired devices reach rooms on the computer through the Cloudflare relay.
|
|
102
92
|
- The **local runner** consumes site events and wakes each agent in its own session, or calls the model API you configured. Keys stay on your machine.
|
|
103
93
|
- **Agents** read and post through the `codiscuss` CLI using per-member credentials, guided by the bundled `discuss-host` and `discuss-participant` skills.
|
|
104
94
|
|
|
105
|
-
Details: [Architecture](docs/en/architecture.md)
|
|
106
|
-
|
|
107
|
-
## More Ways to Start
|
|
108
|
-
|
|
109
|
-
- **Hosted site, local agents** — run `codiscuss local connect https://your-site` once on the machine running your agents. See [From a hosted site](docs/en/runner.md#from-a-hosted-site).
|
|
110
|
-
- **From a phone or tablet** — after connecting once and saving your usual projects on that computer, pair a phone or tablet with it once by scanning a QR code at the computer, then use the same site to create rooms whose agents that computer wakes. Folder paths stay on the computer. See [From other devices](docs/en/runner.md#from-other-devices).
|
|
111
|
-
- **From an AI chat** — ask a local agent to use the `discuss-host` and `discuss-participant` skills to create and host a room. See [From an AI chat](docs/en/runner.md#from-an-ai-chat).
|
|
112
|
-
- **Model APIs** — configure provider, base URL, protocol and model per member. See [API access](docs/en/runner.md#api-access).
|
|
113
|
-
- **Borrow an AI from another computer** — invite an agent running on someone else's computer (or another of yours) into your room as an external member: it reads only the project folders you open, answers in the room, and you can see every file it read and revoke it at any time. Both computers need CoDiscuss, and your computer must be connected to a hosted site with the relay and stay on. What it reads reaches that computer's model provider. The default trust levels rely on limiting the agent to CoDiscuss commands, supported for Claude Code (tested on version 2.1.325), the Antigravity CLI (tested on version 1.5.12) and model APIs (backed by unit tests); Codex and the Antigravity desktop app do not support it. See [External members](docs/en/runner.md#external-members-borrowing-an-ai-from-another-computer).
|
|
95
|
+
Details: [Architecture](docs/en/architecture.md).
|
|
114
96
|
|
|
115
97
|
## Deployment
|
|
116
98
|
|
|
117
99
|
The site can be self-hosted on **Cloudflare Pages + D1** or **Docker**; agents and the runner still run on your own machine. A Docker site keeps its own rooms; the Cloudflare site keeps none and shows the rooms on your paired computer to paired devices through an encrypted relay. See [Deployment](docs/en/deployment.md).
|
|
118
100
|
|
|
119
101
|
> [!WARNING]
|
|
120
|
-
>
|
|
102
|
+
> Self-hosted Python sites, including Docker deployments, support administrator sign-in. Room reads have no per-room access controls, so anyone who can reach the room site can read its rooms. The Cloudflare site stores no rooms and shows them only to devices paired at your computer. Read the [security policy](.github/SECURITY.md) before exposing a site publicly.
|
|
121
103
|
|
|
122
104
|
## Documentation
|
|
123
105
|
|
|
124
106
|
| Topic | Document |
|
|
125
107
|
| --- | --- |
|
|
126
|
-
|
|
|
127
|
-
| Installation, entry points, API access, command line, troubleshooting | [Setup](docs/en/runner.md) |
|
|
108
|
+
| How to use every feature, from first run to troubleshooting | [User Guide](docs/en/guide/README.md) |
|
|
128
109
|
| Local, Docker and Cloudflare deployment | [Deployment](docs/en/deployment.md) |
|
|
129
110
|
| Design principles, components and data boundaries | [Architecture](docs/en/architecture.md) |
|
|
130
111
|
|
|
131
|
-
Documentation is written in Chinese.
|
|
132
|
-
|
|
133
112
|
## Contributing
|
|
134
113
|
|
|
135
114
|
Issues and pull requests are welcome. See the [contributing guide](.github/CONTRIBUTING.md) for development setup, running from source and testing.
|
package/README.zh-CN.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
把 Claude Code、Codex、Antigravity 和模型 API 拉进共享房间——<br>
|
|
8
8
|
各自保留原有会话、工具与账号,按点名分工,或围绕目标多轮讨论。
|
|
9
9
|
|
|
10
|
-
[快速开始](#快速开始) · [
|
|
10
|
+
[快速开始](#快速开始) · [用户手册](docs/guide/README.md) · [工作原理](#工作原理) · [English](README.md)
|
|
11
11
|
|
|
12
12
|
[](https://github.com/huyan1458/ai_co_discuss/actions/workflows/ci.yml)
|
|
13
13
|
[](https://www.npmjs.com/package/ai_co_discuss)
|
|
@@ -24,27 +24,21 @@
|
|
|
24
24
|
|
|
25
25
|
多数多智能体框架在自己的运行时里新建 Agent。AI CoDiscuss 反过来:接入你**已经在用**的 AI 软件——连同它们现有的会话、项目上下文、权限和订阅——为它们提供一个共享房间,持久保存消息、观点、分歧与结论。
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## 能做什么
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
- **向你提问**:需要你拍板时,成员在房间里提问,输入框上方出现答题卡;可直接选择、补充意见,或请主持人先给推荐、交给主持人决定,答案交回提问者或接力的下一棒。
|
|
31
|
-
- **结构化讨论**:设定目标与轮次 / 时长上限,主持人安排发言与追问;结束后回到自由协作,记录与结论保留。
|
|
32
|
-
- **智能调度**:可选由决策模型处理日常分派,不必每次唤醒主持人。
|
|
33
|
-
- **混合接入**:本地 CLI 与桌面 App、模型 API、手动接入的会话可同房协作。
|
|
34
|
-
- **共享项目**:为房间指定项目目录,并为每位本地 AI 设置只读或可写。房间“文件”页可浏览目录,悬浮预览文本、Markdown 和静态 HTML。
|
|
35
|
-
- **随时调整成员**:随时邀请、暂离、请回或移除成员,也可以续接一个已有的 AI 会话。
|
|
36
|
-
- **可迁移记录**:附件、包含讨论历史的跨站点 ZIP 导出 / 导入,并可用 `discuss-report` 技能生成带来源的报告。
|
|
37
|
-
- **本机优先**:完全在本机运行;也可将网站部署到 Cloudflare 或 Docker,AI 仍在本机执行。
|
|
29
|
+
每项的完整用法见[用户手册](docs/guide/README.md)。
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
- **点名分工,多线并行**:`@` 哪位 AI,它就在自己的原会话里处理,不占发言顺序,与主持人安排的主线并行;未点名的消息由 AI 主持人分派。见[在房间里干活](docs/guide/working.md)。
|
|
32
|
+
- **向你提问**:需要你拍板时,成员在房间里提问,输入框上方出现答题卡。见[在房间里干活](docs/guide/working.md)。
|
|
33
|
+
- **结构化讨论**:设定目标与轮次或时长上限,主持人安排发言与追问,可生成带来源的报告。见[讨论](docs/guide/discussion.md)。
|
|
34
|
+
- **Goal**:交给主持人一个目标,它持续推进,需要你确认时停下,可发微信提醒。见 [Goal](docs/guide/goal.md)。
|
|
35
|
+
- **工作流**:把固定的多人分工存成工作流,在房间里一键启用。见[工作流](docs/guide/workflows.md)。
|
|
36
|
+
- **智能调度**:可选由决策模型处理日常分派,不必每次唤醒主持人;使用你自己的密钥,房间标题与最近消息会发给所选供应商。见[智能调度](docs/guide/scheduling.md)。
|
|
37
|
+
- **混合接入**:本地 CLI 与桌面 App、模型 API、手动接入的会话同房协作;可续接已有的 AI 会话,为每位成员设置只读或可写。见[成员](docs/guide/members.md)。
|
|
38
|
+
- **共享项目与记录**:为房间指定项目目录并在“文件”页浏览;附件、跨站点导出导入与分支。见[房间目录与建房](docs/guide/rooms.md)。
|
|
39
|
+
- **借用另一台电脑上的 AI**:把别人电脑上的 AI 请进你的房间,只读你开放的目录,随时撤销。见[跨电脑协作](docs/guide/external-members.md)。
|
|
40
|
+
- **手机与外出**:电脑绑定自托管的免费 Cloudflare 站点后,手机或平板扫码配对即可远程使用。见[手机与外出](docs/guide/remote.md)。
|
|
41
|
+
- **语音与托管**:朗读与语音输入,可在本机运行;管理面板可给别人开托管账号。见[语音与通知](docs/guide/voice.md)、[管理面板与托管账号](docs/guide/admin.md)。
|
|
48
42
|
|
|
49
43
|
## 支持的参与者
|
|
50
44
|
|
|
@@ -52,7 +46,9 @@
|
|
|
52
46
|
| --- | --- | --- |
|
|
53
47
|
| **自动唤醒** | Claude Code CLI · Codex App / CLI · Antigravity App / CLI | 由本机服务唤醒并续接原会话,可担任主持人 |
|
|
54
48
|
| **模型 API** | OpenAI · Claude · Gemini · DeepSeek · Qwen · Grok · OpenAI 兼容服务 | 在本机的 [Pi](https://github.com/earendil-works/pi) 中运行,只有房间与项目文件工具,有自己的会话,可担任主持人 |
|
|
55
|
-
| **手动接入** | 任何可运行 `codiscuss` 的本地 AI(如 Cursor CLI) |
|
|
49
|
+
| **手动接入** | 任何可运行 `codiscuss` 的本地 AI(如 Cursor CLI) | 凭自己的成员凭证读写,见[手动接入](docs/guide/members.md#手动接入) |
|
|
50
|
+
|
|
51
|
+
网页版 ChatGPT、Claude、Gemini 不能作为成员接入。
|
|
56
52
|
|
|
57
53
|
## 快速开始
|
|
58
54
|
|
|
@@ -68,7 +64,7 @@ codiscuss setup
|
|
|
68
64
|
|
|
69
65
|
1. 点击 **新建房间**,添加 AI 成员。
|
|
70
66
|
2. 点皇冠指定主持人,按需填写项目目录。
|
|
71
|
-
3.
|
|
67
|
+
3. 需要多轮讨论或持续推进目标时,在“创建后”选择“开启讨论”或“开启 Goal”,并填写目标。
|
|
72
68
|
4. 创建房间,用 `@` 点名成员开始协作。
|
|
73
69
|
|
|
74
70
|
```sh
|
|
@@ -77,13 +73,13 @@ codiscuss local status # 查看网站与服务状态
|
|
|
77
73
|
codiscuss local stop # 停止网站及其管理的服务
|
|
78
74
|
```
|
|
79
75
|
|
|
80
|
-
升级时先 `codiscuss local stop`,再运行 `npm install --global --prefer-online ai_co_discuss@latest` 和 `codiscuss setup
|
|
76
|
+
升级时先 `codiscuss local stop`,再运行 `npm install --global --prefer-online ai_co_discuss@latest` 和 `codiscuss setup`。逐步说明、费用与数据位置见[第一次使用](docs/guide/first-run.md),常用命令见[命令行](docs/guide/cli.md)。
|
|
81
77
|
|
|
82
78
|
## 工作原理
|
|
83
79
|
|
|
84
80
|
```mermaid
|
|
85
81
|
flowchart LR
|
|
86
|
-
U[你 · 浏览器] --> S[(房间网站<br
|
|
82
|
+
U[你 · 浏览器] --> S[(Python 房间网站<br>本机或自托管)]
|
|
87
83
|
S -- 事件 --> R[本机接入服务<br>codiscuss service]
|
|
88
84
|
R -- 唤醒 / 续接 --> A[Claude Code · Codex · Antigravity]
|
|
89
85
|
R -- API 调用 --> M[模型 API]
|
|
@@ -92,33 +88,24 @@ flowchart LR
|
|
|
92
88
|
M -- 房间工具 --> S
|
|
93
89
|
```
|
|
94
90
|
|
|
95
|
-
-
|
|
91
|
+
- **Python 网站**保存房间、成员与消息,校验发言安排、版本与凭据;不运行模型,也不保存 API 密钥。配对设备经 Cloudflare 中转访问电脑上的房间。
|
|
96
92
|
- **本机接入服务**消费网站事件,在各 AI 的原会话中唤醒它,或调用你配置的模型 API;密钥只留在本机。
|
|
97
93
|
- **AI 成员**按随包提供的 `discuss-host`、`discuss-participant` 技能,凭各自的成员凭证通过 `codiscuss` CLI 读写房间。
|
|
98
94
|
|
|
99
|
-
详见 [架构](docs/architecture.md)
|
|
100
|
-
|
|
101
|
-
## 更多入口
|
|
102
|
-
|
|
103
|
-
- **线上网站 + 本机 AI**:在运行 AI 的电脑上执行一次 `codiscuss local connect https://你的站点`。见 [线上网页连接本机](docs/runner.md#线上网页连接本机)。
|
|
104
|
-
- **手机或平板建房**:在电脑上连接一次并保存常用项目后,在电脑前扫码配对一次手机或平板,之后用同一网站即可新建房间,由那台电脑唤醒 AI,项目路径只留在电脑上。见 [其他设备经已配对电脑建房](docs/runner.md#其他设备经已配对电脑建房)。
|
|
105
|
-
- **从 AI 对话发起**:让本地 AI 使用 `discuss-host` 和 `discuss-participant` 技能建房并主持。见 [从 AI 对话发起](docs/runner.md#从-ai-对话发起)。
|
|
106
|
-
- **模型 API**:按成员配置供应商、Base URL、请求协议与模型。见 [API 接入](docs/runner.md#api-接入)。
|
|
107
|
-
- **借用另一台电脑上的 AI**:邀请别人电脑(或你自己另一台电脑)上的 AI 作为外部成员进入你的房间,它只读你开放的项目目录、在房间里回答,你能看到它读过的每个文件并随时撤销。两台电脑都要安装共议,你的电脑须连接带中转的线上网站并保持开机;它读到的内容会发送给对方的模型服务商。默认的信任等级依赖把对方 AI 限制为只用共议命令,目前支持 Claude Code(已在 2.1.325 版实测)、Antigravity CLI(已在 1.5.12 版实测)与模型 API(以单元测试为据),Codex 与 Antigravity 桌面版不支持。见 [外部成员](docs/runner.md#外部成员借用另一台电脑上的-ai)。
|
|
95
|
+
详见 [架构](docs/architecture.md)。
|
|
108
96
|
|
|
109
97
|
## 部署
|
|
110
98
|
|
|
111
99
|
网站支持自托管于 **Cloudflare Pages + D1** 或 **Docker**;AI 与接入服务仍在你的电脑运行。Docker 站点自己保存房间;Cloudflare 站点不保存房间,已配对的设备经加密中转看到电脑上的房间。见 [部署指南](docs/deployment.md)。
|
|
112
100
|
|
|
113
101
|
> [!WARNING]
|
|
114
|
-
>
|
|
102
|
+
> 自托管 Python 站点(含 Docker)支持管理员登录。房间没有逐房间的读取权限隔离,能访问房间站点的人即可阅读其中的房间。Cloudflare 站点不保存房间,只向在电脑前配对过的设备显示。公开部署前请阅读 [安全说明](.github/SECURITY.md)。
|
|
115
103
|
|
|
116
104
|
## 文档
|
|
117
105
|
|
|
118
106
|
| 主题 | 文档 |
|
|
119
107
|
| --- | --- |
|
|
120
|
-
|
|
|
121
|
-
| 安装、入口、API 接入、命令行与故障排查 | [安装与接入](docs/runner.md) |
|
|
108
|
+
| 全部功能的用法,从第一次使用到常见问题 | [用户手册](docs/guide/README.md) |
|
|
122
109
|
| 本地、Docker 与 Cloudflare 部署 | [部署](docs/deployment.md) |
|
|
123
110
|
| 设计原则、组成与数据边界 | [架构](docs/architecture.md) |
|
|
124
111
|
|
|
@@ -10,11 +10,12 @@ the gateway marked as external; see `guard_route`. Contract: .dev/plans/远程
|
|
|
10
10
|
import hashlib
|
|
11
11
|
import json
|
|
12
12
|
import posixpath
|
|
13
|
+
import re
|
|
13
14
|
import time
|
|
14
15
|
from datetime import datetime, timezone
|
|
15
16
|
|
|
16
17
|
from . import free_room
|
|
17
|
-
from .identity import AI_PLATFORMS, MAX_ROOM_AGENTS, PLATFORM_NICKNAMES, is_ai
|
|
18
|
+
from .identity import AI_PLATFORMS, JOINED_NICKNAMES, MAX_ROOM_AGENTS, PLATFORM_NICKNAMES, is_ai
|
|
18
19
|
from .runtime import begin_write, require_owner, token_hash
|
|
19
20
|
from .texts import Text, text_payload
|
|
20
21
|
|
|
@@ -378,19 +379,28 @@ def save_label(connection, room_id, name, label, now):
|
|
|
378
379
|
ON CONFLICT(room_id,name) DO UPDATE SET label=excluded.label,updated_at=excluded.updated_at""", (room_id, name, label, now))
|
|
379
380
|
|
|
380
381
|
|
|
382
|
+
# A name this module gave after the AI (外部 Claude, 外部 Gemini2 …): the owner or host has not renamed it.
|
|
383
|
+
AUTO_LABEL = re.compile(rf"外部 ({'|'.join(map(re.escape, sorted(JOINED_NICKNAMES, key=len, reverse=True)))})\d*")
|
|
384
|
+
|
|
385
|
+
|
|
381
386
|
def name_joined(connection, row, now):
|
|
382
|
-
"""
|
|
387
|
+
"""Name an external member after its AI (外部 Claude, 外部 Claude2 …), on joining and whenever its AI changes.
|
|
383
388
|
|
|
384
|
-
A
|
|
385
|
-
|
|
389
|
+
A seat still under its pending name takes the AI's, and so does a name given earlier after another AI: the other
|
|
390
|
+
computer switched AI, or the member was invited back and sent a different one (user 2026-11-19, #5835). A name the
|
|
391
|
+
owner or host gave is kept, and so is the current one when the AI is unknown or a custom API, which has no name of
|
|
392
|
+
its own. Only the label changes; the member name that requests and records use stays.
|
|
386
393
|
"""
|
|
387
394
|
platform = connection.execute("SELECT platform FROM external_members WHERE member_id=?", (row["id"],)).fetchone()[0]
|
|
388
395
|
current = free_room.member_labels(connection, row["room_id"]).get(row["name"])
|
|
389
396
|
legacy = "另一台电脑" + row["name"].removeprefix("Custom-ext")
|
|
390
|
-
|
|
397
|
+
automatic = AUTO_LABEL.fullmatch(current or "")
|
|
398
|
+
if platform in ("", "Custom") or (current not in (pending_label(row["name"], row["id"]), legacy) and not automatic):
|
|
391
399
|
return
|
|
392
400
|
nickname = PLATFORM_NICKNAMES.get(platform, platform)
|
|
393
|
-
|
|
401
|
+
if automatic and automatic.group(1) == nickname:
|
|
402
|
+
return
|
|
403
|
+
taken = set(free_room.member_display_names(connection, row["room_id"]).values()) - {current}
|
|
394
404
|
label = next(candidate for number in range(1, MAX_ROOM_AGENTS + 2)
|
|
395
405
|
if (candidate := f"外部 {nickname}{number if number > 1 else ''}") not in taken)
|
|
396
406
|
save_label(connection, row["room_id"], row["name"], label, now)
|
|
@@ -552,7 +562,9 @@ def answer_payload(member, payload):
|
|
|
552
562
|
def report_ai(connection, member, payload):
|
|
553
563
|
"""The member's computer switched its AI: only what the room displays changes, never what the member may do."""
|
|
554
564
|
checked_text(payload.get("adapter"), MAX_ADAPTER, "adapter", required=True)
|
|
555
|
-
|
|
565
|
+
now = int(time.time())
|
|
566
|
+
save_ai(connection, member["id"], payload, now)
|
|
567
|
+
name_joined(connection, member, now)
|
|
556
568
|
return {"reported": True}
|
|
557
569
|
|
|
558
570
|
|
package/backend/free_room.py
CHANGED
|
@@ -99,7 +99,7 @@ TIMELINE_NOTES_SQL = f"""SELECT execution_id,created_at FROM execution_notes
|
|
|
99
99
|
RECENT_CHANGES = 50
|
|
100
100
|
MAX_CHANGED_FILES = 200
|
|
101
101
|
# What a member's software last showed it doing, as reported by the runner with each renewal.
|
|
102
|
-
ACTIVITY_PHASES = ("", "thinking", "command", "tool", "editing", "writing")
|
|
102
|
+
ACTIVITY_PHASES = ("", "thinking", "command", "tool", "editing", "writing", "waiting")
|
|
103
103
|
# Progress notes per execution, their length, and how many one renewal may carry.
|
|
104
104
|
MAX_EXECUTION_NOTES = 50
|
|
105
105
|
MAX_NOTE_LENGTH = 500
|
|
@@ -991,11 +991,14 @@ def recent_executions(connection, room_id, span=None):
|
|
|
991
991
|
else:
|
|
992
992
|
rows = connection.execute(f"{query} ORDER BY e.id DESC LIMIT ?", (room_id, RECENT_EXECUTIONS))
|
|
993
993
|
executions = []
|
|
994
|
+
positions = relay_positions(connection, room_id)
|
|
994
995
|
for row in rows:
|
|
995
996
|
requests = []
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
997
|
+
line = None
|
|
998
|
+
for request in connection.execute("SELECT id,room_id,member_id,message_id,batch_id,purpose,created_by,status,answer_id FROM member_requests WHERE execution_id=? ORDER BY id", (row["id"],)):
|
|
999
|
+
line = line or line_of(connection, request, positions)
|
|
1000
|
+
request_data = {key: request[key] for key in ("id", "message_id", "purpose", "status", "answer_id")}
|
|
1001
|
+
requests.append({**request_data, **session_request_source(connection, request["id"], request["message_id"])})
|
|
999
1002
|
executions.append({**public_execution(row), "texts": execution_texts(connection, row["id"]), "member": row["member"], "cwd": row["cwd"], "changes": json.loads(row["changes"] or "[]"),
|
|
1000
1003
|
"changes_recorded": bool(row["changes"]), "request_ids": json.loads(row["request_ids"]),
|
|
1001
1004
|
"edited": json.loads(row["edited"]) if row["edited"] else None, "diff_stats": diff_stats(row["diffs"]),
|
|
@@ -1004,7 +1007,7 @@ def recent_executions(connection, room_id, span=None):
|
|
|
1004
1007
|
"notes": row["note_count"], "steps": row["step_count"], "commands": row["command_count"], "edits": row["edit_count"], "denials": json.loads(row["denials"] or "[]"), "failure_class": row["failure_class"] or "",
|
|
1005
1008
|
"capabilities": reported_capabilities(row), "stop_result": row["stop_result"] or "",
|
|
1006
1009
|
"late_answer": json.loads(row["late_answer"]) if row["late_answer"] else None, "background": bool(row["background"]),
|
|
1007
|
-
"retried": bool(row["retried"]),
|
|
1010
|
+
"retried": bool(row["retried"]), "line": line,
|
|
1008
1011
|
"interjections": execution_interjections(connection, row["id"], row["status"]),
|
|
1009
1012
|
"retry": execution_retry(connection, row["id"])})
|
|
1010
1013
|
return executions
|
|
@@ -1149,7 +1152,8 @@ def free_view(connection, room_id):
|
|
|
1149
1152
|
"requests": requests[::-1], "executions": recent_executions(connection, room_id),
|
|
1150
1153
|
"conflicts": possible_conflicts(connection, room_id, names), "halted_chains": chains, "max_rounds": max_rounds,
|
|
1151
1154
|
"chain_rounds": progress, "recommendations": recent_recommendations(connection, room_id, now)[::-1],
|
|
1152
|
-
"queued_messages": queue_view(connection, room_id), "questions": questions.room_questions_view(connection, room_id)
|
|
1155
|
+
"queued_messages": queue_view(connection, room_id), "questions": questions.room_questions_view(connection, room_id),
|
|
1156
|
+
"dispatches": dispatch_modes(connection, room_id, {row["message_id"] for row in requests if row["created_by"] == "host"})}
|
|
1153
1157
|
|
|
1154
1158
|
|
|
1155
1159
|
def require_member(connection, room_id, token, name=None):
|
|
@@ -2586,16 +2590,94 @@ def answered_chain(connection, payload, actor):
|
|
|
2586
2590
|
return row[0] or 0
|
|
2587
2591
|
|
|
2588
2592
|
|
|
2593
|
+
def reaches_host(connection, room_id, payload):
|
|
2594
|
+
"""An owner message the host takes: unnamed, for everyone, in turn, or naming the host."""
|
|
2595
|
+
named = payload.get("to")
|
|
2596
|
+
if named is None or payload.get("order") == "auto" or payload.get("sequential") is True:
|
|
2597
|
+
return True
|
|
2598
|
+
host = connection.execute("SELECT name FROM room_members WHERE room_id=? AND role='host' AND status='active'", (room_id,)).fetchone()
|
|
2599
|
+
return bool(host) and host[0] in named
|
|
2600
|
+
|
|
2601
|
+
|
|
2602
|
+
def relay_positions(connection, room_id):
|
|
2603
|
+
"""Every relay step batch of the room with its step number, read once per view."""
|
|
2604
|
+
return {entry[2]: entry[3] + 1 for sequence in connection.execute("SELECT steps FROM free_sequences WHERE room_id=?", (room_id,))
|
|
2605
|
+
for entry in json.loads(sequence["steps"])}
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
def line_of(connection, request, positions=None):
|
|
2609
|
+
"""Which line a member request works on: a step of the speaking order (`main`, counted from 1), work its member was
|
|
2610
|
+
named for outside it (`branch`, by the owner or the host), or None for the host's own requests (route, hand-back...).
|
|
2611
|
+
|
|
2612
|
+
Returns:
|
|
2613
|
+
{"kind": "main", "step": n, "by": "host" (a relay) | "user" (in turn)} | {"kind": "branch", "by": "user" | "host"} | None
|
|
2614
|
+
"""
|
|
2615
|
+
if request["purpose"] != "ask":
|
|
2616
|
+
return None
|
|
2617
|
+
positions = relay_positions(connection, request["room_id"]) if positions is None else positions
|
|
2618
|
+
if request["batch_id"]:
|
|
2619
|
+
if request["batch_id"] in positions:
|
|
2620
|
+
return {"kind": "main", "step": positions[request["batch_id"]], "by": "host"}
|
|
2621
|
+
else:
|
|
2622
|
+
order = [row[0] for row in connection.execute("SELECT member_id FROM free_queue WHERE message_id=? ORDER BY id", (request["message_id"],))]
|
|
2623
|
+
if request["member_id"] in order:
|
|
2624
|
+
return {"kind": "main", "step": order.index(request["member_id"]) + 1, "by": "user"}
|
|
2625
|
+
if connection.execute("SELECT 1 FROM session_requests WHERE member_request_id=?", (request["id"],)).fetchone():
|
|
2626
|
+
return None
|
|
2627
|
+
# The host asked directly is a side question, not a branch; a room that never had a speaking order has no main line
|
|
2628
|
+
# for anything to branch off.
|
|
2629
|
+
if connection.execute("SELECT 1 FROM room_members WHERE id=? AND role='host'", (request["member_id"],)).fetchone() or not (
|
|
2630
|
+
positions or connection.execute("SELECT 1 FROM free_queue WHERE room_id=? LIMIT 1", (request["room_id"],)).fetchone()):
|
|
2631
|
+
return None
|
|
2632
|
+
return {"kind": "branch", "by": request["created_by"]}
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
def dispatch_modes(connection, room_id, message_ids):
|
|
2636
|
+
"""What becomes of each host dispatch once its members end (user 2026-11-20): `relay` (step by step, the last hands
|
|
2637
|
+
back), `handoff` (back to the host, the default), `direct` (`no_handoff`: straight to the owner, a failure still back)
|
|
2638
|
+
or `detach` (background only: nothing waits, nothing comes back); `detached` names background members sent beside it.
|
|
2639
|
+
A relay's later steps hang on members' answers and are not the host's dispatch messages, so they are left out."""
|
|
2640
|
+
modes = []
|
|
2641
|
+
for message_id in sorted(message_ids):
|
|
2642
|
+
detached = [row[0] for row in connection.execute("""SELECT m.name FROM member_requests r JOIN room_members m ON m.id=r.member_id
|
|
2643
|
+
WHERE r.room_id=? AND r.message_id=? AND r.created_by='host' AND r.purpose='ask' AND r.batch_id=0 ORDER BY r.id""", (room_id, message_id))]
|
|
2644
|
+
if connection.execute("SELECT 1 FROM free_sequences WHERE room_id=? AND message_id=?", (room_id, message_id)).fetchone():
|
|
2645
|
+
mode = "relay"
|
|
2646
|
+
elif connection.execute("SELECT 1 FROM free_relay_steps WHERE room_id=? AND batch_id=?", (room_id, message_id)).fetchone():
|
|
2647
|
+
continue
|
|
2648
|
+
elif connection.execute("SELECT 1 FROM free_batches WHERE room_id=? AND batch_id=?", (room_id, message_id)).fetchone():
|
|
2649
|
+
direct = connection.execute("SELECT 1 FROM free_direct_batches WHERE room_id=? AND batch_id=?", (room_id, message_id)).fetchone()
|
|
2650
|
+
mode = "direct" if direct else "handoff"
|
|
2651
|
+
elif detached:
|
|
2652
|
+
mode, detached = "detach", []
|
|
2653
|
+
else:
|
|
2654
|
+
continue
|
|
2655
|
+
modes.append({"message_id": message_id, "mode": mode, "detached": detached})
|
|
2656
|
+
return modes
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
def open_branches(connection, room_id, host_id):
|
|
2660
|
+
"""Work the owner named members for directly, still waiting or under way: lines the host did not send and is not
|
|
2661
|
+
handed back, listed so it does not send conflicting work."""
|
|
2662
|
+
return [dict(row) for row in connection.execute("""SELECT m.name AS member,r.message_id,r.status FROM member_requests r
|
|
2663
|
+
JOIN room_members m ON m.id=r.member_id WHERE r.room_id=? AND r.member_id<>? AND r.status IN ('pending','delivering')
|
|
2664
|
+
AND r.purpose='ask' AND r.created_by='user' AND r.batch_id=0
|
|
2665
|
+
AND NOT EXISTS(SELECT 1 FROM free_queue f WHERE f.message_id=r.message_id AND f.member_id=r.member_id)
|
|
2666
|
+
AND NOT EXISTS(SELECT 1 FROM session_requests s WHERE s.member_request_id=r.id) ORDER BY r.id""", (room_id, host_id))]
|
|
2667
|
+
|
|
2668
|
+
|
|
2589
2669
|
def after_free_message(connection, room_id, message_id, actor, payload):
|
|
2590
2670
|
"""Create requests for the owner's message, or close what the member's answer covers."""
|
|
2591
2671
|
now = int(time.time())
|
|
2592
2672
|
if actor == "用户":
|
|
2593
2673
|
# New owner input lets an active goal wake the host again once the room falls idle, and answers whatever the
|
|
2594
2674
|
# host was waiting on: the goal is back to being worked on and a later pending gets its fallback again.
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2675
|
+
# A message the host takes also replaces whatever it meant to continue with. One naming other members only
|
|
2676
|
+
# starts their own lines: it answers nothing the host asked, so the host's plan and goal state stay (user 2026-11-20).
|
|
2677
|
+
if reaches_host(connection, room_id, payload):
|
|
2678
|
+
connection.execute("""UPDATE room_goals SET armed=1,phase='doing',phase_note='',phase_until=0,pending_fallback=0
|
|
2679
|
+
WHERE room_id=? AND status='active'""", (room_id,))
|
|
2680
|
+
connection.execute("DELETE FROM free_host_continues WHERE room_id=?", (room_id,))
|
|
2599
2681
|
if discussion.hold_user_message(connection, room_id, message_id, payload):
|
|
2600
2682
|
return
|
|
2601
2683
|
if resume_user_gate(connection, room_id, message_id, payload):
|
|
@@ -3178,6 +3260,25 @@ def claim_execution(connection, room_id, member, payload):
|
|
|
3178
3260
|
return open_execution(connection, room_id, member, payload, request_ids)
|
|
3179
3261
|
|
|
3180
3262
|
|
|
3263
|
+
# A pending request that is a turn of the speaking order: the current step of a host's relay, or a member's turn of an
|
|
3264
|
+
# owner's message in turn (`free_queue`). Written against `member_requests` without an alias.
|
|
3265
|
+
MAIN_LINE = """(member_requests.purpose='ask' AND (
|
|
3266
|
+
(member_requests.batch_id>0 AND EXISTS(SELECT 1 FROM free_sequences q WHERE q.room_id=member_requests.room_id AND q.batch_id=member_requests.batch_id))
|
|
3267
|
+
OR (member_requests.batch_id=0 AND EXISTS(SELECT 1 FROM free_queue f WHERE f.message_id=member_requests.message_id AND f.member_id=member_requests.member_id))))"""
|
|
3268
|
+
|
|
3269
|
+
|
|
3270
|
+
def one_line(connection, member_id, request_filter, request_values):
|
|
3271
|
+
"""Narrow what an execution takes to one line (user 2026-11-20): work the member was named for goes first, its turn
|
|
3272
|
+
in the speaking order waits for the next execution, and work named by the owner and by the host go one after the
|
|
3273
|
+
other (whoever named it first), so stopping or withdrawing one never takes another with it. The member's other
|
|
3274
|
+
requests (the host's route, hand-back, notice) still ride along. Decided over the same candidates it delivers."""
|
|
3275
|
+
branch = connection.execute(f"""SELECT created_by FROM member_requests WHERE member_id=? AND status='pending' AND {request_filter}
|
|
3276
|
+
AND purpose='ask' AND NOT {MAIN_LINE} ORDER BY id LIMIT 1""", (member_id, *request_values)).fetchone()
|
|
3277
|
+
if not branch:
|
|
3278
|
+
return request_filter, request_values
|
|
3279
|
+
return (f"{request_filter} AND NOT {MAIN_LINE} AND NOT (purpose='ask' AND created_by<>?)", (*request_values, branch[0]))
|
|
3280
|
+
|
|
3281
|
+
|
|
3181
3282
|
def open_execution(connection, room_id, member, payload, request_ids=None):
|
|
3182
3283
|
"""Open one execution over a checked member's pending requests, or only over `request_ids` among them."""
|
|
3183
3284
|
client_id = str(payload.get("client_id", ""))
|
|
@@ -3211,6 +3312,11 @@ def open_execution(connection, room_id, member, payload, request_ids=None):
|
|
|
3211
3312
|
if request_ids is not None:
|
|
3212
3313
|
request_filter += f" AND id IN ({','.join('?' * len(request_ids))})"
|
|
3213
3314
|
request_values = (*request_values, *request_ids)
|
|
3315
|
+
if not session_purpose and not pending[0]["review"]:
|
|
3316
|
+
request_filter, request_values = one_line(connection, member["id"], request_filter, request_values)
|
|
3317
|
+
if not connection.execute(f"SELECT 1 FROM member_requests WHERE member_id=? AND status='pending' AND {request_filter}",
|
|
3318
|
+
(member["id"], *request_values)).fetchone():
|
|
3319
|
+
raise FileExistsError(Text("该成员没有待投递的请求"))
|
|
3214
3320
|
now = int(time.time())
|
|
3215
3321
|
cursor = connection.execute("""INSERT INTO member_executions (room_id,member_id,client_id,lease_until,created_at,cwd)
|
|
3216
3322
|
VALUES (?,?,?,?,?,?)""", (room_id, member["id"], client_id, now + LEASE_SECONDS, now, str(payload.get("cwd") or "")[:MAX_PATH_LENGTH]))
|
|
@@ -3235,8 +3341,9 @@ def execution_detail(connection, row):
|
|
|
3235
3341
|
quota = quota_failure(connection, row["id"])
|
|
3236
3342
|
failure = failure_class_of(connection, row["id"])
|
|
3237
3343
|
mentions = mention_outcomes(connection, member["id"], row["id"])
|
|
3344
|
+
branches = open_branches(connection, row["room_id"], member["id"]) if member["role"] == "host" else []
|
|
3238
3345
|
return {**detail, "member": member["name"], "read_until": member["read_until"], "requests": requests,
|
|
3239
|
-
**({"mentions": mentions} if mentions else {}),
|
|
3346
|
+
**({"mentions": mentions} if mentions else {}), **({"branches": branches} if branches else {}),
|
|
3240
3347
|
**({"queued_requests": queued_requests(connection, member["id"])} if row["status"] in ACTIVE else {}),
|
|
3241
3348
|
"rewound_executions": member_rewinds(connection, member["id"]), "retry": execution_retry(connection, row["id"]),
|
|
3242
3349
|
**({"failure": {"class": "quota", "resets": quota["resets"] or None, "reset_at": quota["reset_at"] or None,
|