dsh-collab-pair 1.2.1 → 1.2.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/README.md CHANGED
@@ -61,7 +61,8 @@ Set `autoNudge: false` to disable reminders.
61
61
  A project is the set of workers managed by one project-manager conversation. Different managers are different projects, so nothing mixes:
62
62
 
63
63
  - On the first link the project name defaults to the manager conversation title (role prefix removed).
64
- - Rename it in the manager card or with `collab_project({ name })` / `/collab project {"name":"…"}`; every worker of that manager follows the project.
64
+ - Rename it in the manager card or with `collab_project({ name })` / `/collab project {"name":"…"}
65
+ /collab create {"name":"前端","preset":"standard"}`; every worker of that manager follows the project.
65
66
  - The board groups tasks by project (project name + manager).
66
67
  - A worker belongs to exactly one project at a time; unlink it before linking it to another manager.
67
68
 
@@ -105,6 +106,7 @@ For an existing conversation, call `collab_sessions` to get its id, then `collab
105
106
  | --- | --- | --- |
106
107
  | `collab_sessions` | anyone | List recent conversations (id / title / activity / link state) |
107
108
  | `collab_link` | anyone | Link a worker; `role=worker` makes the current conversation the worker; `peer="new"` creates one; `mode` picks temporary/permanent; `project` names the project |
109
+ | `collab_worker_create` | manager | Create a new worker conversation (name, preset/model), linked automatically; can dispatch the first round |
108
110
  | `collab_dispatch` | manager | Dispatch one round; `worker` selects the worker (optional with a single worker), `acceptance` optional |
109
111
  | `collab_report` | worker | Report `summary` / `status`(done\|partial\|blocked) / `details` / `next` |
110
112
  | `collab_status` | anyone | A manager sees every worker's progress; a worker sees its manager and pending task |
@@ -124,6 +126,7 @@ The settings page uses it; it can also be typed manually:
124
126
  /collab link {"peer":"new"}
125
127
  /collab link {"peer":"session-…"}
126
128
  /collab project {"name":"…"}
129
+ /collab create {"name":"前端","preset":"standard"}
127
130
  /collab configure {"worker":"session-…","preset":"ptc"}
128
131
  /collab configure {"worker":"session-…","provider":"deepseek-account","model":"deepseek-flash"}
129
132
  /collab dispatch {"worker":"session-…","task":"…","acceptance":"…"}
@@ -143,7 +146,7 @@ The `collab-pair` row in `cordis.patch.yml`:
143
146
  - id: collab-pair
144
147
  name: 'dsh-collab-pair'
145
148
  config:
146
- maxRounds: 20 # rounds per worker
149
+ maxRounds: 0 # rounds per worker; 0 = unlimited
147
150
  maxRelayChars: 12000 # max characters of the worker's final output in a relay
148
151
  maxHistory: 20 # recent rounds kept per worker
149
152
  notifyWorkerOnDone: true # tell the worker to stop when the link is finished
@@ -164,6 +167,7 @@ One record per worker lives in `$DSH_HOME/storages/collab_pair.json` (storage-do
164
167
  ## Limits
165
168
 
166
169
  - A worker conversation belongs to one collaboration at a time; a manager can own several workers.
170
+ - Rounds are unlimited by default (`maxRounds: 0`); set a positive number to cap each worker.
167
171
  - A conversation cannot be both manager and worker.
168
172
  - Worker conversations need a configured model (new conversations inherit the deployment default).
169
173
  - Relayed results arrive as user messages in the manager conversation, with a report header and round marker. The generated text follows `language`; tool descriptions and internal error messages are Chinese in this release.
@@ -232,7 +236,8 @@ dsh plugin add dsh-collab-pair
232
236
  一个项目就是「一个项目经理对话所管理的员工集合」。不同项目经理就是不同项目,互不混淆:
233
237
 
234
238
  - 第一次关联时,项目名默认取项目经理对话的标题(去掉角色前缀)。
235
- - 可在项目经理卡片里改名,或用 `collab_project({ name })` / `/collab project {"name":"…"}`;该经理的所有员工会一起归到新项目名。
239
+ - 可在项目经理卡片里改名,或用 `collab_project({ name })` / `/collab project {"name":"…"}
240
+ /collab create {"name":"前端","preset":"standard"}`;该经理的所有员工会一起归到新项目名。
236
241
  - 看板按项目分组(项目名 + 项目经理)。
237
242
  - 一个员工同一时间只属于一个项目;要换项目经理,先解除原关联。
238
243
 
@@ -272,6 +277,7 @@ dsh plugin add dsh-collab-pair
272
277
  | --- | --- | --- |
273
278
  | `collab_sessions` | 任何人 | 列出最近对话(id / 标题 / 活跃 / 是否已关联) |
274
279
  | `collab_link` | 任何人 | 关联员工;`role=worker` 表示当前对话成为对方的员工;`peer="new"` 新建;`mode` 选临时/永久;`project` 指定项目名 |
280
+ | `collab_worker_create` | 项目经理 | 新建员工对话(可命名、设预设/模型),默认自动关联,可顺便派发第一轮 |
275
281
  | `collab_dispatch` | 项目经理 | 派发一轮;`worker` 指定员工(只有一个时可省略),`acceptance` 可选 |
276
282
  | `collab_report` | 员工 | 汇报 `summary` / `status`(done\|partial\|blocked) / `details` / `next` |
277
283
  | `collab_status` | 任何人 | 经理看所有员工进度;员工看自己的经理与待办 |
@@ -291,6 +297,7 @@ dsh plugin add dsh-collab-pair
291
297
  /collab link {"peer":"new"}
292
298
  /collab link {"peer":"session-…"}
293
299
  /collab project {"name":"…"}
300
+ /collab create {"name":"前端","preset":"standard"}
294
301
  /collab configure {"worker":"session-…","preset":"ptc"}
295
302
  /collab configure {"worker":"session-…","provider":"deepseek-account","model":"deepseek-flash"}
296
303
  /collab dispatch {"worker":"session-…","task":"…","acceptance":"…"}
@@ -310,7 +317,7 @@ dsh plugin add dsh-collab-pair
310
317
  - id: collab-pair
311
318
  name: 'dsh-collab-pair'
312
319
  config:
313
- maxRounds: 20 # 每个员工最多派发多少轮
320
+ maxRounds: 0 # 每个员工最多派发多少轮;0 = 不限制
314
321
  maxRelayChars: 12000 # 回传时最终产出的最大字符数
315
322
  maxHistory: 20 # 每个员工保留的最近轮次
316
323
  notifyWorkerOnDone: true # done 时通知员工停止
@@ -331,6 +338,7 @@ dsh plugin add dsh-collab-pair
331
338
  ## 限制
332
339
 
333
340
  - 员工对话同时只能属于一个协作;项目经理可以关联多个员工。
341
+ - 默认不限制轮次(`maxRounds: 0`);填正数才会给每个员工设上限。
334
342
  - 一个对话不能同时是项目经理和员工。
335
343
  - 员工对话需要已配置模型(新建对话继承部署默认模型)。
336
344
  - 回传以用户消息形式进入项目经理对话(带【协作回报】标题与轮次标记)。生成文本跟随 `language`;工具描述与内部错误信息本版本仍为中文。
package/cordis.patch.yml CHANGED
@@ -2,7 +2,7 @@
2
2
  - id: collab-pair
3
3
  name: 'dsh-collab-pair'
4
4
  config:
5
- maxRounds: 20
5
+ maxRounds: 0
6
6
  maxRelayChars: 12000
7
7
  maxHistory: 20
8
8
  notifyWorkerOnDone: true
package/index.js CHANGED
@@ -32,7 +32,7 @@ const DONE = 'done'
32
32
  const STOPPED = 'stopped'
33
33
  const REPORTS = new Set(['done', 'partial', 'blocked'])
34
34
  const PROMPT_TIMEOUT_MS = 180000
35
- const ENGINE = 'collab-pair/1.2.0'
35
+ const ENGINE = 'collab-pair/1.2.2'
36
36
 
37
37
  /** A recoverable failure whose message is meant for the model. */
38
38
  class CollabError extends Error {}
@@ -46,7 +46,7 @@ class CollabError extends Error {}
46
46
  function resolveConfig(raw) {
47
47
  const value = raw !== null && typeof raw === 'object' ? raw : {}
48
48
  return {
49
- maxRounds: clampInt(value.maxRounds, 1, 200, 20),
49
+ maxRounds: normalizeRounds(value.maxRounds),
50
50
  maxRelayChars: clampInt(value.maxRelayChars, 500, 100000, 12000),
51
51
  maxHistory: clampInt(value.maxHistory, 1, 100, 20),
52
52
  notifyWorkerOnDone: value.notifyWorkerOnDone !== false,
@@ -69,6 +69,15 @@ function prefixText(candidate, fallback) {
69
69
  return value.length > 24 ? value.slice(0, 24) : value
70
70
  }
71
71
 
72
+ /** Rounds per worker: 0 (the default) means unlimited. */
73
+ function normalizeRounds(candidate) {
74
+ const number = typeof candidate === 'number' ? candidate : Number(candidate)
75
+ if (!Number.isFinite(number)) return 0
76
+ const integer = Math.trunc(number)
77
+ if (integer <= 0) return 0
78
+ return Math.min(integer, 100000)
79
+ }
80
+
72
81
  /** Clamp one integer setting. */
73
82
  function clampInt(candidate, min, max, fallback) {
74
83
  const number = typeof candidate === 'number' ? candidate : Number(candidate)
@@ -222,10 +231,11 @@ const LANGUAGES = {
222
231
  '',
223
232
  '规则:',
224
233
  '- 用 `collab_dispatch` 派发任务;有多个员工时用 `worker` 指定员工(sessionId 或标题),只有一个时可省略。',
234
+ '- 需要新的员工对话时用 `collab_worker_create`(可命名、设预设/模型,并自动关联)。',
225
235
  '- 需要调整某个员工的 agent 预设或模型时,用 `collab_configure`(worker 指定员工)。',
226
236
  '- 收到以【协作回报】开头的消息后,继续派发,或对该员工调用 `collab_done`;`collab_status` 查看全部进度。',
227
237
  '- 除非用户明确要求,不要自己执行员工的交付任务;你负责拆解、验收和决定下一步。',
228
- `- 每个员工最多 ${maxRounds} 轮。`,
238
+ maxRounds > 0 ? `- 每个员工最多 ${maxRounds} 轮。` : '- 不限制轮次,直到你调用 collab_done 收尾。',
229
239
  ].join('\n')
230
240
  },
231
241
  workerSection({ manager, round, pending, project }) {
@@ -283,7 +293,7 @@ const LANGUAGES = {
283
293
  : '(员工本轮没有额外文字总结,以上汇报即为其产出。)'),
284
294
  '',
285
295
  )
286
- if (round >= maxRounds) lines.push(`⚠ 该员工已达到配置的最大轮次 ${maxRounds},无法再派发新一轮;请验收成果后调用 collab_done 收尾。`, '')
296
+ if (maxRounds > 0 && round >= maxRounds) lines.push(`⚠ 该员工已达到配置的最大轮次 ${maxRounds},无法再派发新一轮;请验收成果后调用 collab_done 收尾。`, '')
287
297
  lines.push(
288
298
  '—— 下一步 ——',
289
299
  '请以项目经理身份审阅本轮结果:',
@@ -360,10 +370,11 @@ const LANGUAGES = {
360
370
  '',
361
371
  'Rules:',
362
372
  '- Dispatch a round with `collab_dispatch`; when several workers exist, select one with `worker` (session id or title). With a single worker you may omit it.',
373
+ '- To start a new worker conversation use `collab_worker_create` (name, preset/model, linked automatically).',
363
374
  '- To change a worker\'s agent preset or model, use `collab_configure` (select the worker with `worker`).',
364
375
  '- When a message starting with [Collaboration report] arrives, dispatch the next round or call `collab_done` for that worker; `collab_status` shows every worker.',
365
376
  '- Unless the user explicitly asks, do not do the workers\' delivery work yourself; you break down, review, and decide.',
366
- `- At most ${maxRounds} rounds per worker.`,
377
+ maxRounds > 0 ? `- At most ${maxRounds} rounds per worker.` : '- Rounds are unlimited; continue until you call collab_done.',
367
378
  ].join('\n')
368
379
  },
369
380
  workerSection({ manager, round, pending, project }) {
@@ -421,7 +432,7 @@ const LANGUAGES = {
421
432
  : '(the worker added no text summary; the report above is its output.)'),
422
433
  '',
423
434
  )
424
- if (round >= maxRounds) lines.push(`⚠ This worker reached the configured maximum of ${maxRounds} rounds and cannot receive another round; review the result and call collab_done.`, '')
435
+ if (maxRounds > 0 && round >= maxRounds) lines.push(`⚠ This worker reached the configured maximum of ${maxRounds} rounds and cannot receive another round; review the result and call collab_done.`, '')
425
436
  lines.push(
426
437
  '— Next —',
427
438
  'Review this result as the project manager:',
@@ -783,14 +794,17 @@ export function apply(ctx, rawConfig) {
783
794
  }
784
795
 
785
796
  /** Create a fresh worker conversation in the manager's working directory. */
786
- async function createWorkerSession(callerId, requestedCwd, signal) {
797
+ async function createWorkerSession(callerId, requestedCwd, signal, agentPreset) {
787
798
  const controller = ctx.get('sessionController')
788
799
  if (controller === undefined) throw new CollabError('当前环境不支持新建对话;请先手动创建一个对话再关联。')
789
800
  const callerSession = ctx.sessions.get(callerId)
790
801
  const cwd = typeof requestedCwd === 'string' && requestedCwd.trim() !== ''
791
802
  ? requestedCwd.trim()
792
803
  : (callerSession === undefined ? undefined : ctx.get('workingDirectory')?.get(callerSession))
793
- const created = await controller.create(cwd === undefined ? {} : { cwd })
804
+ const created = await controller.create({
805
+ ...(cwd === undefined ? {} : { cwd }),
806
+ ...(typeof agentPreset === 'string' && agentPreset !== '' ? { agentPreset } : {}),
807
+ })
794
808
  const sessionId = created?.sessionId
795
809
  if (typeof sessionId !== 'string') throw new CollabError('新建对话失败:没有返回 sessionId。')
796
810
  const registry = ctx.get('workspaceRegistry')
@@ -1046,7 +1060,7 @@ export function apply(ctx, rawConfig) {
1046
1060
  return {
1047
1061
  ok: true,
1048
1062
  generatedAt: isoTime(Date.now()),
1049
- maxRounds: cfg.maxRounds,
1063
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1050
1064
  maxNudges: cfg.maxNudges,
1051
1065
  language: cfg.language,
1052
1066
  activeCount: rows.filter((row) => row.status === ACTIVE).length,
@@ -1069,7 +1083,7 @@ export function apply(ctx, rawConfig) {
1069
1083
  if (link.pending !== null && !force) {
1070
1084
  throw new CollabError(`第 ${link.pending.round} 轮仍在等待该员工回报,不要重复派发;需要覆盖请传 force=true。`)
1071
1085
  }
1072
- if (link.round >= cfg.maxRounds) {
1086
+ if (cfg.maxRounds > 0 && link.round >= cfg.maxRounds) {
1073
1087
  throw new CollabError(`已达到最大轮次 ${cfg.maxRounds},请验收成果并调用 collab_done 收尾。`)
1074
1088
  }
1075
1089
  const round = link.round + 1
@@ -1515,6 +1529,91 @@ export function apply(ctx, rawConfig) {
1515
1529
  },
1516
1530
  })
1517
1531
 
1532
+ toolExecutors.create = register({
1533
+ name: 'collab_worker_create',
1534
+ description:
1535
+ '创建一个新的员工对话,可命名、设 agent 预设/模型,默认立即关联到当前对话(项目经理)。相当于「新建对话 + collab_link(peer=new)」,也可以顺便派发第一轮任务。',
1536
+ parameters: {
1537
+ type: 'object',
1538
+ properties: {
1539
+ name: { type: 'string', description: '可选:员工名,会作为对话标题(自动加【员工】前缀)。' },
1540
+ cwd: { type: 'string', description: '可选:新对话的工作目录,默认与当前对话相同。' },
1541
+ preset: { type: 'string', description: '可选:agent 预设 id(如 standard / ptc / minimal)。' },
1542
+ provider: { type: 'string', description: '可选:模型供应商 id(配合 model)。' },
1543
+ model: { type: 'string', description: '可选:模型 id。' },
1544
+ reasoningEffort: { type: 'string', description: '可选:推理强度。' },
1545
+ mode: { type: 'string', enum: ['temporary', 'permanent'], description: '关联模式,默认 temporary。' },
1546
+ project: { type: 'string', description: '可选:项目名。' },
1547
+ link: { type: 'boolean', description: '是否立即关联,默认 true。' },
1548
+ task: { type: 'string', description: '可选:创建后立即派发的第一轮任务。' },
1549
+ acceptance: { type: 'string', description: '可选:第一轮验收标准。' },
1550
+ },
1551
+ },
1552
+ async execute(args, exec) {
1553
+ const agent = requireAgent(exec)
1554
+ if (workerAssociation(agent.id) !== undefined) throw new CollabError('当前对话是员工,不能创建或管理员工。')
1555
+ const link = args?.link !== false
1556
+ const task = typeof args?.task === 'string' ? args.task.trim() : ''
1557
+ const acceptance = typeof args?.acceptance === 'string' ? args.acceptance.trim() : ''
1558
+ if (!link && task !== '') throw new CollabError('link=false 时不能派发任务;请先关联再派发。')
1559
+ const presetId = typeof args?.preset === 'string' ? args.preset.trim() : ''
1560
+ if (presetId !== '') {
1561
+ const presets = ctx.get('agentPresets')
1562
+ if (presets === undefined) throw new CollabError('当前环境没有 agentPresets 服务,无法设置预设。')
1563
+ const roster = await presets.list()
1564
+ if (!roster.some((preset) => preset.id === presetId || preset.name === presetId)) {
1565
+ throw new CollabError(`没有预设 "${presetId}";可用:${roster.map((preset) => preset.id).join(' / ')}`)
1566
+ }
1567
+ }
1568
+ const providerId = typeof args?.provider === 'string' ? args.provider.trim() : ''
1569
+ const modelId = typeof args?.model === 'string' ? args.model.trim() : ''
1570
+ if (modelId !== '' && providerId === '') throw new CollabError('设置模型时还需要 provider。')
1571
+ const name = typeof args?.name === 'string' ? args.name.trim() : ''
1572
+ const sessionId = await createWorkerSession(agent.id, args?.cwd, exec.signal, presetId)
1573
+ let title = null
1574
+ if (name !== '') {
1575
+ const base = stripKnownPrefix(name)
1576
+ title = cfg.addPrefix ? `${cfg.prefixWorker}${base}` : base
1577
+ await renameSession(sessionId, title)
1578
+ }
1579
+ if (modelId !== '') {
1580
+ const controller = ctx.get('sessionController')
1581
+ if (controller === undefined || typeof controller.selectModel !== 'function') throw new CollabError('当前环境缺少 sessionController,无法设置模型。')
1582
+ const effort = typeof args?.reasoningEffort === 'string' ? args.reasoningEffort.trim() : ''
1583
+ await controller.selectModel({
1584
+ sessionId,
1585
+ provider: providerId,
1586
+ model: modelId,
1587
+ ...(effort === '' ? {} : { reasoningEffort: effort }),
1588
+ })
1589
+ }
1590
+ let linked = null
1591
+ if (link) {
1592
+ linked = await toolExecutors.link.execute({
1593
+ peer: sessionId,
1594
+ mode: args?.mode === 'permanent' ? 'permanent' : 'temporary',
1595
+ ...(typeof args?.project === 'string' && args.project.trim() !== '' ? { project: args.project.trim() } : {}),
1596
+ }, { agent, signal: exec.signal })
1597
+ }
1598
+ let receipt = null
1599
+ if (linked !== null && task !== '') {
1600
+ receipt = await toolExecutors.dispatch.execute({ task, acceptance, worker: sessionId }, { agent, signal: exec.signal })
1601
+ }
1602
+ return {
1603
+ ok: true,
1604
+ sessionId,
1605
+ title,
1606
+ linked: linked !== null,
1607
+ ...(linked === null ? {} : { linkId: linked.linkId, mode: linked.mode, project: managerProjectName(agent.id) || null }),
1608
+ ...(receipt === null ? {} : { round: receipt.round }),
1609
+ message: linked === null
1610
+ ? `已创建员工对话 ${sessionId}(未关联)。`
1611
+ : `已创建并关联员工 ${sessionId}${title === null ? '' : `(${title})`}${receipt === null ? '' : `,第 ${receipt.round} 轮任务已派发`}。`,
1612
+ }
1613
+ },
1614
+ when: ({ agent }) => workerAssociation(agent.id) === undefined,
1615
+ })
1616
+
1518
1617
  toolExecutors.dispatch = register({
1519
1618
  name: 'collab_dispatch',
1520
1619
  description:
@@ -1644,7 +1743,7 @@ export function apply(ctx, rawConfig) {
1644
1743
  role: 'manager',
1645
1744
  project: managerProjectName(agent.id) || null,
1646
1745
  manager: { sessionId: agent.id, title: (await titleOf(agent.id)) ?? null },
1647
- maxRounds: cfg.maxRounds,
1746
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1648
1747
  activeCount: visible.filter((link) => link.status === ACTIVE).length,
1649
1748
  totalCount: managed.length,
1650
1749
  workers,
@@ -1676,7 +1775,7 @@ export function apply(ctx, rawConfig) {
1676
1775
  goal: link.goal || null,
1677
1776
  status: link.status,
1678
1777
  round: link.round,
1679
- maxRounds: cfg.maxRounds,
1778
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1680
1779
  pending: link.pending === null
1681
1780
  ? null
1682
1781
  : {
@@ -1958,6 +2057,7 @@ export function apply(ctx, rawConfig) {
1958
2057
  const actions = {
1959
2058
  status: 'status',
1960
2059
  link: 'link',
2060
+ create: 'create',
1961
2061
  dispatch: 'dispatch',
1962
2062
  configure: 'configure',
1963
2063
  project: 'project',
@@ -1969,7 +2069,7 @@ export function apply(ctx, rawConfig) {
1969
2069
  name: 'collab',
1970
2070
  description: '双对话协作:查看全部任务、关联员工、设置项目名、配置预设与语言、派发任务、收尾或解除。',
1971
2071
  input: {
1972
- hint: 'tasks | status | link --peer <id|new> | project --name <项目名> | configure --preset <id> | language <zh|en> | dispatch --worker <id> --task ... | done --worker <id> --summary ... | unlink --worker <id>',
2072
+ hint: 'tasks | status | link --peer <id|new> | create --name <名字> --preset <id> | project --name <项目名> | configure --preset <id> | language <zh|en> | dispatch --worker <id> --task ... | done --worker <id> --summary ... | unlink --worker <id>',
1973
2073
  },
1974
2074
  handler: async (invocation) => {
1975
2075
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-collab-pair",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "For large projects: link a project-manager conversation with one or more worker conversations (temporary links unbind when done, permanent links stay until unlinked), group managers and workers by project, dispatch each round from the manager instead of repeating prompts, relay results automatically, and keep unattended runs moving with a visual task board.",
5
5
  "type": "module",
6
6
  "license": "MIT",