dsh-collab-pair 1.2.0 → 1.2.2

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
@@ -143,7 +143,7 @@ The `collab-pair` row in `cordis.patch.yml`:
143
143
  - id: collab-pair
144
144
  name: 'dsh-collab-pair'
145
145
  config:
146
- maxRounds: 20 # rounds per worker
146
+ maxRounds: 0 # rounds per worker; 0 = unlimited
147
147
  maxRelayChars: 12000 # max characters of the worker's final output in a relay
148
148
  maxHistory: 20 # recent rounds kept per worker
149
149
  notifyWorkerOnDone: true # tell the worker to stop when the link is finished
@@ -164,6 +164,7 @@ One record per worker lives in `$DSH_HOME/storages/collab_pair.json` (storage-do
164
164
  ## Limits
165
165
 
166
166
  - A worker conversation belongs to one collaboration at a time; a manager can own several workers.
167
+ - Rounds are unlimited by default (`maxRounds: 0`); set a positive number to cap each worker.
167
168
  - A conversation cannot be both manager and worker.
168
169
  - Worker conversations need a configured model (new conversations inherit the deployment default).
169
170
  - 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.
@@ -310,7 +311,7 @@ dsh plugin add dsh-collab-pair
310
311
  - id: collab-pair
311
312
  name: 'dsh-collab-pair'
312
313
  config:
313
- maxRounds: 20 # 每个员工最多派发多少轮
314
+ maxRounds: 0 # 每个员工最多派发多少轮;0 = 不限制
314
315
  maxRelayChars: 12000 # 回传时最终产出的最大字符数
315
316
  maxHistory: 20 # 每个员工保留的最近轮次
316
317
  notifyWorkerOnDone: true # done 时通知员工停止
@@ -331,6 +332,7 @@ dsh plugin add dsh-collab-pair
331
332
  ## 限制
332
333
 
333
334
  - 员工对话同时只能属于一个协作;项目经理可以关联多个员工。
335
+ - 默认不限制轮次(`maxRounds: 0`);填正数才会给每个员工设上限。
334
336
  - 一个对话不能同时是项目经理和员工。
335
337
  - 员工对话需要已配置模型(新建对话继承部署默认模型)。
336
338
  - 回传以用户消息形式进入项目经理对话(带【协作回报】标题与轮次标记)。生成文本跟随 `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)
@@ -225,7 +234,7 @@ const LANGUAGES = {
225
234
  '- 需要调整某个员工的 agent 预设或模型时,用 `collab_configure`(worker 指定员工)。',
226
235
  '- 收到以【协作回报】开头的消息后,继续派发,或对该员工调用 `collab_done`;`collab_status` 查看全部进度。',
227
236
  '- 除非用户明确要求,不要自己执行员工的交付任务;你负责拆解、验收和决定下一步。',
228
- `- 每个员工最多 ${maxRounds} 轮。`,
237
+ maxRounds > 0 ? `- 每个员工最多 ${maxRounds} 轮。` : '- 不限制轮次,直到你调用 collab_done 收尾。',
229
238
  ].join('\n')
230
239
  },
231
240
  workerSection({ manager, round, pending, project }) {
@@ -283,7 +292,7 @@ const LANGUAGES = {
283
292
  : '(员工本轮没有额外文字总结,以上汇报即为其产出。)'),
284
293
  '',
285
294
  )
286
- if (round >= maxRounds) lines.push(`⚠ 该员工已达到配置的最大轮次 ${maxRounds},无法再派发新一轮;请验收成果后调用 collab_done 收尾。`, '')
295
+ if (maxRounds > 0 && round >= maxRounds) lines.push(`⚠ 该员工已达到配置的最大轮次 ${maxRounds},无法再派发新一轮;请验收成果后调用 collab_done 收尾。`, '')
287
296
  lines.push(
288
297
  '—— 下一步 ——',
289
298
  '请以项目经理身份审阅本轮结果:',
@@ -363,7 +372,7 @@ const LANGUAGES = {
363
372
  '- To change a worker\'s agent preset or model, use `collab_configure` (select the worker with `worker`).',
364
373
  '- 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
374
  '- 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.`,
375
+ maxRounds > 0 ? `- At most ${maxRounds} rounds per worker.` : '- Rounds are unlimited; continue until you call collab_done.',
367
376
  ].join('\n')
