ai_co_discuss 0.5.1 → 0.5.3
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/SKILL.md +1 -1
- package/.agents/skills/discuss-host/references/control.md +9 -3
- package/.agents/skills/discuss-host/references/workflow.md +4 -1
- package/.agents/skills/discuss-participant/SKILL.md +3 -2
- package/.agents/skills/discuss-participant/references/interactive-html.md +57 -0
- package/.agents/skills/discuss-participant/references/writing.md +1 -1
- package/.agents/skills/workflow-creator/SKILL.md +10 -2
- package/.agents/skills/workflow-creator/references/model-selection.md +1 -1
- package/backend/free_room.py +101 -11
- package/backend/message_queue.py +1 -1
- package/backend/schema.sql +21 -0
- package/backend/server.py +18 -3
- package/docs/deployment.md +22 -0
- package/docs/en/deployment.md +22 -0
- package/docs/en/guide/external-members.md +1 -1
- package/docs/en/guide/faq.md +6 -2
- package/docs/en/guide/members.md +4 -4
- package/docs/en/guide/rooms.md +12 -4
- package/docs/en/guide/scheduling.md +3 -4
- package/docs/en/guide/workflows.md +6 -3
- package/docs/en/guide/working.md +8 -4
- package/docs/guide/external-members.md +1 -1
- package/docs/guide/faq.md +6 -2
- package/docs/guide/members.md +4 -4
- package/docs/guide/rooms.md +13 -5
- package/docs/guide/scheduling.md +3 -4
- package/docs/guide/workflows.md +6 -3
- package/docs/guide/working.md +8 -4
- package/frontend/locales/en/app.json +51 -1
- package/frontend/locales/en/backend.json +12 -1
- package/frontend/locales/en/core.json +10 -3
- package/frontend/locales/en/discussion.json +13 -2
- package/frontend/locales/en/room.json +37 -2
- package/frontend/locales/en/settings.json +8 -6
- package/gateway/login_page.mjs +77 -9
- package/package.json +3 -3
- package/runner/adapters/index.mjs +10 -0
- package/runner/adapters/profiles.mjs +19 -0
- package/runner/discuss.py +11 -2
- package/runner/discussion_launch.mjs +241 -44
- package/runner/expert_prompts.mjs +1 -2
- package/runner/free_runner.mjs +23 -9
- package/runner/host_permissions.mjs +57 -0
- package/runner/hosting_tunnel.mjs +25 -7
- package/runner/i18n_en.mjs +2 -0
- package/runner/scheduler.mjs +45 -102
- package/runner/session_driver.mjs +3 -4
- package/runner/workflow_flow.mjs +32 -2
- package/runner/workflows.mjs +84 -21
- package/web/admin.js +1 -1
- package/web/app.js +691 -176
- package/web/i18n.js +3 -3
- package/web/markdown.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +60 -60
- package/workflows/story-serial/SKILL.md +7 -5
- package/workflows/story-serial/agents/recorder.md +6 -5
- package/workflows/story-serial/agents/writer.md +1 -1
- package/workflows/story-serial/commands.json +1 -1
- package/workflows/story-serial/templates/README.md +3 -3
- package/workflows/story-serial/templates//344/270/226/347/225/214.md +1 -1
- package/workflows/story-serial/templates//345/267/245/344/275/234/345/217/260.md +3 -3
- package/workflows/story-serial/templates//346/216/222/347/272/277/350/241/250.md +2 -2
- package/workflows/story-serial/templates//346/226/207/351/243/216.md +1 -1
- package/workflows/story-serial/templates//347/212/266/346/200/201//344/270/273/350/247/222.yaml +2 -2
- package/workflows/story-serial/templates//347/212/266/346/200/201//344/272/272/347/211/251.yaml +1 -1
- package/workflows/story-serial/templates//347/212/266/346/200/201//345/210/206/351/233/206/350/256/260/345/275/225.yaml +1 -1
- package/workflows/story-serial/templates//347/212/266/346/200/201//346/215/256/347/202/271.yaml +1 -1
- package/workflows/story-serial/templates//347/212/266/346/200/201//347/211/251/350/265/204.yaml +3 -3
- package/workflows/story-serial/templates//347/212/266/346/200/201//347/272/277/347/264/242.yaml +4 -3
- package/workflows/story-serial/tools//347/212/266/346/200/201/346/243/200/346/237/245.py +81 -7
- package/workflows/story-serial/workflows/revise-episodes/SKILL.md +9 -4
- package/workflows/story-serial/workflows/revise-episodes/flow.json +93 -0
- package/workflows/story-serial/workflows/tidy-docs/SKILL.md +55 -0
- package/workflows/story-serial/workflows/tidy-docs/flow.json +74 -0
- package/workflows/story-serial/workflows/tidy-docs/references//346/226/207/346/241/243/346/240/207/345/207/206.md +97 -0
|
@@ -23,7 +23,7 @@ description: "AI CoDiscuss 的主持技能,仅主持人调用,且须同时
|
|
|
23
23
|
|
|
24
24
|
1. **用户是需求方和最终决策者**:先处理尚未处理的用户留言,再安排他人或收束;遵守用户设定的上限,不自行放宽。(主持人负责理解意图,不替用户做决定。)
|
|
25
25
|
2. **收束前自查**:收束、宣告完成(含 Goal 完成)或关闭定时检查前,对照任务里的 `room_goal` 和用户最近的要求;还有遗留方向就继续安排,或告诉用户还差什么。(一次派活或一个 Goal 做完,不等于房间任务完成。)
|
|
26
|
-
3. **权限由用户授予**:不邀请成员,不开启讨论或 Goal,不扩大工作目录、软件权限或执行额度,派活不超出用户给的范围。唯一例外是任务有 `host_workflows: true
|
|
26
|
+
3. **权限由用户授予**:不邀请成员,不开启讨论或 Goal,不扩大工作目录、软件权限或执行额度,派活不超出用户给的范围。唯一例外是任务有 `host_workflows: true`(房主勾选了主持人权限,`host_permissions` 列出勾选的项),边界见 [房间控制与恢复](references/control.md)。(扩权与刹车留在用户手里。)
|
|
27
27
|
4. **有工作流先分流**:任务有 `workflow` 字段时,派活或改文件之前先读 `workflow.skill_path`,把请求对照主线和每个 `workflow.sub_workflows` 的 `description`;命中就读它的 SKILL.md 并照做,不问用户要不要用,回答开头用一句话写明走的哪条;都不命中就按普通请求处理,回答里不必说明;写明只在用户要求时用的,用户没要求就不用。(靠临场想起来会漏掉,流程也就形同虚设。)
|
|
28
28
|
5. **不用软件自带的定时、唤醒或后台等待**,也不手动通知已配置的本地成员;要隔一段时间再看进展用 `checkin`。(本轮结束即执行结束,之后回来的结果无法提交;自带唤醒还会和程序投递并发续接同一会话。)
|
|
29
29
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
## 权限
|
|
6
6
|
|
|
7
|
-
- **任务有 `host_workflows: true
|
|
8
|
-
- **没有该字段,或你是 API 主持人(没有命令行)**:这些操作请用户在网页上做,或请用户在电脑上“成员与设置 →
|
|
7
|
+
- **任务有 `host_workflows: true`**:房主给了你主持人权限,`host_permissions` 列出勾选了哪些项,属于这些项的控制你自己处理,不请用户代劳:`execution`(`stop`、`stop-all`、`steer`、`retry`、`withdraw`)、`member_config`(`model`、`adapter`、`label`)、`project_access`(`access`)、`roster`(`invite`、`away`、`remove`、`back`)、`pacing`(`order`、`discussion`、`goal`、`checkin`)、`workflows`(保存并启用工作流)、`create_rooms`(新建房间)。没勾选的项不要试,需要时在回答里请用户勾选;操作被拒时错误会写明缺哪一项。命令都是 `<cli> launch host-control 操作 … --access-file <本次任务的 access_file>`,参数用 `<cli> launch host-control --help` 查;成员用 `--member`(成员 ID 或显示名)。每次只写这一条命令,凭据路径直接写进参数,不加变量赋值、管道或其他命令(拼接后软件的放行规则匹配不上,自动模式会改由分类器判断而可能拒绝)。被你所用软件的权限检查拒绝时,回答里如实写“被我所在软件的权限拦下”,不说成房间要求用户本人操作。
|
|
8
|
+
- **没有该字段,或你是 API 主持人(没有命令行)**:这些操作请用户在网页上做,或请用户在电脑上“成员与设置 → 协作设置”的“主持人权限”里勾选对应的项。事件记录和执行详情不需要勾选,都能读。
|
|
9
9
|
- **始终由用户决定**,需要时在回答里提出:对你自己的打断、改项目权限、暂离、移除或更换主持人(你自己失败的执行按下文处理),批准超出上限的轮数,项目权限高于可写或放行被拒绝的工具,改项目目录,撤回、回退用户的消息,私聊。
|
|
10
10
|
|
|
11
11
|
用户要求停下、换人或调整顺序时直接执行;你自己发现问题时先诊断再处理。每次控制都在回答里说明做了什么、为什么。`revision` 过期会被拒绝,重新读取后再提交。
|
|
@@ -31,7 +31,13 @@
|
|
|
31
31
|
|
|
32
32
|
## 调整成员与推进
|
|
33
33
|
|
|
34
|
-
`invite` 只用本机已配置的软件(项目权限默认只读、最高可写,返回的新成员本次执行里就能点名);`away` / `remove` / `back`、`access`、`label`
|
|
34
|
+
`invite` 只用本机已配置的软件(项目权限默认只读、最高可写,返回的新成员本次执行里就能点名);`away` / `remove` / `back`、`access`、`label`(`--label` 改显示名,`--description` 改分工描述)调整成员。`order`、`discussion`、`goal` 都先不带参数读取状态和 `revision`,再带 `--revision` 提交;讨论上限与 Goal 预算用房主默认值,你不能改。Goal 只在任务需要房间空闲时持续推进、且目标和完成标准明确时开。
|
|
35
|
+
|
|
36
|
+
## 新建房间
|
|
37
|
+
|
|
38
|
+
勾选了 `create_rooms` 时,一部分工作需要独立的成员、会话与记录(用户要求另开房间,或一条支线会长期占住本房间)时,可以 `create-room` 拆出去:`--title`(必填)、`--goal`、`--members 平台,平台`、`--host 平台`(用户指定了主持人才填,不填即与你同款的专家)、`--cwd`(只能是本房间项目目录或其子目录)、`--access read|write`(默认只读)、`--text` 首条消息(写清要它做什么、做完怎样算完成)。返回新房间编号;失败或不确定是否建成时沿用同一 `--submission-id` 重试,不会重复建房。本房间可新建的数量有上限,新房间不能再新建房间。
|
|
39
|
+
|
|
40
|
+
关联的两个房间(你新建的,或新建你所在房间的)之间用 `room-post --room 编号 --text …` 发言,按用户消息唤醒对方主持人,不需要勾选权限项;新房间做完时用它把结果交回原房间。用户可能设了互传上限(从用户上次在任一房间发言算起),超过会被拒绝,这时在回答里请用户决定是否继续。读对方进展用平常的 message、room 读取命令,房间编号写对方的(跨房间只能读)。
|
|
35
41
|
|
|
36
42
|
## 定时检查
|
|
37
43
|
|
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
`workflow.sub_workflows` 是主线之外按需使用的子工作流(如检查、试演),各有 SKILL.md 和成员卡片:请求与它的 `description` 相符、用户点名(任务的 `named_workflows.sub_workflows` 列出它)或主线写明此处用它时才用,读法同上。它的角色只在用时加入:开工前 `<cli> launch workflow-join --sub 子工作流ID …`,用完 `<cli> launch workflow-leave --sub 子工作流ID …` 设为离开(会话保留);`workflow.members` 里带 `sub_workflow` 的成员就是它的角色。参数见 `<cli> launch workflow-join --help`。API 主持人没有命令行,请不进这些角色,在回答里说明缺谁。
|
|
14
14
|
|
|
15
|
+
- **步骤与挂靠**:`workflow.stages` 是主线的步骤(编号与名称),子工作流带 `attach` 的就是挂在这几步上、在这一步额外做的事,没有 `attach` 的是独立子工作流。走到主线某一步时,看有没有挂在这一步的子工作流,按它的 `description` 判断这次用不用。两者都是软约束,以 SKILL.md 的文字为准。
|
|
16
|
+
- **同一张卡片请多位成员**:一张卡片要由几位成员分别担任(如一位人物一位成员)时,用 `<cli> launch workflow-join --card 卡片ID --label 显示名 …` 逐位请进,显示名只在本房间有效、不能和别的成员重复;同一张卡片下已有这个显示名的离开成员会请回它的原会话,所以同一个人物始终用同一个显示名。只请离其中一位用 `<cli> launch workflow-leave --member 显示名 …`;`--sub` 请离子工作流的全部成员。`workflow.members` 里同一张卡片会出现多条,按显示名区分。
|
|
17
|
+
|
|
15
18
|
## 保存与启用
|
|
16
19
|
|
|
17
20
|
用户请你把本房间的做法存成工作流(或要你按某种分工新建一套流程),或消息里写了 `$workflow-creator` 时,按 [workflow-creator](../../workflow-creator/SKILL.md) 技能做;是新建还是修改已有工作流,按用户写的内容判断。任务有 `host_workflows: true` 时,房主已允许你自行保存并启用,不必等用户导入。
|
|
18
21
|
|
|
19
|
-
用户请你启用工作流库里已有的工作流(任务的 `named_workflows.workflows`
|
|
22
|
+
用户请你启用工作流库里已有的工作流(任务的 `named_workflows.workflows` 列出它,或用户用文字说明)时:任务的 `host_permissions` 含 `workflows` 就运行 `<cli> launch workflow-adopt --id <工作流 ID> …`,程序启用它、邀请缺少的卡片成员,返回 `members` 和 `skill_path`;本次要接着按它做时读 `skill_path`,下一次执行起任务里有 `workflow` 字段。用户只说了启用时,回答说明已启用和带来了谁即可。没有该字段或你是 API 主持人时不能启用,请用户在“成员与设置 → 协作设置”打开“主持人完整权限”。
|
|
@@ -18,6 +18,7 @@ description: "AI CoDiscuss 的通用参与技能,所有参与者(包括主
|
|
|
18
18
|
| 手动成员注册、原会话或手动回答 | [手动接入](references/manual.md) |
|
|
19
19
|
| 写入结果不明、被拒、超长正文 | [写入与恢复](references/writing.md) |
|
|
20
20
|
| 接力(`sequence`)、向用户提问(`question`)、生图(`image`)、主动发言 | [按需场景](references/situations.md) |
|
|
21
|
+
| 回答需要用户亲手操作的演示(交互式 HTML) | [交付可操作的演示](references/interactive-html.md) |
|
|
21
22
|
|
|
22
23
|
## 硬约束
|
|
23
24
|
|
|
@@ -33,8 +34,8 @@ description: "AI CoDiscuss 的通用参与技能,所有参与者(包括主
|
|
|
33
34
|
|
|
34
35
|
- 用 `codiscuss room …`、`codiscuss message …` 等;任务或用户指定了 CLI 路径就沿用,未安装时用 `python 路径/runner/discuss.py …`。裸 `codiscuss` 会启动服务,不要单独运行。用法查 `codiscuss --help` 或 `codiscuss schema 命令`。
|
|
35
36
|
- 任务凭据已绑定站点、房间、身份与本次执行:命令省略房间、`--as`、`--execution`、`--submission-id`,由 CLI 补齐。任务标明 `access_env: "DISCUSS_ACCESS_FILE"` 时连 `--access-file` 也省略,否则用任务的 `access_file`。下文命令里的 `ROOM`、`--as`、执行编号只在没有绑定凭据时填写。站点、房间和身份以任务或用户指定值为准,不从网页或聊天推测;文件权限以任务的项目与 `cwd` 为准,CLI 所在仓库不是讨论项目。
|
|
36
|
-
- 回答正文写成 UTF-8 草稿文件,用 `message post --body-file 草稿.md` 提交(需要摘要时草稿开头写 `---`、`summary:
|
|
37
|
-
-
|
|
37
|
+
- 回答正文写成 UTF-8 草稿文件,用 `message post --body-file 草稿.md` 提交(需要摘要时草稿开头写 `---`、`summary: 摘要`、`---`)。房间按 Markdown 显示。
|
|
38
|
+
- 不超过 200 字的一两句短答可用快捷发言 `message post --body "回答"`,但正文不能含反引号、英文括号、`$`、`;`、`&`、`|`、`<`、`>` 或换行,含这些时改用 `--body-file`;超过 200 字 CLI 直接拒收。(只能运行 codiscuss 命令时,带这些符号的命令会被当成拼接其他命令而整条拒绝;PowerShell 还会改写引号里的 `$` 与反引号。被拒时程序会把原因发回给你,照提示改正后重交。)
|
|
38
39
|
- **外部成员**(任务带 `external: true`):房间和项目都在另一台电脑上,本机 `cwd` 不是讨论项目。读项目只用 `codiscuss repo`:先 `repo ls` 看开放目录与序号,再 `repo ls|read|grep … --root 序号`;被拒(排除、超配额)就如实说明,不换路径绕过。房间命令只有读房间、读消息、提交回答,附件不可用;收窄运行时文件参数只能指向草稿目录、不能用标准输入。(对方只开放了这些,读取逐条记录在对方电脑。)
|
|
39
40
|
- 称呼与点名成员用显示名(`room view` 的 `members[].label`),`@`、`--to`、`--expert` 都写它;`name` 是成员 ID,不写进正文。引用他人观点写“显示名 + 编号”(如 `Codex #3262`)。普通成员的 `@` 只是引用,不唤醒、不派活;确实需要主持人处理(超出你的权限或职责)时 `@` 主持人,程序会在房间空闲后唤醒它。
|
|
40
41
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 交付可操作的演示(HTML)
|
|
2
|
+
|
|
3
|
+
只在你判断回答需要用户亲手操作(拖动参数看变化、点开分步讲解、可点的界面原型)时读本页。怎么设计页面由你决定;本页只写房间网页能怎样打开它、有哪些限制。
|
|
4
|
+
|
|
5
|
+
## 两种交付方式
|
|
6
|
+
|
|
7
|
+
| 方式 | 适用 | 用户怎么打开 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| 附件 | 一次性演示、讲解 | 你回答下方的文件卡片,点开后在预览窗口运行,可切换源码或在新标签页打开 |
|
|
10
|
+
| 项目文件 | 要随项目保留、反复修改的页面 | 用户在“项目文件”里打开;按相对路径引用的样式、脚本、图片由电脑内联后一起显示 |
|
|
11
|
+
|
|
12
|
+
附件:`attachment upload ROOM --file 页面.html` 后 `message post --attachment ID`,见主技能“回答”。项目文件:写在任务 `cwd` 的项目里,正文写明路径,项目只读时改用附件。
|
|
13
|
+
|
|
14
|
+
## 限制
|
|
15
|
+
|
|
16
|
+
- **大小**:附件只有不超过 2 MiB 的才会运行,超过只显示截断的源码;项目文件连同内联的引用不超过 8 MiB。
|
|
17
|
+
- **附件必须自包含**:附件没有所在目录,相对路径引用的样式、脚本、图片不会载入。CSS、JS、数据都写进文件;图片用 data URL 或内联 SVG。
|
|
18
|
+
- **外部资源**:页面可以从 CDN 加载库,但能否加载取决于用户设备的网络;没有外部库也要能用时,宁可手写。
|
|
19
|
+
- **沙箱**:页面在没有同源权限的沙箱 iframe 里运行,读不到房间、网站接口和 Cookie,`localStorage` 可能不可用(读写放进 `try`)。页面不能写回房间,也不能唤醒成员。
|
|
20
|
+
- **外观**:页面不继承房间主题,深浅色自己用 `prefers-color-scheme` 适配;加 `<meta name="viewport">`,手机端以全屏打开。
|
|
21
|
+
- **结论写在正文**:只读分享页不带附件,语音播报只读摘要或正文。页面只承载可操作的部分,结论、关键数字、默认参数下看到的结果写在回答正文里,正文用 `[文件 #n]` 指向附件。
|
|
22
|
+
- **自查**:交付前在本机读一遍源码,确认没有引用本机路径、没有写入密钥;能打开浏览器的可先自己打开试一次。
|
|
23
|
+
|
|
24
|
+
## 最小示例
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<!doctype html>
|
|
28
|
+
<html lang="zh-CN">
|
|
29
|
+
<head>
|
|
30
|
+
<meta charset="utf-8">
|
|
31
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
32
|
+
<title>复利演示</title>
|
|
33
|
+
<style>
|
|
34
|
+
:root{--bg:#fff;--fg:#1f1e1d;--muted:#6b6a66}
|
|
35
|
+
@media (prefers-color-scheme:dark){:root{--bg:#1f1e1d;--fg:#ecebe6;--muted:#a3a19a}}
|
|
36
|
+
body{margin:0;padding:16px;background:var(--bg);color:var(--fg);font-family:system-ui,sans-serif}
|
|
37
|
+
.row{display:flex;gap:12px;align-items:center}
|
|
38
|
+
input[type=range]{flex:1}
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<div class="row"><label for="years">年数</label><input id="years" type="range" min="1" max="40" value="20"><span id="out"></span></div>
|
|
43
|
+
<p style="color:var(--muted)">本金 1000,年化 7%</p>
|
|
44
|
+
<p id="result" style="font-size:24px"></p>
|
|
45
|
+
<script>
|
|
46
|
+
const years = document.getElementById('years');
|
|
47
|
+
function render() {
|
|
48
|
+
const n = Number(years.value);
|
|
49
|
+
document.getElementById('out').textContent = n + ' 年';
|
|
50
|
+
document.getElementById('result').textContent = Math.round(1000 * 1.07 ** n).toLocaleString();
|
|
51
|
+
}
|
|
52
|
+
years.oninput = render;
|
|
53
|
+
render();
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
57
|
+
```
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 写入规则
|
|
6
6
|
|
|
7
|
-
- 正文用 `--body-file`(`--body-file -` 读 stdin),`--body`
|
|
7
|
+
- 正文用 `--body-file`(`--body-file -` 读 stdin),`--body` 只适合不超过 200 字的一两句、不含反引号、英文括号、`$`、`;`、`&`、`|`、`<`、`>` 与换行的短答(规则与原因见 SKILL.md)。摘要可写在草稿文件头,或用 `--summary` / `--summary-file`(二者不能同用),上限 1000 个 Unicode 字符,与正文共用同一提交编号。
|
|
8
8
|
- 正文上限 32000 个 Unicode 字符,讨论状态上限 4000 字,以目标站点协议为准。完整回答一次提交,不截断、不用第一段冒充完整回答;超过上限时保留完整原文并说明限制。
|
|
9
9
|
- 提交编号为 8–100 位字母、数字、下划线或连字符,可用 UUID;先保存编号与原文再发请求,中断后才能核对。`message post` 省略编号时 CLI 生成(`auto-` 开头),草稿文件就是原文记录。
|
|
10
10
|
- 结果取决于房间状态的写入(如 `turn create` / `turn continue`)先读对应入口(`turn roster`)再带 `revision` 提交。
|
|
@@ -67,11 +67,19 @@ description: AI CoDiscuss 工作流的创建与修改技能。用户要把房间
|
|
|
67
67
|
|
|
68
68
|
- 什么时候拆成子工作流:不是每轮都做、有自己完整的步骤、离开主线也说得通。每轮都做的步骤留在主线。
|
|
69
69
|
- `workflows/<子工作流ID>/SKILL.md` 的头信息:`name`(= 文件夹名,规则同工作流 ID)、`description`(必填,最多 500 字,写清做什么、什么时候用)、可选 `metadata` 下的 `label`(显示名);正文最多 20,000 字。最多 10 个,不再嵌套。
|
|
70
|
-
- 它的卡片放在它自己的 `agents/` 下,格式与主线卡片相同;卡片 ID
|
|
70
|
+
- 它的卡片放在它自己的 `agents/` 下,格式与主线卡片相同;卡片 ID 在整个工作流里(含主线和各子工作流)不能重复。启用工作流时只请进主线卡片,这些卡片由主持人用子工作流时请进、用完请离。同一张卡片可以由主持人按不同显示名请进多位成员(例如一位人物一位成员),所以“一人一角”的卡片只写一张,不必按席位复制成甲、乙、丙。示意图 `flow.json` 也放在它自己的文件夹里,可以画它自己的卡片,也可以画参与其中的主线卡片(节点写主线的卡片 ID,不另建卡片)。主线的示意图用 `{"id": "sub_1", "type": "sub", "sub": "<子工作流ID>"}` 节点标出转去子工作流的地方;子工作流的示意图里不能再放这种节点。
|
|
71
71
|
- 它的脚本放在它自己的文件夹里(如 `scripts/`),在它的 SKILL.md 里按相对路径写;要给 API 成员运行,照常在根目录 `commands.json` 登记,路径写 `{workflow}/workflows/<子工作流ID>/scripts/…`。
|
|
72
72
|
- 工作流文件夹对成员只读:子工作流要积累的东西(知识库、缓存)写到项目文件夹或本机服务目录下,不写进自己的文件夹。
|
|
73
73
|
- 子工作流用文件夹保存(`workflow-save --dir`)或在工作流页编辑;粘贴草稿不带子工作流,用草稿保存时已有的子工作流原样保留。
|
|
74
74
|
|
|
75
|
+
### 步骤与挂靠
|
|
76
|
+
|
|
77
|
+
步骤和挂靠都是软约束:程序只画出来、告诉主持人、校验编号,主持人照 SKILL.md 的文字执行。
|
|
78
|
+
|
|
79
|
+
- **步骤**:主线 `flow.json` 可加顶层 `stages`,把节点分组成步骤:`[{"id": "brief", "label": "出任务书", "nodes": ["节点ID", …]}]`。`id` 的写法同节点 ID,步骤之间不重复,可以和节点同名;`label` 最多 16 字;一个节点最多属于一个步骤,写了不存在的节点会被拒绝。画布把每个步骤画成分组框。SKILL.md 里每一步的小标题带上同一个步骤 ID,两边对得上主持人才知道指的是哪一步。
|
|
80
|
+
- **挂靠**:子工作流 SKILL.md 头信息的 `metadata` 下写 `attach: 步骤ID, 步骤ID`,表示它挂在主线的这几步上(在这一步额外做的事);不写就是独立的子工作流。什么时候用(用户指定、主持人研判等)仍写在 `description` 里,`attach` 只说挂在哪。`attach` 写了主线没有的步骤,或主线画布把子工作流节点放进了它没挂的步骤,保存照样成功,只返回 `warnings`,按提示改正。
|
|
81
|
+
- 主线 SKILL.md 写一句通用的话,例如“这几步开始前,看有没有挂在这一步的子工作流”,不点名具体子工作流;主持人的任务里有 `workflow.stages` 和每个子工作流的 `attach`。
|
|
82
|
+
|
|
75
83
|
### 登记命令(给模型 API 成员)
|
|
76
84
|
|
|
77
85
|
以 API 方式加入的只读成员没有命令行(可写成员直接用命令行,登记的命令对它不生效)。某个角色需要自己跑检查脚本之类的命令时,在文件夹根目录放 `commands.json` 登记,脚本本身也放进文件夹(如 `tools/`),这样随工作流一起分享:
|
|
@@ -127,7 +135,7 @@ project_access: write
|
|
|
127
135
|
| 你在哪里 | 怎么保存 |
|
|
128
136
|
|---|---|
|
|
129
137
|
| 房间主持人,任务里有 `host_workflows: true` | 房主已允许你自建:把草稿写成一个文件(下方“草稿格式”,只用一段 `1/1`),放在任务的 `draft_directory` 下,运行 `<cli> launch workflow-adopt --draft <文件> --access-file <本次任务的 access_file>`。程序校验、保存、在本房间启用并邀请缺少的卡片成员(离开的请回),返回 `members`(卡片 ID → 成员名),本次执行里就能点名派活。只能更新本房间绑定的工作流;卡片权限最高 write。 |
|
|
130
|
-
| 房间主持人,任务里没有该字段 | 你不能保存。告诉用户:在“成员与设置 →
|
|
138
|
+
| 房间主持人,任务里没有该字段 | 你不能保存。告诉用户:在“成员与设置 → 协作设置”的“主持人权限”里勾选“工作流”后,你就能自己保存并启用;用户打开后再按上一行做。 |
|
|
131
139
|
| 不在房间里,用户直接让你建 | 先在一个临时文件夹里按“格式”写好,运行 `codiscuss launch workflow-check --dir <文件夹>` 校验;用户确认后运行 `codiscuss launch workflow-save --dir <文件夹>` 保存进工作流库。同 ID 会覆盖原有工作流,覆盖前先告诉用户。 |
|
|
132
140
|
|
|
133
141
|
不要直接写入本机服务目录的 `workflows/`:那样会跳过校验和写入锁,格式错的文件会让启用它的房间读不到工作流。命令失败时按报错修正,不要绕过。
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
写卡片时:
|
|
20
20
|
|
|
21
21
|
- 只写本机已配置的平台;不确定时 `model`、`effort` 省略,用本机默认值。
|
|
22
|
-
-
|
|
22
|
+
- 模型 API 平台(`OpenAI`、`DeepSeek`、`Qwen`、`Grok`、`Custom`)的成员在本机的 Pi 环境里运行,保留会话,能读网页(本机存了 DeepSeek API Key 时还能联网搜索)。`effort` 只认 `low`、`medium`、`high`,作为推理强度传给模型,写别的值等于省略。项目可写时用 Pi 自带的读写、编辑和命令行,和本机软件一样;只读时能读、搜项目文件,命令只能跑 `commands.json` 登记的只读命令。只读又要跑脚本的角色,要么登记命令,要么用 `Claude`、`Codex`、`Antigravity` 这类本机软件。
|
|
23
23
|
- 要出图、改图的角色(插画、封面、配图)任选平台,在提示词里写明由它负责出图;房间添加了“生图”卡片(图片模型在卡片里配置)后才能画。出图角色优先用能看图的本机软件(如 `Claude`),它能下载附件自查;API 成员看不到自己画的图,用它出图时另配一张本机软件的审图卡片。
|
|
24
24
|
- 同一件事要两个视角审时,两张卡片用不同平台,避免同一家模型的盲点重叠。
|
package/backend/free_room.py
CHANGED
|
@@ -89,7 +89,7 @@ TIMELINE_SQL = f"""SELECT x.*,(SELECT COALESCE(NULLIF(s.text,''),substr(a.text,1
|
|
|
89
89
|
(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,
|
|
90
90
|
(SELECT MAX(r.answer_id) FROM member_requests r WHERE r.execution_id=e.id) AS answer_id,
|
|
91
91
|
(SELECT n.text FROM execution_notes n WHERE n.execution_id=e.id ORDER BY n.seq DESC LIMIT 1) AS last_note,
|
|
92
|
-
CASE WHEN e.changes='' THEN NULL ELSE json_array_length(e.changes) END AS changes
|
|
92
|
+
CASE WHEN e.changes='' THEN NULL ELSE json_array_length(e.changes) END AS changes,e.model,e.effort
|
|
93
93
|
FROM member_executions e JOIN room_members m ON m.id=e.member_id WHERE e.id IN ({TIMELINE_FREE_IDS})) x"""
|
|
94
94
|
TIMELINE_SEGMENTS_SQL = f"""SELECT source,execution_id,phase,tool,start_ms,end_ms FROM execution_segments WHERE room_id=?1
|
|
95
95
|
AND source='free' AND execution_id IN ({TIMELINE_FREE_IDS}) ORDER BY source,execution_id,seq"""
|
|
@@ -155,7 +155,9 @@ SESSION_MODES = ("new", "borrowed")
|
|
|
155
155
|
FREE_OPERATIONS = ("messages", "attachments", "move", "folder", "rename", "archive", "restore", "delete")
|
|
156
156
|
MEMBER_FIELDS = ("id", "name", "adapter", "role", "status", "access", "session_mode", "read_until")
|
|
157
157
|
EXECUTION_FIELDS = ("id", "member_id", "status", "session_id", "lease_until", "created_at", "finished_at", "result",
|
|
158
|
-
"activity", "activity_at", "paused_at")
|
|
158
|
+
"activity", "activity_at", "paused_at", "model", "effort")
|
|
159
|
+
# Longest model ID or effort name an execution keeps; longer reports are cut.
|
|
160
|
+
MAX_MODEL_LENGTH = 100
|
|
159
161
|
# What the runner found when a voided execution's software was to stop; '' until it reports.
|
|
160
162
|
STOP_RESULTS = ("stopped", "unstoppable", "unconfirmed")
|
|
161
163
|
# How long a member voided where the runner could not stop it gets no new delivery unless its late answer shows the turn ended.
|
|
@@ -192,7 +194,8 @@ LATER_COLUMNS = {"room_members": {"access": "TEXT NOT NULL DEFAULT 'runner'", "s
|
|
|
192
194
|
"member_executions": {"changes": "TEXT NOT NULL DEFAULT ''", "edited": "TEXT NOT NULL DEFAULT ''", "cwd": "TEXT NOT NULL DEFAULT ''",
|
|
193
195
|
"diffs": "TEXT NOT NULL DEFAULT ''", "changes_provisional": "INTEGER NOT NULL DEFAULT 0",
|
|
194
196
|
"activity": "TEXT NOT NULL DEFAULT ''", "activity_at": "INTEGER NOT NULL DEFAULT 0",
|
|
195
|
-
"paused_at": "INTEGER NOT NULL DEFAULT 0"
|
|
197
|
+
"paused_at": "INTEGER NOT NULL DEFAULT 0", "model": "TEXT NOT NULL DEFAULT ''",
|
|
198
|
+
"effort": "TEXT NOT NULL DEFAULT ''"},
|
|
196
199
|
"member_requests": {"chain_id": "INTEGER NOT NULL DEFAULT 0", "batch_id": "INTEGER NOT NULL DEFAULT 0",
|
|
197
200
|
"purpose": "TEXT NOT NULL DEFAULT 'ask'", "created_by": "TEXT NOT NULL DEFAULT 'user'"},
|
|
198
201
|
"free_chain_holds": {"asked_rounds": "INTEGER NOT NULL DEFAULT 0", "asked_reason": "TEXT NOT NULL DEFAULT ''"},
|
|
@@ -1489,9 +1492,9 @@ def keep_working(connection, room_id, host, message_id, chain_id, execution_id):
|
|
|
1489
1492
|
hanging on it, carries the same software turn on, so that work shows as its own card under the dispatch."""
|
|
1490
1493
|
now = int(time.time())
|
|
1491
1494
|
previous = connection.execute("SELECT * FROM member_executions WHERE id=?", (execution_id,)).fetchone()
|
|
1492
|
-
next_id = connection.execute("""INSERT INTO member_executions (room_id,member_id,client_id,session_id,lease_until,created_at,cwd)
|
|
1493
|
-
VALUES (
|
|
1494
|
-
|
|
1495
|
+
next_id = connection.execute("""INSERT INTO member_executions (room_id,member_id,client_id,session_id,lease_until,created_at,cwd,model,effort)
|
|
1496
|
+
VALUES (?,?,?,?,?,?,?,?,?)""", (room_id, host["id"], f"keep-working-{execution_id}", previous["session_id"],
|
|
1497
|
+
now + LEASE_SECONDS, now, previous["cwd"], previous["model"], previous["effort"])).lastrowid
|
|
1495
1498
|
connection.execute("""INSERT INTO execution_capabilities (execution_id,room_id,stoppable,progress,steer,resume)
|
|
1496
1499
|
SELECT ?,room_id,stoppable,progress,steer,resume FROM execution_capabilities WHERE execution_id=?""", (next_id, execution_id))
|
|
1497
1500
|
insert_request(connection, room_id, host["id"], message_id, chain_id, "keep_working", "host")
|
|
@@ -1542,7 +1545,7 @@ def save_suggestions(connection, room_id, message_id, member, payload):
|
|
|
1542
1545
|
prose = mention_prose(str(payload.get("text", "")))
|
|
1543
1546
|
for handle, name in member_handles(connection, room_id).items():
|
|
1544
1547
|
if name in active and name != member["name"] and re.search(
|
|
1545
|
-
r"(^|[\s(
|
|
1548
|
+
r"(^|[\s((,,。;;::、])@" + re.escape(handle) + r"(?![A-Za-z0-9_\-\u4e00-\u9fff])", prose):
|
|
1546
1549
|
targets.add(active[name]["id"])
|
|
1547
1550
|
for target_id in targets:
|
|
1548
1551
|
connection.execute("INSERT INTO member_suggestions (message_id,member_id) VALUES (?,?)", (message_id, target_id))
|
|
@@ -2624,10 +2627,10 @@ def line_of(connection, request, positions=None):
|
|
|
2624
2627
|
return {"kind": "main", "step": order.index(request["member_id"]) + 1, "by": "user"}
|
|
2625
2628
|
if connection.execute("SELECT 1 FROM session_requests WHERE member_request_id=?", (request["id"],)).fetchone():
|
|
2626
2629
|
return None
|
|
2627
|
-
# The host asked directly is a side question, not a branch
|
|
2628
|
-
#
|
|
2629
|
-
if connection.execute("SELECT 1 FROM room_members WHERE id=? AND role='host'", (request["member_id"],)).fetchone() or
|
|
2630
|
-
|
|
2630
|
+
# The host asked directly is a side question, not a branch. A member named directly works beside whatever the host
|
|
2631
|
+
# and the others do, relay or not (user 2026-11-21, #6512); only a room of a single member has nothing to branch off.
|
|
2632
|
+
if connection.execute("SELECT 1 FROM room_members WHERE id=? AND role='host'", (request["member_id"],)).fetchone() or \
|
|
2633
|
+
connection.execute("SELECT COUNT(*) FROM room_members WHERE room_id=? AND status<>'removed'", (request["room_id"],)).fetchone()[0] < 2:
|
|
2631
2634
|
return None
|
|
2632
2635
|
return {"kind": "branch", "by": request["created_by"]}
|
|
2633
2636
|
|
|
@@ -3619,6 +3622,15 @@ def execution_action(connection, room_id, execution_id, token, payload, member=N
|
|
|
3619
3622
|
changes = changed_files(payload)
|
|
3620
3623
|
connection.execute("UPDATE member_executions SET changes=?,edited=?,diffs=?,changes_provisional=? WHERE id=?",
|
|
3621
3624
|
(json.dumps(changes, ensure_ascii=False), edited_files(payload, changes), file_diffs(payload, changes), int(provisional), execution_id))
|
|
3625
|
+
elif action == "model":
|
|
3626
|
+
# What the runner's adapter says this execution ran with: the chosen model on delivery, then the session log's
|
|
3627
|
+
# after it ends, so a finished execution may still report. An empty field keeps what was reported before.
|
|
3628
|
+
values = {field: payload.get(field, "") for field in ("model", "effort")}
|
|
3629
|
+
if any(not isinstance(value, str) for value in values.values()):
|
|
3630
|
+
raise ValueError(Text("model 与 effort 须为字符串"))
|
|
3631
|
+
for field, value in values.items():
|
|
3632
|
+
if value.strip():
|
|
3633
|
+
connection.execute(f"UPDATE member_executions SET {field}=? WHERE id=?", (value.strip()[:MAX_MODEL_LENGTH], execution_id))
|
|
3622
3634
|
elif action == "denials":
|
|
3623
3635
|
# Like file changes, read from the software's output once its process ends; recorded once.
|
|
3624
3636
|
saved = connection.execute("INSERT OR IGNORE INTO execution_denials (execution_id,room_id,denials) VALUES (?,?,?)",
|
|
@@ -4096,6 +4108,84 @@ def adopt_manual_member(connection, room_id, member, payload):
|
|
|
4096
4108
|
connection.execute("UPDATE room_members SET token_hash=? WHERE id=?", (token_hash(payload["token"]), member["id"]))
|
|
4097
4109
|
|
|
4098
4110
|
|
|
4111
|
+
ROOM_LINK_RELATIONS = ("child", "parent")
|
|
4112
|
+
ROOM_ID_PATTERN = re.compile(r"[A-Za-z0-9_-]{1,64}")
|
|
4113
|
+
|
|
4114
|
+
|
|
4115
|
+
def linked_room_values(connection, room_id, other, host):
|
|
4116
|
+
"""Check another room on this site and the host's display name a cross-room record names; returns the trimmed host."""
|
|
4117
|
+
if not isinstance(other, str) or not ROOM_ID_PATTERN.fullmatch(other) or other == room_id \
|
|
4118
|
+
or not connection.execute("SELECT 1 FROM rooms WHERE id=?", (other,)).fetchone():
|
|
4119
|
+
raise ValueError(Text("关联的房间不存在"))
|
|
4120
|
+
if not isinstance(host, str) or not 0 < len(host.strip()) <= MODEL_TEXT_LIMIT:
|
|
4121
|
+
raise ValueError(Text("host 须为 1–100 字的主持人名称"))
|
|
4122
|
+
return host.strip()
|
|
4123
|
+
|
|
4124
|
+
|
|
4125
|
+
def record_room_link(connection, room_id, token, payload):
|
|
4126
|
+
"""Leave a card naming a room this room's host created (`child`) or the room whose host created this one (`parent`).
|
|
4127
|
+
|
|
4128
|
+
The runner writes one on each side with each room's owner credential after `host-control create-room`; nobody is
|
|
4129
|
+
woken. A retry for the same pair returns the card already there.
|
|
4130
|
+
"""
|
|
4131
|
+
require_owner(connection, room_id, token)
|
|
4132
|
+
relation = payload.get("relation")
|
|
4133
|
+
if relation not in ROOM_LINK_RELATIONS:
|
|
4134
|
+
raise ValueError(Text("relation 须为 child 或 parent"))
|
|
4135
|
+
host = linked_room_values(connection, room_id, payload.get("room_id"), payload.get("host"))
|
|
4136
|
+
begin_write(connection)
|
|
4137
|
+
existing = connection.execute("SELECT message_id FROM room_links WHERE room_id=? AND other_room_id=?", (room_id, payload["room_id"])).fetchone()
|
|
4138
|
+
if existing:
|
|
4139
|
+
return {"message_id": existing[0], "duplicate": True}
|
|
4140
|
+
title = connection.execute("SELECT title FROM rooms WHERE id=?", (payload["room_id"],)).fetchone()[0]
|
|
4141
|
+
text = (Text("主持人 {host} 新建了房间「{title}」。", host=host, title=title) if relation == "child"
|
|
4142
|
+
else Text("本房间由房间「{title}」的主持人 {host} 新建。", host=host, title=title))
|
|
4143
|
+
message_id = connection.execute("INSERT INTO messages(room_id,author,text,source,submission_id,created_at) VALUES(?,?,?,?,?,?)",
|
|
4144
|
+
(room_id, NOTICE_AUTHOR, text, "room_link", f"room-link-{payload['room_id']}",
|
|
4145
|
+
time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()))).lastrowid
|
|
4146
|
+
save_text(connection, "message", message_id, "text", text)
|
|
4147
|
+
connection.execute("INSERT INTO message_details (message_id,kind,submitted_by) VALUES (?,?,?)", (message_id, "notice", NOTICE_AUTHOR))
|
|
4148
|
+
connection.execute("INSERT INTO room_links (message_id,room_id,other_room_id,relation,host) VALUES (?,?,?,?,?)",
|
|
4149
|
+
(message_id, room_id, payload["room_id"], relation, host))
|
|
4150
|
+
return {"message_id": message_id, "duplicate": False}
|
|
4151
|
+
|
|
4152
|
+
|
|
4153
|
+
# The largest limit a relay may carry on how many messages two linked rooms' hosts pass each other (0 is unlimited).
|
|
4154
|
+
MAX_RELAY_LIMIT = 100
|
|
4155
|
+
|
|
4156
|
+
|
|
4157
|
+
def check_relay(connection, room_id, relay):
|
|
4158
|
+
"""Check a message another room's host sends here: the rooms are linked, and the hosts have not passed the limit.
|
|
4159
|
+
|
|
4160
|
+
`relay.limit` is the owner's limit the runner reads from this computer's preferences (0 or absent: unlimited, user
|
|
4161
|
+
2026-11-21). It counts both directions since the owner's own last message in either room; past it the write is a 409
|
|
4162
|
+
until the owner speaks. Returns the trimmed host name.
|
|
4163
|
+
"""
|
|
4164
|
+
if not isinstance(relay, dict):
|
|
4165
|
+
raise ValueError(Text("relay 须为含 room_id 与 host 的对象"))
|
|
4166
|
+
host = linked_room_values(connection, room_id, relay.get("room_id"), relay.get("host"))
|
|
4167
|
+
source, limit = relay["room_id"], relay.get("limit", 0)
|
|
4168
|
+
if type(limit) is not int or not 0 <= limit <= MAX_RELAY_LIMIT:
|
|
4169
|
+
raise ValueError(Text("relay.limit 须为 0–100 的整数,0 表示不限"))
|
|
4170
|
+
if not connection.execute("SELECT 1 FROM room_links WHERE room_id=? AND other_room_id=?", (room_id, source)).fetchone():
|
|
4171
|
+
raise PermissionError(Text("只有互相关联的房间之间才能代主持人发言"))
|
|
4172
|
+
if not limit:
|
|
4173
|
+
return host
|
|
4174
|
+
spoke = connection.execute("""SELECT COALESCE(MAX(m.id),0) FROM messages m WHERE m.room_id IN (?,?) AND m.author='用户'
|
|
4175
|
+
AND NOT EXISTS (SELECT 1 FROM message_relays r WHERE r.message_id=m.id)""", (room_id, source)).fetchone()[0]
|
|
4176
|
+
passed = connection.execute("""SELECT COUNT(*) FROM message_relays r JOIN messages m ON m.id=r.message_id WHERE m.id>?
|
|
4177
|
+
AND ((m.room_id=? AND r.source_room_id=?) OR (m.room_id=? AND r.source_room_id=?))""", (spoke, room_id, source, source, room_id)).fetchone()[0]
|
|
4178
|
+
if passed >= limit:
|
|
4179
|
+
raise FileExistsError(Text("两个房间的主持人自用户上次发言后已互传 {count} 条消息,达到上限;请等用户在任一房间发言后再继续", count=passed))
|
|
4180
|
+
return host
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
def save_message_relay(connection, room_id, message_id, relay):
|
|
4184
|
+
"""Label an owner-credential message the host of another room sent: `relay = {room_id, host}`."""
|
|
4185
|
+
host = check_relay(connection, room_id, relay)
|
|
4186
|
+
connection.execute("INSERT INTO message_relays (message_id,source_room_id,host) VALUES (?,?,?)", (message_id, relay["room_id"], host))
|
|
4187
|
+
|
|
4188
|
+
|
|
4099
4189
|
def record_model_change(connection, room_id, member, payload):
|
|
4100
4190
|
"""Leave a visible system record that the owner (or the host for it) changed a member's model; nobody is woken.
|
|
4101
4191
|
|
package/backend/message_queue.py
CHANGED
|
@@ -18,7 +18,7 @@ from .runtime import begin_write, require_owner
|
|
|
18
18
|
from .texts import Text, load_texts, save_text
|
|
19
19
|
|
|
20
20
|
QUEUED_FIELDS = ("author", "text", "reply_to", "kind", "submitted_by", "to", "sequential", "order", "attachment_ids", "attachment_start",
|
|
21
|
-
"submission_id", "message_id")
|
|
21
|
+
"submission_id", "message_id", "relay")
|
|
22
22
|
QUEUE_ACTIONS = ("send", "edit", "delete", "reorder", "resume", "queueing")
|
|
23
23
|
QUEUE_ERRORS = (ValueError, TypeError, LookupError, PermissionError, FileExistsError)
|
|
24
24
|
|
package/backend/schema.sql
CHANGED
|
@@ -101,6 +101,23 @@ CREATE TABLE IF NOT EXISTS message_details (
|
|
|
101
101
|
CREATE TABLE IF NOT EXISTS proactive_messages (
|
|
102
102
|
message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE
|
|
103
103
|
);
|
|
104
|
+
-- A card in a room naming a room its host created (`child`) or the room whose host created it (`parent`); the runner
|
|
105
|
+
-- writes one on each side after `host-control create-room`. Wakes nobody; one per pair of rooms.
|
|
106
|
+
CREATE TABLE IF NOT EXISTS room_links (
|
|
107
|
+
message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE,
|
|
108
|
+
room_id TEXT NOT NULL REFERENCES rooms(id),
|
|
109
|
+
other_room_id TEXT NOT NULL,
|
|
110
|
+
relation TEXT NOT NULL CHECK(relation IN ('child','parent')),
|
|
111
|
+
host TEXT NOT NULL,
|
|
112
|
+
UNIQUE(room_id, other_room_id)
|
|
113
|
+
);
|
|
114
|
+
-- An owner-credential message the host of another room sent here through `host-control room-post`: where it came from.
|
|
115
|
+
-- Only a label; the write itself is the owner's, so it routes and wakes like the owner's own message.
|
|
116
|
+
CREATE TABLE IF NOT EXISTS message_relays (
|
|
117
|
+
message_id INTEGER PRIMARY KEY REFERENCES messages(id) ON DELETE CASCADE,
|
|
118
|
+
source_room_id TEXT NOT NULL,
|
|
119
|
+
host TEXT NOT NULL
|
|
120
|
+
);
|
|
104
121
|
-- Site administrator account (single user) and its login sessions. Raw tokens and passwords are never stored.
|
|
105
122
|
CREATE TABLE IF NOT EXISTS site_admin (
|
|
106
123
|
id INTEGER PRIMARY KEY CHECK(id=1),
|
|
@@ -307,6 +324,10 @@ CREATE TABLE IF NOT EXISTS member_executions (
|
|
|
307
324
|
-- When the owner paused it from the private chat (0 = not paused): the runner stopped its software turn and resumes
|
|
308
325
|
-- the same execution in the same session with the owner's next line; the execution itself stays live.
|
|
309
326
|
paused_at INTEGER NOT NULL DEFAULT 0,
|
|
327
|
+
-- The model and effort this execution ran with, as the runner's adapter reported them ('' when unknown): the
|
|
328
|
+
-- chosen ones on delivery, replaced by what the software's session log says once it ends. Shown on the card.
|
|
329
|
+
model TEXT NOT NULL DEFAULT '',
|
|
330
|
+
effort TEXT NOT NULL DEFAULT '',
|
|
310
331
|
UNIQUE(room_id,client_id)
|
|
311
332
|
);
|
|
312
333
|
-- What the owner wrote about each member (strengths, division of work), by name so it survives leaving and rejoining.
|
package/backend/server.py
CHANGED
|
@@ -41,7 +41,7 @@ from .free_room import convert_suggestion, message_suggestions, save_suggestions
|
|
|
41
41
|
from .free_room import adopt_recommendation, recommend_member, register_member, require_member
|
|
42
42
|
from .private_chat import chat_action, member_chat
|
|
43
43
|
from .external_members import external_api, guard_route as guard_external_route, is_external_path, owner_api as external_owner_api
|
|
44
|
-
from .free_room import describe_members, execution_notes, label_members, set_host_checkin, withdraw_dispatch, member_descriptions, member_display_names, member_handles, member_labels, reorder_speakers, resolve_member_fields, set_chain_rounds, speaking_order, stop_room, stop_room_work
|
|
44
|
+
from .free_room import describe_members, execution_notes, label_members, check_relay, record_room_link, save_message_relay, set_host_checkin, withdraw_dispatch, member_descriptions, member_display_names, member_handles, member_labels, reorder_speakers, resolve_member_fields, set_chain_rounds, speaking_order, stop_room, stop_room_work
|
|
45
45
|
from .free_room import (ADAPTER_VALUE, LAYOUT_AFTER_SQL, LAYOUT_AT_SQL, continue_chain, execution_timeline, group_route_plan, retract_message, rewind_plan, rewind_room,
|
|
46
46
|
host_event, host_hidden_event, room_event_log, withdrawals)
|
|
47
47
|
from .free_room import review_capability, review_roster, checked_review_plan, save_review_plan, check_review_retry
|
|
@@ -214,8 +214,14 @@ COALESCE(details.submitted_by, CASE WHEN messages.source IN ('cli','api','url','
|
|
|
214
214
|
THEN messages.author ELSE '用户' END) AS submitted_by,
|
|
215
215
|
COALESCE(summaries.text,'') AS summary, COALESCE(summaries.author,'') AS summary_by, timing.elapsed_seconds,
|
|
216
216
|
answered.execution_id, answered.request_message_id, answered.layout_after, answered.layout_at, COALESCE(withdrawn.kind,'') AS withdrawn,
|
|
217
|
-
EXISTS(SELECT 1 FROM proactive_messages p WHERE p.message_id=messages.id) AS proactive
|
|
217
|
+
EXISTS(SELECT 1 FROM proactive_messages p WHERE p.message_id=messages.id) AS proactive,
|
|
218
|
+
relay.source_room_id AS relay_room, relay.host AS relay_host,
|
|
219
|
+
(SELECT l.other_room_id FROM room_links l WHERE l.message_id=messages.id) AS link_room,
|
|
220
|
+
(SELECT l.relation FROM room_links l WHERE l.message_id=messages.id) AS link_relation,
|
|
221
|
+
(SELECT r.title FROM room_links l JOIN rooms r ON r.id=l.other_room_id WHERE l.message_id=messages.id) AS link_title,
|
|
222
|
+
(SELECT r.title FROM rooms r WHERE r.id=relay.source_room_id) AS relay_title
|
|
218
223
|
FROM messages LEFT JOIN message_details AS details ON details.message_id=messages.id
|
|
224
|
+
LEFT JOIN message_relays AS relay ON relay.message_id=messages.id
|
|
219
225
|
LEFT JOIN message_withdrawals AS withdrawn ON withdrawn.message_id=messages.id
|
|
220
226
|
LEFT JOIN message_summaries AS summaries ON summaries.message_id=messages.id
|
|
221
227
|
LEFT JOIN message_timings AS timing ON timing.message_id=messages.id
|
|
@@ -1695,6 +1701,9 @@ def append_free_message(connection, room, payload, actor):
|
|
|
1695
1701
|
room_id = room["id"]
|
|
1696
1702
|
if actor == "用户" and (author != "用户" or payload.get("submitted_by", "用户") != "用户"):
|
|
1697
1703
|
raise PermissionError(Text('房间控制凭据只能以用户身份发言'))
|
|
1704
|
+
if payload.get("relay") is not None and actor != "用户":
|
|
1705
|
+
# Another room's host speaks here through `host-control room-post`, only with the owner credential.
|
|
1706
|
+
raise PermissionError(Text('只有房间控制凭据能代其他房间的主持人发言'))
|
|
1698
1707
|
submitted_by = author
|
|
1699
1708
|
source = payload.get("source") if payload.get("source") in ("api", "auto") else "cli"
|
|
1700
1709
|
expected = {"author": author, "text": text, "reply_to": reply_to, "kind": "chat", "submitted_by": submitted_by,
|
|
@@ -1713,6 +1722,8 @@ def append_free_message(connection, room, payload, actor):
|
|
|
1713
1722
|
return {"message": previous, "duplicate": True}
|
|
1714
1723
|
if room["archived"]:
|
|
1715
1724
|
raise ValueError(Text('房间已存档;恢复后才能继续协作'))
|
|
1725
|
+
if payload.get("relay") is not None:
|
|
1726
|
+
check_relay(connection, room_id, payload["relay"])
|
|
1716
1727
|
check_message_references(connection, room_id, expected)
|
|
1717
1728
|
check_message_attachments(connection, room_id, submitted_by, identifiers)
|
|
1718
1729
|
# `/goal` and `/discuss` are commands: checked before saving, never queued, and not routed to members.
|
|
@@ -1734,6 +1745,8 @@ def append_free_message(connection, room, payload, actor):
|
|
|
1734
1745
|
connection.execute("INSERT INTO message_summaries (message_id,text,author) VALUES (?,?,?)",
|
|
1735
1746
|
(cursor.lastrowid, expected["summary"], expected["summary_by"]))
|
|
1736
1747
|
link_message_attachments(connection, room_id, cursor.lastrowid, identifiers, text, payload)
|
|
1748
|
+
if payload.get("relay") is not None:
|
|
1749
|
+
save_message_relay(connection, room_id, cursor.lastrowid, payload["relay"])
|
|
1737
1750
|
# A captured reply keeps its text, but its mentions wake nobody: only a submitted answer may ask for a host.
|
|
1738
1751
|
if expected["source"] != "auto":
|
|
1739
1752
|
save_suggestions(connection, room_id, cursor.lastrowid, actor, payload)
|
|
@@ -3338,7 +3351,7 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
3338
3351
|
result = queue_action(connection, room_id, token, self.read_payload(), post_queued, check_queued, interrupt_for_message)
|
|
3339
3352
|
connection.commit()
|
|
3340
3353
|
return self.respond(result)
|
|
3341
|
-
if parts[3:4] in (["inbox"], ["executions"], ["members"], ["chats"], ["suggestions"], ["recommendations"], ["stop"], ["dispatches"], ["host-checkin"]):
|
|
3354
|
+
if parts[3:4] in (["inbox"], ["executions"], ["members"], ["chats"], ["suggestions"], ["recommendations"], ["stop"], ["dispatches"], ["host-checkin"], ["room-link"]):
|
|
3342
3355
|
return self.handle_free_api(connection, parts, method)
|
|
3343
3356
|
if parts[3:4] == ["attachments"]:
|
|
3344
3357
|
return self.handle_attachments(connection, parts, params, method)
|
|
@@ -3658,6 +3671,8 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
3658
3671
|
result = withdraw_dispatch(connection, room_id, token, int(parts[4]))
|
|
3659
3672
|
elif parts[3:] == ["host-checkin"] and method == "POST":
|
|
3660
3673
|
result = set_host_checkin(connection, room_id, token, self.read_payload())
|
|
3674
|
+
elif parts[3:] == ["room-link"] and method == "POST":
|
|
3675
|
+
result = record_room_link(connection, room_id, token, self.read_payload())
|
|
3661
3676
|
else:
|
|
3662
3677
|
raise LookupError(Text('地址不存在'))
|
|
3663
3678
|
if not self.read_only_request():
|
package/docs/deployment.md
CHANGED
|
@@ -187,3 +187,25 @@ npx wrangler deploy --config deploy/entry.wrangler.jsonc
|
|
|
187
187
|
|
|
188
188
|
- **`no such table`**:所连接的数据库尚未执行 schema,先核对配置文件指向的数据库。
|
|
189
189
|
- **端口被占用**:服务拒绝两个实例监听同一端口,改用其他端口。
|
|
190
|
+
|
|
191
|
+
## 官方房间分享站(运营方)
|
|
192
|
+
|
|
193
|
+
在线分享由独立的 Worker、D1 和自定义域名提供。访客无需安装,发布者无需自行部署。以下命令从源码仓库根目录运行,需要运营方的 Cloudflare 账号和该账号已接管的域名。
|
|
194
|
+
|
|
195
|
+
1. 运行 `npm ci`、`npm run build` 和 `npx wrangler login`。把 `deploy/share.wrangler.jsonc` 复制为同目录的 `deploy/wrangler.local.jsonc`,保留原有绑定与 Cron 配置;若该私有文件已用于其他服务,请为分享站另选私有路径并调整下列命令。
|
|
196
|
+
2. 创建独立数据库,将返回的 ID 写入私有配置的 `d1_databases[0].database_id`。在该配置顶层添加 `"routes": [{ "pattern": "<分享站完整主机名>", "custom_domain": true }]`,并将 `web/app.js` 的 `SHARE_SITE` 指向同一 HTTPS 域名。使用与配对和登录站点隔离的主机名。
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
npx wrangler d1 create codiscuss-share --config deploy/wrangler.local.jsonc
|
|
200
|
+
npx wrangler d1 execute DB --remote --file backend/share_schema.sql --config deploy/wrangler.local.jsonc
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
3. 用下列交互命令分别录入两段独立生成的随机 secret。`ADMIN_TOKEN` 只给运营方审核工具,`SOURCE_SALT` 用于给来源 IP 做 HMAC,保持稳定。确认域名和数据库后部署。Cron 每小时删除到期分享,访客访问在到期时即返回 410。
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
npx wrangler secret put ADMIN_TOKEN --config deploy/wrangler.local.jsonc
|
|
207
|
+
npx wrangler secret put SOURCE_SALT --config deploy/wrangler.local.jsonc
|
|
208
|
+
npx wrangler deploy --config deploy/wrangler.local.jsonc
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
程序按原始快照字节限制单份 5 MiB、每个来源 20 份及 50 MiB、全站 5 GB。免费 D1 的单库物理上限是 500 MB,账号合计 5 GB;压缩后的数据、索引和其他记录都占用单库空间。部署使用一个库,先达到的平台限额会先影响写入。分享页面每次检查状态,撤销或下架后停止提供内容;已由读者保存的副本无法收回。[Cloudflare D1 限额](https://developers.cloudflare.com/d1/platform/limits/)
|
package/docs/en/deployment.md
CHANGED
|
@@ -185,3 +185,25 @@ To connect a hosted computer: in the admin panel of your computer (the one that
|
|
|
185
185
|
|
|
186
186
|
- **`no such table`** — the connected database has no schema yet; check which database your configuration points to.
|
|
187
187
|
- **Port already in use** — the service refuses to share a port; choose another one.
|
|
188
|
+
|
|
189
|
+
## Official room sharing site (operators)
|
|
190
|
+
|
|
191
|
+
The online sharing service uses a dedicated Worker, D1 database and custom domain. Visitors can read links without installing the app, and publishers use the operator's service. Run the following from the repository root with a Cloudflare account that manages the chosen domain.
|
|
192
|
+
|
|
193
|
+
1. Run `npm ci`, `npm run build` and `npx wrangler login`. Copy `deploy/share.wrangler.jsonc` to `deploy/wrangler.local.jsonc`, retaining its bindings and Cron configuration. If that private file is already used by another service, choose a separate private path and adjust the commands below.
|
|
194
|
+
2. Create the dedicated database and enter the returned ID in `d1_databases[0].database_id` in the private configuration. Add `"routes": [{ "pattern": "<full-share-hostname>", "custom_domain": true }]` at the top level, and set `SHARE_SITE` in `web/app.js` to that HTTPS origin. Use a hostname separate from the pairing and sign-in sites.
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
npx wrangler d1 create codiscuss-share --config deploy/wrangler.local.jsonc
|
|
198
|
+
npx wrangler d1 execute DB --remote --file backend/share_schema.sql --config deploy/wrangler.local.jsonc
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
3. Enter two independently generated random secrets at the prompts below. Give `ADMIN_TOKEN` only to the operator's moderation tool. Keep `SOURCE_SALT` stable for source IP hashing. Verify the domain and database before deploying. An hourly Cron removes expired shares. Views return 410 as soon as a link expires.
|
|
202
|
+
|
|
203
|
+
```sh
|
|
204
|
+
npx wrangler secret put ADMIN_TOKEN --config deploy/wrangler.local.jsonc
|
|
205
|
+
npx wrangler secret put SOURCE_SALT --config deploy/wrangler.local.jsonc
|
|
206
|
+
npx wrangler deploy --config deploy/wrangler.local.jsonc
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The service limits raw snapshot data to 5 MiB per share, 20 shares and 50 MiB per source, and 5 GB across the site. Free D1 allows 500 MB of physical storage per database and 5 GB across the account. Compressed data, indexes and other records occupy space in the single configured database. Platform limits can therefore stop writes earlier. Every page request checks visibility. Revocation or moderation stops subsequent views, while copies already saved by readers remain available to them. [Cloudflare D1 limits](https://developers.cloudflare.com/d1/platform/limits/)
|
|
@@ -37,7 +37,7 @@ Invite an AI running on another computer to your room. It can read the project f
|
|
|
37
37
|
|
|
38
38
|
- **Renew from the lending computer:** Change the loan duration in the external room’s right sidebar. The new duration starts when saved and can also shorten the loan. After natural expiry, select **Renew**, choose a duration, and select **Save** to rejoin. A loan revoked by the room owner cannot be renewed.
|
|
39
39
|
- **Pause or leave from the lending computer:** In the external room’s right sidebar, select **Pause** or **Resume**. Use the room menu to **Leave room**. After the room ends, **Delete record** removes it from the local list. Paired phones and tablets can also change these settings.
|
|
40
|
-
- **Inspect access and revoke from the room owner’s computer:** In the right sidebar, open the member menu and select **Read log and access**. The same controls appear on the external expert card under **Room → Members and settings** in the
|
|
40
|
+
- **Inspect access and revoke from the room owner’s computer:** In the right sidebar, open the member menu and select **Read log and access**. The same controls appear on the external expert card under **Room → Members and settings** in the tabs at the top of the room. Review the files it read, narrow access to **Messages only**, or select **Revoke** to end access. For a seat still awaiting check-in, select “Remove seat”.
|
|
41
41
|
- **Invite again:** Ended members appear dimmed below the active list with a reason. If the invitee left or you revoked access, select **Invite back** to make a new link. The member name and history remain.
|
|
42
42
|
|
|
43
43
|
## What the other computer can and cannot read
|
package/docs/en/guide/faq.md
CHANGED
|
@@ -53,10 +53,10 @@ Shutdown and sleep interrupt local execution. During an internet outage, the loc
|
|
|
53
53
|
|
|
54
54
|
- **A member does not respond or keeps waiting.** Run `codiscuss local status`. If other work is in progress, look for the new message in the queue above the composer. For a stuck room, run `codiscuss room events <ROOM_ID>` to see what happened.
|
|
55
55
|
- **Delivery failed.** Read the original cause on the failure card. If sign-in has expired, sign in again in the AI tool or under **Account → CLI sign-ins** in the admin panel, then choose **Retry now**. Delivery can retry automatically up to three times.
|
|
56
|
-
- **Quota exhausted.** Wait for the quota to reset, switch the member's model under **Room → Members and settings** in the
|
|
56
|
+
- **Quota exhausted.** Wait for the quota to reset, switch the member's model under **Room → Members and settings** in the tabs at the top of the room, or reassign the work.
|
|
57
57
|
- **Output limit or context compression failure.** For an output limit, ask for a shorter answer or split the task. For a compression failure, shorten the input. The next run starts a fresh session.
|
|
58
58
|
- **Provider policy refusal.** Review the content and the provider's requirements before trying again. Policy refusals and compression failures do not trigger automatic retries.
|
|
59
|
-
- **Codex reports that the session is in use.** Codex App may already have the conversation open. Switch the connection to Codex App in the right sidebar or under **Room → Members and settings** in the
|
|
59
|
+
- **Codex reports that the session is in use.** Codex App may already have the conversation open. Switch the connection to Codex App in the right sidebar or under **Room → Members and settings** in the tabs at the top of the room, or use a fresh session.
|
|
60
60
|
- **A run has an unknown outcome after restart.** If the original process has exited, the service checks the records. It collects an eligible answer when it can confirm normal completion. If you see **Unable to confirm the previous run outcome after restart**, check the original conversation before retrying.
|
|
61
61
|
- **Windows reports two data directories.** Manage the service from a regular terminal, or set `DISCUSS_SERVICE_HOME` explicitly so both processes use the same directory.
|
|
62
62
|
|
|
@@ -70,7 +70,11 @@ Shutdown and sleep interrupt local execution. During an internet outage, the loc
|
|
|
70
70
|
| Appearance | Channel, Channel · Light | Choose a theme. Changes take effect immediately. |
|
|
71
71
|
| Language · 语言 | 简体中文, English | Choose the display language. Changes take effect immediately. |
|
|
72
72
|
| Conversation width | Narrow, Default, Wide | Set the width of the conversation for reading. |
|
|
73
|
+
| Card text size | Small, Medium, Large | Text size inside message cards. Medium is the default; the choice applies to this device only. |
|
|
73
74
|
| Visual effects | Full, Compact | Compact turns off background blur and layered shadows for smoother scrolling on slower devices. |
|
|
74
75
|
| Folding long answers | Relaxed, Standard, Eager | How long an answer must be before it folds, and how much stays visible, measured against the screen height. Relaxed is the default; the choice applies to this device only. |
|
|
76
|
+
| Room preferences → Host's project access | Read-only, Can write, Automatic, Full access | The project access the first member added to a new room (the host by default) starts with; Read-only by default. If its software doesn't support the chosen level, it stays read-only. Saved in the local service, kept across updates; needs the local service connected. |
|
|
75
77
|
| Speech | Text-to-speech service, General voice, voices by platform and for files, Speed, Tone, Voice input, Local process | [Local and cloud speech](voice.md#read-aloud-and-voice-input-local-and-cloud-options) |
|
|
76
78
|
| WeChat notifications | Scan to link, Send test, Unlink | [WeChat notifications](voice.md#wechat-notifications) |
|
|
79
|
+
|
|
80
|
+
The site controls animations for work status, member card flips, and opening, minimizing, or switching the layout of the file preview window. Your system's reduced-motion setting does not change these animations. The hosted sign-in page always plays its brand animation.
|