dsh-collab-pair 1.5.1 → 1.5.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 +18 -0
- package/client.js +5 -0
- package/hub.js +6 -0
- package/index.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,15 @@ Security: the token is a shared secret for the room; anyone holding it can deliv
|
|
|
112
112
|
|
|
113
113
|
If a tunnel is inconvenient, choose **Free public relay (ntfy.sh)** in the Settings card: no account and no deployment. The topic is derived from room + token; messages go through ntfy.sh in 4 KB chunks (the free tier allows about 250 publishes per day per IP). Use a long random token; this is not end-to-end encrypted.
|
|
114
114
|
|
|
115
|
+
**`127.0.0.1` / `localhost` only works on the machine running the hub.** On every other device use the hub's LAN IP (same network, with the firewall port open) or the HTTPS tunnel URL. `hub.js` prints its LAN addresses at startup. Before relying on a relay, open `<hub-url>/v1/health` from the other device and press **Test connection** in the Settings card.
|
|
116
|
+
|
|
117
|
+
Cross-device checklist:
|
|
118
|
+
|
|
119
|
+
- the other device can open `<hub-url>/v1/health`;
|
|
120
|
+
- both devices use the same `hubRoom` and `hubToken`, with **distinct** `deviceName`s;
|
|
121
|
+
- the worker device registered its alias, and the manager linked that device + alias;
|
|
122
|
+
- remote workers run on their own machine, so files are **not** shared: use a common git remote or network drive, or ask the worker to return patches/text in its report.
|
|
123
|
+
|
|
115
124
|
## Stage queue
|
|
116
125
|
|
|
117
126
|
A human can pre-write several large stages for one worker; finishing one dispatches the next automatically.
|
|
@@ -372,6 +381,15 @@ collab_dispatch({ worker: "前端", task: "…" })
|
|
|
372
381
|
|
|
373
382
|
如果内网穿透不方便,可在设置卡片里选 **免费公共中继(ntfy.sh)**:不用账号、不用部署。topic 由 room + token 派生;消息以 4 KB 分片经过 ntfy.sh(免费额度约每 IP 每天 250 次发布)。请用足够长的随机 token;这不是端到端加密。
|
|
374
383
|
|
|
384
|
+
**`127.0.0.1` / `localhost` 只对运行 hub 的那台机器有效。** 其他设备要填 hub 所在机器的局域网 IP(同一网络、防火墙放行端口)或 HTTPS 隧道地址;`hub.js` 启动时会打印局域网地址。正式使用前,从另一台设备打开 `<hub 地址>/v1/health`,并在设置卡片里点「测试连接」。
|
|
385
|
+
|
|
386
|
+
跨设备检查清单:
|
|
387
|
+
|
|
388
|
+
- 另一台设备能打开 `<hub 地址>/v1/health`;
|
|
389
|
+
- 两台设备的 `hubRoom`、`hubToken` 相同,`deviceName` **不同**;
|
|
390
|
+
- 员工设备已注册别名,经理设备关联了该设备 + 别名;
|
|
391
|
+
- 远程员工在各自机器上执行,**文件不共享**:用共同的 git remote 或网络盘,或让员工在回报里给出 patch/文本。
|
|
392
|
+
|
|
375
393
|
## 阶段队列
|
|
376
394
|
|
|
377
395
|
人可以给同一个员工预先写好多个大阶段;完成一个阶段后自动派发下一个。
|
package/client.js
CHANGED
|
@@ -77,6 +77,7 @@ window.__ModuleLoader__.load({
|
|
|
77
77
|
relayNtfy: '免费公共中继 ntfy.sh',
|
|
78
78
|
relayOffHint: '关闭后不再轮询中继,令牌会保留,切回时无需重填。',
|
|
79
79
|
relayHubUrl: 'Hub 地址',
|
|
80
|
+
relayLocalhostHint: '127.0.0.1 / localhost 只在本机可访问;另一台设备请填这台机器的局域网 IP 或 HTTPS 隧道地址。',
|
|
80
81
|
relayRoom: '房间',
|
|
81
82
|
relayToken: '令牌',
|
|
82
83
|
relayTokenKeep: '留空保留已保存的令牌',
|
|
@@ -230,6 +231,7 @@ window.__ModuleLoader__.load({
|
|
|
230
231
|
relayNtfy: 'Free public relay ntfy.sh',
|
|
231
232
|
relayOffHint: 'Turning it off stops polling and keeps the token for next time.',
|
|
232
233
|
relayHubUrl: 'Hub URL',
|
|
234
|
+
relayLocalhostHint: '127.0.0.1 / localhost only works on this machine; on another device use this machine’s LAN address or an HTTPS tunnel URL.',
|
|
233
235
|
relayRoom: 'Room',
|
|
234
236
|
relayToken: 'Token',
|
|
235
237
|
relayTokenKeep: 'Leave blank to keep the saved token',
|
|
@@ -960,6 +962,9 @@ window.__ModuleLoader__.load({
|
|
|
960
962
|
onChange: (event) => setRelayHubUrl(event.target.value),
|
|
961
963
|
}))
|
|
962
964
|
: null,
|
|
965
|
+
relayMode === 'hub' && /^https?:\/\/(localhost|127\.0\.0\.1)(:|\/|$)/i.test(relayHubUrl.trim())
|
|
966
|
+
? h('p', { style: S.hint }, t('relayLocalhostHint'))
|
|
967
|
+
: null,
|
|
963
968
|
relayMode === 'off'
|
|
964
969
|
? null
|
|
965
970
|
: h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
package/hub.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
// for dispatch/report round trips; it is deliberately not a durable queue.
|
|
18
18
|
|
|
19
19
|
import { createHash, randomBytes, timingSafeEqual } from 'node:crypto'
|
|
20
|
+
import { networkInterfaces } from 'node:os'
|
|
20
21
|
import { createServer } from 'node:http'
|
|
21
22
|
|
|
22
23
|
const args = new Map()
|
|
@@ -192,6 +193,11 @@ const server = createServer(async (request, response) => {
|
|
|
192
193
|
|
|
193
194
|
server.listen(port, host, () => {
|
|
194
195
|
console.log(`collab-pair hub listening on http://${host}:${port}`)
|
|
196
|
+
const lan = Object.values(networkInterfaces()).flat()
|
|
197
|
+
.filter((entry) => entry !== undefined && entry.family === 'IPv4' && entry.internal !== true)
|
|
198
|
+
.map((entry) => `http://${entry.address}:${port}`)
|
|
199
|
+
if (lan.length > 0) console.log(`LAN addresses: ${lan.join(' ')}`)
|
|
195
200
|
console.log(`token: ${token}`)
|
|
201
|
+
console.log('127.0.0.1/localhost only works on this machine; other devices must use a LAN address or an HTTPS tunnel')
|
|
196
202
|
console.log('put the hub behind HTTPS before using it across untrusted networks')
|
|
197
203
|
})
|
package/index.js
CHANGED
|
@@ -41,7 +41,7 @@ const DONE = 'done'
|
|
|
41
41
|
const STOPPED = 'stopped'
|
|
42
42
|
const REPORTS = new Set(['done', 'partial', 'blocked'])
|
|
43
43
|
const PROMPT_TIMEOUT_MS = 180000
|
|
44
|
-
const ENGINE = 'collab-pair/1.5.
|
|
44
|
+
const ENGINE = 'collab-pair/1.5.2'
|
|
45
45
|
const PREFIX_DEFAULTS = {
|
|
46
46
|
zh: { manager: '【项目经理】', worker: '【员工】' },
|
|
47
47
|
en: { manager: '[Manager]', worker: '[Worker]' },
|
|
@@ -289,6 +289,7 @@ const LANGUAGES = {
|
|
|
289
289
|
'',
|
|
290
290
|
'规则:',
|
|
291
291
|
'- 默认自主创建员工:需要人干活时,先用 `collab_worker_create` 建立合适的员工(可按角色建多个),再派发;不要等用户手动新建。',
|
|
292
|
+
'- 远端设备上的员工用 `collab_remote` 关联(先在设置页的「跨设备协作」里配置中继);本机员工才用 `collab_worker_create`,不要重复创建。',
|
|
292
293
|
'- 不要自己承担员工的具体执行工作。你负责拆解、派发、验收和决定下一步;自己动手只限于规划、审阅和必要协调,避免因长时间执行而错过员工回报。',
|
|
293
294
|
'- 用 `collab_dispatch` 派发任务;有多个员工时用 `worker` 指定员工(sessionId 或标题),只有一个时可省略。',
|
|
294
295
|
'- 阶段队列:用 `collab_stage` 添加/查看;当前阶段验收通过后调用 `collab_stage({action:"complete"})`,会自动派发下一阶段。',
|
|
@@ -429,6 +430,7 @@ const LANGUAGES = {
|
|
|
429
430
|
'',
|
|
430
431
|
'Rules:',
|
|
431
432
|
'- Create workers by default: when work needs doing, use `collab_worker_create` to make the right worker(s) (multiple roles if needed), then dispatch. Do not wait for the user to create them manually.',
|
|
433
|
+
'- For a worker on another device use `collab_remote` (configure the relay in the Settings cross-device card first); only create a local worker with `collab_worker_create`. Do not duplicate it.',
|
|
432
434
|
'- Do not do the workers\' execution work yourself. You break down, dispatch, review and decide; your own hands-on work should be limited to planning, review and necessary coordination, so a long execution does not make you miss worker reports.',
|
|
433
435
|
'- 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.',
|
|
434
436
|
'- Stage queue: manage it with `collab_stage`; when the current stage passes acceptance, call `collab_stage({action:"complete"})` to dispatch the next stage automatically.',
|
|
@@ -2366,7 +2368,7 @@ export function apply(ctx, rawConfig) {
|
|
|
2366
2368
|
toolExecutors.remote = register({
|
|
2367
2369
|
name: 'collab_remote',
|
|
2368
2370
|
description:
|
|
2369
|
-
'
|
|
2371
|
+
'跨设备协作:在设置页的「跨设备协作」里选择中继并保存(自建 hub 或免费 ntfy.sh)。action=alias 在员工设备上把当前对话注册成别名;action=link 在项目经理设备上关联远端设备上的别名;action=aliases / remove-alias / status 查看或维护。',
|
|
2370
2372
|
parameters: {
|
|
2371
2373
|
type: 'object',
|
|
2372
2374
|
properties: {
|
|
@@ -3205,14 +3207,18 @@ export function apply(ctx, rawConfig) {
|
|
|
3205
3207
|
if (sub === 'test') {
|
|
3206
3208
|
if (!relayConfigured()) return { kind: 'error', text: '中继未启用:先选择模式并保存。' }
|
|
3207
3209
|
try {
|
|
3210
|
+
let message = ''
|
|
3208
3211
|
if (cfg.relayMode === 'hub') {
|
|
3209
3212
|
await hubFetch(`/v1/head?room=${encodeURIComponent(cfg.hubRoom)}`)
|
|
3213
|
+
if (/^https?:\/\/(localhost|127\.0\.0\.1)(:|\/|$)/i.test(cfg.hubUrl)) {
|
|
3214
|
+
message = '连接成功,但这个地址只在本机可访问;跨设备请改用局域网 IP 或 HTTPS 隧道地址。'
|
|
3215
|
+
}
|
|
3210
3216
|
} else {
|
|
3211
3217
|
const response = await fetch(`https://ntfy.sh/${encodeURIComponent(ntfyTopic())}/json?poll=1&since=10m`, { signal: AbortSignal.timeout(15000) })
|
|
3212
3218
|
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
|
3213
3219
|
await response.text()
|
|
3214
3220
|
}
|
|
3215
|
-
return { kind: 'success', text: JSON.stringify({ ok: true, mode: cfg.relayMode, device: cfg.deviceName, room: cfg.hubRoom }) }
|
|
3221
|
+
return { kind: 'success', text: JSON.stringify({ ok: true, mode: cfg.relayMode, device: cfg.deviceName, room: cfg.hubRoom, ...(message === '' ? {} : { message }) }) }
|
|
3216
3222
|
} catch (error) {
|
|
3217
3223
|
return { kind: 'error', text: `连接测试失败:${error instanceof Error ? error.message : String(error)}` }
|
|
3218
3224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-collab-pair",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "DSH collaboration plugin: link a project-manager conversation with local or remote workers across devices, dispatch rounds, relay results and manage projects/stages automatically. Also ships a prompt to-do queue for any conversation: pre-write a series of prompts and the next one is sent when a turn ends. Includes a relay hub and a free ntfy.sh transport.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|