aicrosschat 0.8.7 → 0.8.9
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/README.md +38 -2
- package/bin/crosschat.mjs +15 -1
- package/mcp/server.mjs +24 -0
- package/package.json +1 -1
- package/plugin/lib/index.js +25 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
| 广播的 `note`(自由发言) | **不投递**(仍可用 `team_inbox` 读到) | 投递、只注入 |
|
|
46
46
|
| 与他机相关的事件 | 不投递 | 不投递 |
|
|
47
47
|
|
|
48
|
-
## 模型可见的工具(DSH 端共
|
|
48
|
+
## 模型可见的工具(DSH 端共 12 个)
|
|
49
49
|
|
|
50
50
|
| 工具 | 作用 |
|
|
51
51
|
|---|---|
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
| `team_claim` / `team_done` / `team_tasks` | 任务板:认领 / 完成 / 查看 |
|
|
57
57
|
| `team_profile` / `team_roster` | 能力自述 / 名册 |
|
|
58
58
|
| `team_wait` | 阻塞等一组任务完成(默认 60s,上限 300s) |
|
|
59
|
+
| `team_broadcast` | 主控把「用户决策/全局约束」广播给全员(kind=status,投递但不唤醒) |
|
|
59
60
|
|
|
60
61
|
## 任务板
|
|
61
62
|
|
|
@@ -79,7 +80,7 @@ task ──▶ open ──claim──▶ claimed ──done──▶ done
|
|
|
79
80
|
|
|
80
81
|
| 端 | 工具数 | 说明 |
|
|
81
82
|
|---|---|---|
|
|
82
|
-
| DSH 插件 | **
|
|
83
|
+
| DSH 插件 | **12** | 含 `team_join` / `team_leave`,身份随会话自动恢复 |
|
|
83
84
|
| MCP 桥 | **9** | 无 join/leave(用 `CROSSCHAT_NODE` 固定身份),其余同名同义,含 `team_wait` |
|
|
84
85
|
| CLI | **9** | 子命令 `peers/say/inbox/claim/done/tasks/profile/roster/wait` |
|
|
85
86
|
|
|
@@ -170,6 +171,41 @@ npm run smoke # 16 项,等价于 node relay/smoke.mjs
|
|
|
170
171
|
> 早先文档里提到的 `test-core.mjs`、`test-integration.mjs`、`test-two-instances.mjs` 已不存在;双实例结果属于历史记录,当前仓库不再提供该驱动脚本,**不作为可复现声明**。
|
|
171
172
|
|
|
172
173
|
|
|
174
|
+
## 进度共享与任务颗粒度(协作约定)
|
|
175
|
+
|
|
176
|
+
跨机协作最大的成本不是算力,而是**等一个不知道卡在哪的任务**。所以把下面两条当作协议的一部分:
|
|
177
|
+
|
|
178
|
+
### 1. 任务颗粒度:一个任务 = 一个可验收的交付单元
|
|
179
|
+
|
|
180
|
+
- 派活前先拆:一个任务应当能在**一次执行**内完成、并且有一个**可判定通过/不通过的结果**(文件、测试输出、指标、链接)。
|
|
181
|
+
- 不要把一个多日目标直接丢给成员;拆成「可并行 / 有依赖」的子任务,用 `dependsOn` 串起来(见上文)。
|
|
182
|
+
- 派发时写清四件事:**目标**(做什么)、**范围**(`paths`,避免重叠)、**验收标准**(怎样算完成)、**回报点**(何时发 status)。
|
|
183
|
+
- 主控侧:板上一个任务对应一个可验收结果;不要把“调研 + 实现 + 发布”塞进同一个任务。
|
|
184
|
+
|
|
185
|
+
### 2. 进度共享:关键节点必须发 `status`,不要静默
|
|
186
|
+
|
|
187
|
+
执行方在下列节点发一条 `team_say(kind=status, taskId=…)`,一条一两句即可:
|
|
188
|
+
|
|
189
|
+
| 节点 | 内容 |
|
|
190
|
+
|---|---|
|
|
191
|
+
| 开工 | 认领后说明预期做法与预计耗时 |
|
|
192
|
+
| 遇到阻塞 | 卡在哪、需要谁提供什么(同时用 `kind=blocker` 更醒目) |
|
|
193
|
+
| 长任务中途 | 每完成一个阶段发一次(建议不超过 15 分钟或每 25% 进度一次) |
|
|
194
|
+
| 完成 | 用 `team_done(taskId, 摘要)` 收口;`answer` 只是汇报,不关闭任务 |
|
|
195
|
+
|
|
196
|
+
- **不要用“我在做了”代替具体进展**:写“已完成 X,正在 Y,预计 Z 前给结果”。
|
|
197
|
+
- 主控收到 `status` 后如无新指令可只记录不回;需要改方向时再 `team_say(kind=task)` 追加。
|
|
198
|
+
- 如果任务预计会超过原估时,先发 status 再继续,别等到超时。
|
|
199
|
+
|
|
200
|
+
### 3. 用户决策的广播:只有"影响所有人"的才广播
|
|
201
|
+
|
|
202
|
+
- 用户原话里**影响全局的约束/决策**(隐私边界、命名、发布口径、账号操作禁止项),由主控用 `team_broadcast` 发一条 `status`(所有成员都会收到,但不唤醒);
|
|
203
|
+
- 单个节点的任务细节、报错、命令输出,用 `team_say` 点名,不进全员上下文;
|
|
204
|
+
- 隐私/账号信息**不要广播**;
|
|
205
|
+
- 广播前先压缩成一句可执行的话,别把聊天原文整段转发。
|
|
206
|
+
|
|
207
|
+
> 这两条是约定而非强制校验:插件不会因为没发 status 拦截你,但审计/复盘会把“静默超时”和“颗粒度过大”当作协作问题记录下来。
|
|
208
|
+
|
|
173
209
|
## 其他客户端接入(非 DSH)
|
|
174
210
|
|
|
175
211
|
协议在 relay 层,所以参与者不必是 DSH。两种接入方式:
|
package/bin/crosschat.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* crosschat health
|
|
6
6
|
* crosschat peers
|
|
7
7
|
* crosschat inbox [--since N] [--limit K]
|
|
8
|
-
* crosschat say "正文" [--to node|'*'] [--kind task] [--task T1]
|
|
8
|
+
* crosschat broadcast "正文" [--task T1]\n crosschat say "正文" [--to node|'*'] [--kind task] [--task T1]
|
|
9
9
|
*
|
|
10
10
|
* 连接参数优先级:命令行 flag > 环境变量。
|
|
11
11
|
* --relay / CROSSCHAT_RELAY 默认 http://127.0.0.1:7317
|
|
@@ -192,6 +192,20 @@ try {
|
|
|
192
192
|
? '任务板为空\n'
|
|
193
193
|
: rows.map(t => `${t.id} [${t.state}]${t.owner ? ` @${t.ownerName || t.owner}` : ''} r${t.round}`
|
|
194
194
|
+ `${t.paths?.length ? ` paths=${t.paths.join(',')}` : ''}: ${t.title}`).join('\n') + '\n')
|
|
195
|
+
} else if (command === 'broadcast') {
|
|
196
|
+
const text = flags.text ?? positional.slice(1).join(' ')
|
|
197
|
+
if (!String(text).trim()) {
|
|
198
|
+
process.stderr.write('crosschat broadcast: 正文不能为空\n')
|
|
199
|
+
process.exit(2)
|
|
200
|
+
}
|
|
201
|
+
const receipt = await client.append({
|
|
202
|
+
name,
|
|
203
|
+
kind: 'status',
|
|
204
|
+
to: '*',
|
|
205
|
+
text: String(text),
|
|
206
|
+
...(flags.task ? { taskId: String(flags.task) } : {}),
|
|
207
|
+
})
|
|
208
|
+
process.stdout.write(`已广播给全员 seq=${receipt.seq}\n`)
|
|
195
209
|
} else if (command === 'say') {
|
|
196
210
|
const text = flags.text ?? positional.slice(1).join(' ')
|
|
197
211
|
if (!String(text).trim()) {
|
package/mcp/server.mjs
CHANGED
|
@@ -110,6 +110,18 @@ const TOOLS = [
|
|
|
110
110
|
required: ['taskIds'],
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
|
+
{
|
|
114
|
+
name: 'team_broadcast',
|
|
115
|
+
description: '把一条用户决策/全局约束广播给全员(kind=status,投递但不唤醒);建议仅主控使用。',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
text: { type: 'string', description: '广播内容。' },
|
|
120
|
+
taskId: { type: 'string', description: '可选,关联任务。' },
|
|
121
|
+
},
|
|
122
|
+
required: ['text'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
113
125
|
{
|
|
114
126
|
name: 'team_peers',
|
|
115
127
|
description: '列出当前在线的协作节点和日志尾部序号。',
|
|
@@ -248,6 +260,18 @@ async function callTool(name, args) {
|
|
|
248
260
|
await new Promise(resolve => setTimeout(resolve, 2000))
|
|
249
261
|
}
|
|
250
262
|
}
|
|
263
|
+
if (name === 'team_broadcast') {
|
|
264
|
+
const text = String(args?.text ?? '').trim()
|
|
265
|
+
if (!text) throw new Error('text 不能为空')
|
|
266
|
+
const receipt = await client.append({
|
|
267
|
+
name: NAME,
|
|
268
|
+
kind: 'status',
|
|
269
|
+
to: '*',
|
|
270
|
+
text,
|
|
271
|
+
...(args?.taskId ? { taskId: String(args.taskId) } : {}),
|
|
272
|
+
})
|
|
273
|
+
return `已广播给全员(seq=${receipt.seq})。`
|
|
274
|
+
}
|
|
251
275
|
if (name === 'team_peers') {
|
|
252
276
|
const page = await client.peers()
|
|
253
277
|
const nodes = (page.peers ?? []).map(p => p.node)
|
package/package.json
CHANGED
package/plugin/lib/index.js
CHANGED
|
@@ -869,6 +869,31 @@ export function apply(ctx, config) {
|
|
|
869
869
|
},
|
|
870
870
|
}))
|
|
871
871
|
|
|
872
|
+
ctx.tools.register(defineTool({
|
|
873
|
+
name: 'team_broadcast',
|
|
874
|
+
description:
|
|
875
|
+
'把一条「用户决策 / 全局约束」广播给所有成员(kind=status:所有成员都会收到上下文,但不唤醒)。'
|
|
876
|
+
+ '仅建议主控使用;过程性信息请用 team_say 点名,避免刷屏。',
|
|
877
|
+
parameters: {
|
|
878
|
+
text: { type: 'string', required: true, description: '要广播的内容(≤8000 字)。' },
|
|
879
|
+
taskId: { type: 'string', description: '可选,关联任务。' },
|
|
880
|
+
},
|
|
881
|
+
output: {
|
|
882
|
+
schema: {
|
|
883
|
+
type: 'object',
|
|
884
|
+
additionalProperties: false,
|
|
885
|
+
properties: { ok: { type: 'boolean', required: true }, seq: { type: 'integer' } },
|
|
886
|
+
},
|
|
887
|
+
render: (_args, value) => [{ type: 'text', text: `已广播给全员(seq=${value.seq ?? '?'})。` }],
|
|
888
|
+
},
|
|
889
|
+
async execute(args) {
|
|
890
|
+
const text = String(args.text ?? '').trim()
|
|
891
|
+
if (!text) throw new Error('text 不能为空')
|
|
892
|
+
const receipt = await append({ kind: 'status', to: '*', text, ...(args.taskId ? { taskId: String(args.taskId) } : {}) })
|
|
893
|
+
return { ok: true, ...(receipt && receipt.seq ? { seq: receipt.seq } : {}) }
|
|
894
|
+
},
|
|
895
|
+
}))
|
|
896
|
+
|
|
872
897
|
ctx.tools.register(defineTool({
|
|
873
898
|
name: 'team_peers',
|
|
874
899
|
description: '列出当前在线的协作节点。',
|