368
377
  },
369
378
  workerSection({ manager, round, pending, project }) {
@@ -421,7 +430,7 @@ const LANGUAGES = {
421
430
  : '(the worker added no text summary; the report above is its output.)'),
422
431
  '',
423
432
  )
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.`, '')
433
+ 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
434
  lines.push(
426
435
  '— Next —',
427
436
  'Review this result as the project manager:',
@@ -497,6 +506,7 @@ export function apply(ctx, rawConfig) {
497
506
  })
498
507
  if (cfg.autoNudge) watchdogTimer = setInterval(() => { void runWatchdog() }, 60000)
499
508
  setTimeout(() => { void recoverPendingLinks() }, 5000)
509
+ setTimeout(() => { void backfillProjects() }, 3000)
500
510
 
501
511
  registerTools()
502
512
  registerCommand()
@@ -1045,7 +1055,7 @@ export function apply(ctx, rawConfig) {
1045
1055
  return {
1046
1056
  ok: true,
1047
1057
  generatedAt: isoTime(Date.now()),
1048
- maxRounds: cfg.maxRounds,
1058
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1049
1059
  maxNudges: cfg.maxNudges,
1050
1060
  language: cfg.language,
1051
1061
  activeCount: rows.filter((row) => row.status === ACTIVE).length,
@@ -1068,7 +1078,7 @@ export function apply(ctx, rawConfig) {
1068
1078
  if (link.pending !== null && !force) {
1069
1079
  throw new CollabError(`第 ${link.pending.round} 轮仍在等待该员工回报,不要重复派发;需要覆盖请传 force=true。`)
1070
1080
  }
1071
- if (link.round >= cfg.maxRounds) {
1081
+ if (cfg.maxRounds > 0 && link.round >= cfg.maxRounds) {
1072
1082
  throw new CollabError(`已达到最大轮次 ${cfg.maxRounds},请验收成果并调用 collab_done 收尾。`)
1073
1083
  }
1074
1084
  const round = link.round + 1
@@ -1234,6 +1244,24 @@ export function apply(ctx, rawConfig) {
1234
1244
  }
1235
1245
  }
1236
1246
 
1247
+ /**
1248
+ * Name links created before the project field existed: derive the project
1249
+ * from the manager conversation title once, then persist it.
1250
+ */
1251
+ async function backfillProjects() {
1252
+ if (!alive) return
1253
+ for (const link of [...links.values()]) {
1254
+ if (!alive) return
1255
+ if (typeof link.project === 'string' && link.project !== '') continue
1256
+ const title = await titleOf(link.manager)
1257
+ const name = typeof title === 'string' ? stripKnownPrefix(title) : ''
1258
+ if (name === '') continue
1259
+ link.project = name
1260
+ link.updatedAt = Date.now()
1261
+ await persist(link)
1262
+ }
1263
+ }
1264
+
1237
1265
  /** Serialize relays per link so one turn cannot relay twice. */
1238
1266
  function enqueueRelay(linkId, run) { const previous = relays.get(linkId) ?? Promise.resolve()
1239
1267
  const next = previous.then(run, run).catch((error) => {
@@ -1625,7 +1653,7 @@ export function apply(ctx, rawConfig) {
1625
1653
  role: 'manager',
1626
1654
  project: managerProjectName(agent.id) || null,
1627
1655
  manager: { sessionId: agent.id, title: (await titleOf(agent.id)) ?? null },
1628
- maxRounds: cfg.maxRounds,
1656
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1629
1657
  activeCount: visible.filter((link) => link.status === ACTIVE).length,
1630
1658
  totalCount: managed.length,
1631
1659
  workers,
@@ -1657,7 +1685,7 @@ export function apply(ctx, rawConfig) {
1657
1685
  goal: link.goal || null,
1658
1686
  status: link.status,
1659
1687
  round: link.round,
1660
- maxRounds: cfg.maxRounds,
1688
+ maxRounds: cfg.maxRounds === 0 ? null : cfg.maxRounds,
1661
1689
  pending: link.pending === null
1662
1690
  ? null
1663
1691
  : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-collab-pair",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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",