@xmodelin/dsh-collab-sessions 0.0.0-stage → 0.0.1
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 +685 -2
- package/client.js +2172 -0
- package/cordis.patch.yml +195 -0
- package/icon.svg +7 -0
- package/index.js +2583 -0
- package/lib/auth.js +187 -0
- package/lib/layout.js +821 -0
- package/lib/notices.js +135 -0
- package/lib/relationships.js +157 -0
- package/lib/requests.js +315 -0
- package/lib/tasks.js +375 -0
- package/lib/write-scope.js +96 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +61 -4
package/README.md
CHANGED
|
@@ -1,3 +1,686 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Collab sessions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A DeepSeek Harness plugin that adds a **Collab** entry to the left sidebar's
|
|
4
|
+
New-session row. Activating it starts a New Session under the bundled `collab`
|
|
5
|
+
Agent preset **in the currently selected Workspace** (the same target the
|
|
6
|
+
built-in New Session button uses: the current Session's Workspace, then the
|
|
7
|
+
recent Workspace). It does not create a new Workspace per session.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Installation, bundle requirements, and profile linking are documented in the
|
|
12
|
+
repository root [README](../README.md#installation).
|
|
13
|
+
|
|
14
|
+
The `collab` preset is a copy of the shipped `standard` preset. When upgrading
|
|
15
|
+
DSH, re-sync `cordis.patch.yml` from the installed
|
|
16
|
+
`dsh-web-app/presets/standard.patch.yml`.
|
|
17
|
+
|
|
18
|
+
## What a collab session gets
|
|
19
|
+
|
|
20
|
+
1. **A unique session ID.** The Host session id (`session-<uuid>`) is stored in
|
|
21
|
+
`session.json`, returned by `collab_info`, and used as the address other
|
|
22
|
+
sessions send messages to.
|
|
23
|
+
2. **Explicitly authorized session-to-session messaging.** The `collab_*`
|
|
24
|
+
tools exchange HMAC-authenticated messages with another collab session, but
|
|
25
|
+
only after a human authorizes the pair. A cold target is resumed, a live
|
|
26
|
+
target is woken, and the browser activates the target's Session page when it
|
|
27
|
+
starts running. The message body is read through `collab_inbox`.
|
|
28
|
+
3. **A two-directory working layout.** The Session stays in its Workspace and
|
|
29
|
+
gets a per-session working directory inside it:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
<workspace>/.dsh-collab/sessions/<sessionId>/
|
|
33
|
+
comm/
|
|
34
|
+
<peerSessionId>/
|
|
35
|
+
credential.json shared pair secret
|
|
36
|
+
inbox/*.json unread inbound messages
|
|
37
|
+
outbox/*.json sent messages (normal)
|
|
38
|
+
archive/inbox/*.json read inbound messages
|
|
39
|
+
archive/outbox/ explicitly archived sent messages (normal sends stay in outbox/)
|
|
40
|
+
rejected/ quarantined invalid or oversized files
|
|
41
|
+
private/ session-only data (mode 0700)
|
|
42
|
+
session.json layout metadata
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Authorization
|
|
46
|
+
|
|
47
|
+
Only **collaboration sessions** can communicate with each other. Every
|
|
48
|
+
communication pair must be authorized explicitly and **bilaterally**: A must
|
|
49
|
+
authorize B and B must authorize A. A single-sided grant is shown as pending
|
|
50
|
+
but does not open the gate.
|
|
51
|
+
|
|
52
|
+
Open **Collab access** (协同授权) from the left sidebar panel list:
|
|
53
|
+
|
|
54
|
+
- **已授权会话对** — pairs where both sides have authorized, with a **Revoke**
|
|
55
|
+
action for each. One-sided grants appear below them as pending until the
|
|
56
|
+
other side grants too.
|
|
57
|
+
- **协同会话** — every collaboration session. Select exactly two and click
|
|
58
|
+
**Authorize both sides**.
|
|
59
|
+
|
|
60
|
+
The gate is enforced on both sides: `collab_send` requires both directional
|
|
61
|
+
grants, and delivery plus `collab_inbox` re-check them. Revoking removes both
|
|
62
|
+
directions immediately, stops new sends, and hides already queued messages from
|
|
63
|
+
`collab_inbox` until both sides are authorized again.
|
|
64
|
+
|
|
65
|
+
The page is a generated Host Remote (`ctx.remote.collabAuth`), not a session
|
|
66
|
+
command: it needs no control session and leaves no `/collab-auth` row in any
|
|
67
|
+
conversation. The Host commands remain available for manual debugging:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
/collab-auth list
|
|
71
|
+
/collab-auth authorize <sessionA> <sessionB> # both directions
|
|
72
|
+
/collab-auth grant <fromSession> <toSession> # one direction
|
|
73
|
+
/collab-auth revoke <sessionA> <sessionB> # both directions
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Authorization Remote (development)
|
|
77
|
+
|
|
78
|
+
The auth page is backed by a separate generated Typert package in
|
|
79
|
+
`../dsh-collab-api`:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
dsh-collab-api/
|
|
83
|
+
packages/dsh-collab-auth-api/ Host service + generated Remote artifacts
|
|
84
|
+
tsconfig.host.json workspace face for generation
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Build it with the DSH Typert generator:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
cd ../dsh-collab-api
|
|
91
|
+
pnpm install
|
|
92
|
+
pnpm build
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This emits `lib/typert.host.js`, `lib/typert.remote-client.js`, and the bundled
|
|
96
|
+
`lib/client.js`. The API package is a dependency of the sessions bundle, and
|
|
97
|
+
the sessions patch inserts its loader row. After rebuilding, re-enable the
|
|
98
|
+
sessions bundle (or restart DSH) and refresh the Web client so the generated
|
|
99
|
+
`remote.collabAuth` namespace remounts. Board, base
|
|
100
|
+
prompt, and link actions also use `collabAuth.panel`; they do not add command
|
|
101
|
+
rows to the conversation.
|
|
102
|
+
|
|
103
|
+
## Base prompt
|
|
104
|
+
|
|
105
|
+
Every collaboration session can carry its own **base prompt** — a baseline
|
|
106
|
+
instruction injected at the top of that session's collaboration prompt on every
|
|
107
|
+
turn. Use it for a role ("you are the reviewer") and hard constraints ("never
|
|
108
|
+
edit files; answer in Chinese"). It is per session and persists in the session's
|
|
109
|
+
`session.json` across resumes.
|
|
110
|
+
|
|
111
|
+
The only UI entry point is the collaboration session row's **更多 / More**
|
|
112
|
+
menu in the left sidebar (also available by right-clicking the row) →
|
|
113
|
+
**设置会话提示词**. The session-header More menu and the new-session hero chip
|
|
114
|
+
do not expose this editor.
|
|
115
|
+
|
|
116
|
+
The editor loads the current text, saves it, and the next turn picks it up.
|
|
117
|
+
The Host command is also available:
|
|
118
|
+
|
|
119
|
+
```text
|
|
120
|
+
/collab-base get
|
|
121
|
+
/collab-base set <base64-of-the-prompt>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Supervisor sessions
|
|
125
|
+
|
|
126
|
+
The Collab button is a dropdown with **协同会话** and **超级会话**. A supervisor
|
|
127
|
+
session is a coordination-only preset: no shell, files, office, web, or edit
|
|
128
|
+
tools. It uses task tools to plan/assign/verify; workers execute.
|
|
129
|
+
|
|
130
|
+
- **Open the boards**: use DSH’s original right-sidebar expand button. For a
|
|
131
|
+
supervisor session the right sidebar is seeded with three tabs: **start**
|
|
132
|
+
(DSH’s default guide), **任务列表** (received requests, tasks, and subtasks),
|
|
133
|
+
and **注册中心** (offered workers on top, collaboration sessions not offered
|
|
134
|
+
on the bottom). Other session types keep only the default start tab.
|
|
135
|
+
- **Registering** a worker is an **Offer** action in the 注册 tab; it writes the
|
|
136
|
+
`offer` relationship and authorizes the supervisor↔worker pair.
|
|
137
|
+
- **Capabilities are live**: name/description are derived from the worker’s
|
|
138
|
+
current title and base prompt every time a supervisor or the 注册 tab reads
|
|
139
|
+
them, so changing a base prompt never leaves a stale registration snapshot.
|
|
140
|
+
The tab marks a changed capability; **固定当前** pins the current text as a
|
|
141
|
+
human override, and **使用实时** returns to live derivation.
|
|
142
|
+
- **Supervisor rule**: call `collab_capabilities` immediately before
|
|
143
|
+
decomposition; it reports `source=live|override`, `version`, and
|
|
144
|
+
`changed=yes|no`. Task assignment records the capability version used.
|
|
145
|
+
- **Task flow**: `collab_task_create` → `collab_task_assign`; the worker accepts,
|
|
146
|
+
executes, and calls `collab_task_complete`; the supervisor reads
|
|
147
|
+
`collab_tasks` / `collab_task_result` and may reject/retry/cancel. Capacity is
|
|
148
|
+
one active task per worker.
|
|
149
|
+
- **Communication is role-agnostic**: `collab_send`, `collab_inbox`, and
|
|
150
|
+
`collab_peers` use bilateral authorization for ordinary peers, workers, and
|
|
151
|
+
supervisors alike. Chat never creates or changes tasks; only task tools do.
|
|
152
|
+
- **Task isolation**: a worker may chat with ordinary peers, but ordinary peers
|
|
153
|
+
cannot assign work directly; they submit a request to the supervisor. Task
|
|
154
|
+
results still route to the task’s supervisor.
|
|
155
|
+
- **Shared delivery**: workers write final artifacts directly to
|
|
156
|
+
`shared/<taskId>/artifacts/`; the worker can write while the task is
|
|
157
|
+
open, and read after close. A task is bound to exactly one accepted
|
|
158
|
+
request. The requester can read the task artifacts only after a successful
|
|
159
|
+
delivery, and cannot write. The supervisor lists them with
|
|
160
|
+
`collab_delivery_list`, generates `manifest.json` with
|
|
161
|
+
`collab_delivery_manifest` (path, bytes, sha256, mode), and sends the
|
|
162
|
+
sanitized manifest with `collab_request_deliver` only after the task is
|
|
163
|
+
closed and every subtask is done or cancelled. Empty deliveries are refused.
|
|
164
|
+
The notice's `root` is an opaque `.deliveries/<deliveryId>/artifacts` alias,
|
|
165
|
+
not the task path, so the requester does not receive a task id. The
|
|
166
|
+
auth API client bundle is minified but remains self-contained (`zod` is
|
|
167
|
+
bundled) for compatibility with module-loader configurations that do not
|
|
168
|
+
expose `zod` as an external module.
|
|
169
|
+
- **No copy-out**: do not create a copy task or copy artifacts to an
|
|
170
|
+
ad-hoc shared directory. The canonical `deliveryDir` is returned by the task
|
|
171
|
+
assignment; ad-hoc shared writes are denied by the guard.
|
|
172
|
+
- **Message hygiene**: opened inbox messages are recorded in a per-session
|
|
173
|
+
replay ledger; a duplicate MAC-valid message id is quarantined. First-contact
|
|
174
|
+
credential creation is serialized by a pair lock. Undelivered notices older
|
|
175
|
+
than seven days and unreferenced delivery aliases older than seven days are
|
|
176
|
+
pruned at startup/flush.
|
|
177
|
+
- **Notice outbox**: protocol notices are persisted in `notices.json` before
|
|
178
|
+
delivery and retried by the Host, so a temporary offline peer or revoked
|
|
179
|
+
authorization does not lose a committed acceptance, assignment, or result
|
|
180
|
+
wake-up.
|
|
181
|
+
- **Cross-process state locks**: registry, authorization, relationship, task,
|
|
182
|
+
request, and notice mutations use a short-lived lock and re-read the state
|
|
183
|
+
document under that lock; JSON writes are fsynced and atomically renamed.
|
|
184
|
+
The default wait is bounded to 1 second (`lockTimeoutMs`), after which the
|
|
185
|
+
error names the holder pid instead of blocking the Host event loop for five
|
|
186
|
+
seconds; `lockStaleMs` controls when an abandoned lock can be reclaimed.
|
|
187
|
+
Parsed state caches invalidate on file identity changes, and a malformed
|
|
188
|
+
state document is moved to a `.corrupt-<timestamp>` backup instead of being
|
|
189
|
+
silently replaced by an empty store.
|
|
190
|
+
- **Per-session OS sandbox**: `perSessionSandbox` (default true on macOS/Linux,
|
|
191
|
+
forced off on Windows) narrows the DSH sandbox workspace boundary to each
|
|
192
|
+
collab session's own workdir and registers its task delivery dirs as
|
|
193
|
+
writable roots. The original workspace remains the prompt/registry value.
|
|
194
|
+
Windows keeps the original workspace root and relies on the guard.
|
|
195
|
+
- **Managed-worker write scope**: `write`, `edit`, `apply_patch`, and ordinary
|
|
196
|
+
shell write targets are limited to the assigned deliveryDir, `private/`, and
|
|
197
|
+
`comm/`. The shell extractor covers bash redirections/copy verbs and common
|
|
198
|
+
PowerShell cmdlets (`Set-Content`, `Add-Content`, `Out-File`, `New-Item`,
|
|
199
|
+
`Copy-Item`, `Move-Item`, `Remove-Item`, `Invoke-WebRequest -OutFile`,
|
|
200
|
+
`[IO.File]::WriteAllText`, and similar). It is conservative, not a complete
|
|
201
|
+
PowerShell parser, and it is not an OS sandbox.
|
|
202
|
+
- **Requests do not require offer**: any collaboration session with bilateral
|
|
203
|
+
authorization to a supervisor can call `collab_request_submit`; it does not
|
|
204
|
+
need to be an offered worker. The request is a normal structured message and
|
|
205
|
+
has no fixed requester role. The requirement is outcome-focused: requester
|
|
206
|
+
text must not choose workers, tasks, subtasks, delivery paths, or internal
|
|
207
|
+
scheduling.
|
|
208
|
+
- **Supervisor accept**: evaluate `collab_capabilities`, create a task and
|
|
209
|
+
subtasks, assign at least one subtask to an offered worker, then call
|
|
210
|
+
`collab_request_accept` with the `taskId`. The request becomes `accepted`;
|
|
211
|
+
the requester is notified.
|
|
212
|
+
- **Supervisor reject**: call `collab_request_reject` with a concrete reason,
|
|
213
|
+
naming the missing capability. The request becomes `rejected`.
|
|
214
|
+
- **Request acknowledgement timeout**: a pending request expires after
|
|
215
|
+
`requestTimeoutMs` (default 10 minutes). The requester receives a
|
|
216
|
+
`request-expired` notice; an expired request cannot be accepted or rejected
|
|
217
|
+
and the requester may submit a new one. The timeout covers supervisor
|
|
218
|
+
acknowledgement only, not task execution.
|
|
219
|
+
- **Execution deadline**: an accepted request gets a soft
|
|
220
|
+
`executionTimeoutMs` deadline (default 24 hours). When it passes, the request
|
|
221
|
+
becomes `overdue` and the requester receives a `request-overdue` notice; work
|
|
222
|
+
is not automatically killed. The supervisor can call
|
|
223
|
+
`collab_request_heartbeat` with progress and an optional deadline extension;
|
|
224
|
+
the requester can cancel a pending or accepted request. Successful delivery
|
|
225
|
+
clears the deadline and moves the request to the terminal `delivered` state.
|
|
226
|
+
- **Request tools**: `collab_request_submit`, `collab_request_cancel`,
|
|
227
|
+
`collab_requests`, `collab_request_accept`, `collab_request_reject`.
|
|
228
|
+
Requests are stored in `requests.json` next to the other collaboration state.
|
|
229
|
+
- **The task tab** shows the supervisor's received requests above the selected task and its
|
|
230
|
+
subtasks, including pending/accepted/rejected status and rejection reasons.
|
|
231
|
+
|
|
232
|
+
## Supervisor panel
|
|
233
|
+
|
|
234
|
+
Supervisor sessions expose their task/capability tabs when the right sidebar is
|
|
235
|
+
opened. The plugin does not force the sidebar open or steal the active tab; it
|
|
236
|
+
seeds **start**, **任务**, and **注册** once on each collapse-to-expand
|
|
237
|
+
transition. Board, base-prompt, and link actions use the authorization Remote
|
|
238
|
+
(`collabAuth.panel`) rather than slash-command execution, so reading the board
|
|
239
|
+
does not add command rows to the conversation. The authorization Remote is a
|
|
240
|
+
required client dependency because Cordis resolves `ctx.remote.collabAuth`
|
|
241
|
+
through the injected service namespace. Management Remote calls are owner-only;
|
|
242
|
+
a non-owner Peer is rejected before it can list or mutate authorization pairs or
|
|
243
|
+
the collaboration board. The packaged Host service is the generated
|
|
244
|
+
resource-aware class (`lib/index.js`): `authorize`, `revoke`, and `panel`
|
|
245
|
+
declare the `session` resource, while `list` remains a global owner-only read.
|
|
246
|
+
The owner check is kept as the current policy, so resource metadata cannot
|
|
247
|
+
silently broaden access.
|
|
248
|
+
|
|
249
|
+
## Copy session name
|
|
250
|
+
|
|
251
|
+
Every named session row has a copy action in its hover strip, and the session
|
|
252
|
+
right-click menu has **复制会话名 / Copy session name**. The action copies the
|
|
253
|
+
display name to the clipboard and briefly marks the button as copied.
|
|
254
|
+
|
|
255
|
+
## Manual state recovery
|
|
256
|
+
|
|
257
|
+
State is under the DSH home:
|
|
258
|
+
|
|
259
|
+
```text
|
|
260
|
+
~/.dsh/collab/
|
|
261
|
+
registry.json collaboration session index
|
|
262
|
+
authorization.json bilateral communication grants
|
|
263
|
+
relationships.json supervisor↔worker offers and capability overrides
|
|
264
|
+
tasks.json tasks and subtasks
|
|
265
|
+
requests.json requester↔supervisor requests and deliveries
|
|
266
|
+
notices.json durable protocol notice outbox
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
A malformed document is moved aside as:
|
|
270
|
+
|
|
271
|
+
```text
|
|
272
|
+
<file>.corrupt-<timestamp>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
That backup is the **bad** file, not a clean backup. Do not restore it blindly.
|
|
276
|
+
|
|
277
|
+
### Repair SOP
|
|
278
|
+
|
|
279
|
+
1. **Locate the file.** The error names the exact path:
|
|
280
|
+
|
|
281
|
+
```text
|
|
282
|
+
collaboration state is corrupted: /home/me/.dsh/collab/tasks.json;
|
|
283
|
+
backup: /home/me/.dsh/collab/tasks.json.corrupt-1760000000000
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
2. **Quit DSH completely.** Do not edit state while the Host is running.
|
|
287
|
+
|
|
288
|
+
3. **Back up the whole state directory.**
|
|
289
|
+
|
|
290
|
+
```sh
|
|
291
|
+
stamp=$(date +%Y%m%d-%H%M%S)
|
|
292
|
+
cp -R ~/.dsh/collab ~/.dsh/collab.manual-backup-$stamp
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
4. **Validate every document** (read-only):
|
|
296
|
+
|
|
297
|
+
```sh
|
|
298
|
+
for name in registry authorization relationships tasks requests notices; do
|
|
299
|
+
printf '%s: ' "$name"
|
|
300
|
+
if python3 -m json.tool "$HOME/.dsh/collab/$name.json" >/dev/null 2>&1; then
|
|
301
|
+
echo OK
|
|
302
|
+
else
|
|
303
|
+
echo BAD
|
|
304
|
+
fi
|
|
305
|
+
done
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
5. **Choose the least destructive repair:**
|
|
309
|
+
|
|
310
|
+
- **Syntax error only, data still present:** fix quotes, commas, braces,
|
|
311
|
+
brackets, or truncation in a copy, then validate with
|
|
312
|
+
`python3 -m json.tool`.
|
|
313
|
+
- **Schema is broken beyond repair:** replace the file with the empty
|
|
314
|
+
skeleton below. The next write recreates the store.
|
|
315
|
+
- **Known-good backup exists:** restore that copy, not a `.corrupt-*` file.
|
|
316
|
+
- **File is missing:** do nothing; missing means empty and is recreated on
|
|
317
|
+
the next write.
|
|
318
|
+
|
|
319
|
+
6. **Preserve permissions.**
|
|
320
|
+
|
|
321
|
+
```sh
|
|
322
|
+
chmod 700 ~/.dsh/collab
|
|
323
|
+
chmod 600 ~/.dsh/collab/*.json
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
7. **Restart DSH** and verify the affected surface:
|
|
327
|
+
|
|
328
|
+
| File | Verify after restart |
|
|
329
|
+
|---|---|
|
|
330
|
+
| `registry.json` | Collaboration sessions reappear; if not, the plugin rescans the workspace `.dsh-collab` directories. |
|
|
331
|
+
| `authorization.json` | Re-authorize pairs in **Collab access** if grants are gone. |
|
|
332
|
+
| `relationships.json` | Re-offer workers in the supervisor's **注册** tab. |
|
|
333
|
+
| `tasks.json` | Task board shows the desired tasks/subtasks; delivery artifacts remain on disk. |
|
|
334
|
+
| `requests.json` | Requester and supervisor can list the requests that still exist. |
|
|
335
|
+
| `notices.json` | Pending wake-ups may be gone; the task/request stores remain authoritative. |
|
|
336
|
+
|
|
337
|
+
### Empty skeletons
|
|
338
|
+
|
|
339
|
+
Use these when the file is syntactically broken and you accept losing that
|
|
340
|
+
store's data. All are valid JSON and match the current versions.
|
|
341
|
+
|
|
342
|
+
```json
|
|
343
|
+
{"version":1,"sessions":{}}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
```json
|
|
347
|
+
{"version":2,"grants":[]}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
```json
|
|
351
|
+
{"version":1,"relationships":[]}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
```json
|
|
355
|
+
{"version":2,"tasks":{},"subtasks":{}}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{"version":2,"requests":{}}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{"version":1,"notices":{}}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Format examples
|
|
367
|
+
|
|
368
|
+
The examples below are intentionally complete. Replace the ids, paths,
|
|
369
|
+
timestamps, and hashes; keep the field names and JSON types.
|
|
370
|
+
|
|
371
|
+
#### registry.json
|
|
372
|
+
|
|
373
|
+
```json
|
|
374
|
+
{
|
|
375
|
+
"version": 1,
|
|
376
|
+
"sessions": {
|
|
377
|
+
"session-11111111-1111-4111-8111-111111111111": {
|
|
378
|
+
"sessionId": "session-11111111-1111-4111-8111-111111111111",
|
|
379
|
+
"preset": "collab",
|
|
380
|
+
"originalCwd": "/Users/me/project",
|
|
381
|
+
"workdir": "/Users/me/project/.dsh-collab/sessions/session-11111111-1111-4111-8111-111111111111",
|
|
382
|
+
"title": "Worker A",
|
|
383
|
+
"createdAt": 1760000000000,
|
|
384
|
+
"updatedAt": 1760000000000
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
- `preset` is `collab` or `supervisor`.
|
|
391
|
+
- `sessionId` must be a real `session-<uuid>` id.
|
|
392
|
+
- This file is a derived index. Resetting it is usually safe; sessions are
|
|
393
|
+
rediscovered from `<workspace>/.dsh-collab/sessions/`.
|
|
394
|
+
|
|
395
|
+
#### authorization.json
|
|
396
|
+
|
|
397
|
+
```json
|
|
398
|
+
{
|
|
399
|
+
"version": 2,
|
|
400
|
+
"grants": [
|
|
401
|
+
{
|
|
402
|
+
"from": "session-11111111-1111-4111-8111-111111111111",
|
|
403
|
+
"to": "session-22222222-2222-4222-8222-222222222222",
|
|
404
|
+
"createdAt": 1760000000000,
|
|
405
|
+
"updatedAt": 1760000000000,
|
|
406
|
+
"authorizedBy": "ui"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"from": "session-22222222-2222-4222-8222-222222222222",
|
|
410
|
+
"to": "session-11111111-1111-4111-8111-111111111111",
|
|
411
|
+
"createdAt": 1760000000000,
|
|
412
|
+
"updatedAt": 1760000000000,
|
|
413
|
+
"authorizedBy": "ui"
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
- One object is one direction. Communication requires **both** directions.
|
|
420
|
+
- A single direction is a pending grant and does not authorize messaging.
|
|
421
|
+
- Prefer re-authorizing in the UI instead of hand-writing this file.
|
|
422
|
+
|
|
423
|
+
#### relationships.json
|
|
424
|
+
|
|
425
|
+
```json
|
|
426
|
+
{
|
|
427
|
+
"version": 1,
|
|
428
|
+
"relationships": [
|
|
429
|
+
{
|
|
430
|
+
"supervisor": "session-11111111-1111-4111-8111-111111111111",
|
|
431
|
+
"worker": "session-22222222-2222-4222-8222-222222222222",
|
|
432
|
+
"capabilityOverride": null,
|
|
433
|
+
"offer": true,
|
|
434
|
+
"request": false,
|
|
435
|
+
"createdAt": 1760000000000,
|
|
436
|
+
"updatedAt": 1760000000000,
|
|
437
|
+
"createdBy": "human"
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
- `offer: true` makes the worker eligible for assignment.
|
|
444
|
+
- `capabilityOverride` may be `null` or:
|
|
445
|
+
```json
|
|
446
|
+
{"name":"reviewer","description":"Reviews changes","tags":["review"]}
|
|
447
|
+
```
|
|
448
|
+
- Prefer re-offering workers in the UI after a reset.
|
|
449
|
+
|
|
450
|
+
#### tasks.json
|
|
451
|
+
|
|
452
|
+
```json
|
|
453
|
+
{
|
|
454
|
+
"version": 2,
|
|
455
|
+
"tasks": {
|
|
456
|
+
"task-11111111-1111-4111-8111-111111111111": {
|
|
457
|
+
"id": "task-11111111-1111-4111-8111-111111111111",
|
|
458
|
+
"taskId": "task-11111111-1111-4111-8111-111111111111",
|
|
459
|
+
"supervisor": "session-11111111-1111-4111-8111-111111111111",
|
|
460
|
+
"title": "Delivery task",
|
|
461
|
+
"status": "open",
|
|
462
|
+
"requestId": null,
|
|
463
|
+
"createdAt": 1760000000000,
|
|
464
|
+
"closedAt": null
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
"subtasks": {
|
|
468
|
+
"subtask-22222222-2222-4222-8222-222222222222": {
|
|
469
|
+
"id": "subtask-22222222-2222-4222-8222-222222222222",
|
|
470
|
+
"subtaskId": "subtask-22222222-2222-4222-8222-222222222222",
|
|
471
|
+
"taskId": "task-11111111-1111-4111-8111-111111111111",
|
|
472
|
+
"supervisor": "session-11111111-1111-4111-8111-111111111111",
|
|
473
|
+
"worker": "session-22222222-2222-4222-8222-222222222222",
|
|
474
|
+
"title": "Write result.txt",
|
|
475
|
+
"instruction": "Write result.txt with the requested content.",
|
|
476
|
+
"inputs": {},
|
|
477
|
+
"acceptance": "result.txt exists and contains the requested content.",
|
|
478
|
+
"status": "done",
|
|
479
|
+
"attempts": 1,
|
|
480
|
+
"createdAt": 1760000000000,
|
|
481
|
+
"updatedAt": 1760000000000,
|
|
482
|
+
"createdTurn": null,
|
|
483
|
+
"assignedTurn": null,
|
|
484
|
+
"capabilityVersion": null,
|
|
485
|
+
"result": {
|
|
486
|
+
"summary": "Created result.txt",
|
|
487
|
+
"details": "6 bytes",
|
|
488
|
+
"artifacts": ["result.txt"],
|
|
489
|
+
"completedAt": "2026-11-24T00:00:00.000Z"
|
|
490
|
+
},
|
|
491
|
+
"failure": null,
|
|
492
|
+
"history": [
|
|
493
|
+
{"at":"2026-11-24T00:00:00.000Z","status":"assigned","note":"attempt 1"},
|
|
494
|
+
{"at":"2026-11-24T00:01:00.000Z","status":"done","note":"completed by worker"}
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
- Task and subtask keys must match their `id`.
|
|
502
|
+
- A subtask's `taskId` points at its parent task.
|
|
503
|
+
- Subtask status is one of `created`, `assigned`, `accepted`, `running`,
|
|
504
|
+
`done`, `failed`, `cancelled`.
|
|
505
|
+
- `history[].at` is an ISO timestamp; `createdAt`/`updatedAt` are epoch
|
|
506
|
+
milliseconds.
|
|
507
|
+
- Do not invent `result` or delivery files that do not exist.
|
|
508
|
+
|
|
509
|
+
#### requests.json
|
|
510
|
+
|
|
511
|
+
```json
|
|
512
|
+
{
|
|
513
|
+
"version": 2,
|
|
514
|
+
"requests": {
|
|
515
|
+
"request-33333333-3333-4333-8333-333333333333": {
|
|
516
|
+
"id": "request-33333333-3333-4333-8333-333333333333",
|
|
517
|
+
"requester": "session-33333333-3333-4333-8333-333333333333",
|
|
518
|
+
"supervisor": "session-11111111-1111-4111-8111-111111111111",
|
|
519
|
+
"title": "Deliver result.txt",
|
|
520
|
+
"requirement": "Deliver result.txt containing hello.",
|
|
521
|
+
"status": "delivered",
|
|
522
|
+
"reason": null,
|
|
523
|
+
"taskId": "task-11111111-1111-4111-8111-111111111111",
|
|
524
|
+
"subtaskIds": ["subtask-22222222-2222-4222-8222-222222222222"],
|
|
525
|
+
"response": null,
|
|
526
|
+
"createdTurn": null,
|
|
527
|
+
"createdAt": 1760000000000,
|
|
528
|
+
"updatedAt": 1760000000000,
|
|
529
|
+
"resolvedAt": 1760000000000,
|
|
530
|
+
"delivery": {
|
|
531
|
+
"deliveryId": "delivery-44444444-4444-4444-8444-444444444444",
|
|
532
|
+
"manifestSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
|
533
|
+
"deliveredAt": 1760000000000
|
|
534
|
+
},
|
|
535
|
+
"expiresAt": null,
|
|
536
|
+
"executionDeadlineAt": null,
|
|
537
|
+
"lastHeartbeatAt": null,
|
|
538
|
+
"heartbeatNote": null,
|
|
539
|
+
"overdue": false,
|
|
540
|
+
"overdueAt": null
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
- `requester` must be a real session id and must differ from `supervisor`.
|
|
547
|
+
- `status` is `pending`, `accepted`, `delivered`, `rejected`, `cancelled`, or
|
|
548
|
+
`expired`.
|
|
549
|
+
- `delivery` is `null` until delivered; a fake `manifestSha256` makes the
|
|
550
|
+
request look delivered without a valid delivery. Do not fabricate it.
|
|
551
|
+
- `taskId` is the parent task; `subtaskIds` are the worker-assigned subtasks.
|
|
552
|
+
|
|
553
|
+
#### notices.json
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"version": 1,
|
|
558
|
+
"notices": {
|
|
559
|
+
"notice-55555555-5555-4555-8555-555555555555": {
|
|
560
|
+
"id": "notice-55555555-5555-4555-8555-555555555555",
|
|
561
|
+
"from": "session-11111111-1111-4111-8111-111111111111",
|
|
562
|
+
"to": "session-22222222-2222-4222-8222-222222222222",
|
|
563
|
+
"payload": {
|
|
564
|
+
"type": "collab-task/assign",
|
|
565
|
+
"version": 1,
|
|
566
|
+
"taskId": "task-22222222-2222-4222-8222-222222222222"
|
|
567
|
+
},
|
|
568
|
+
"createdAt": 1760000000000,
|
|
569
|
+
"updatedAt": 1760000000000,
|
|
570
|
+
"attempts": 0,
|
|
571
|
+
"lastError": null
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
- `payload` is an opaque protocol object; preserve existing payloads rather
|
|
578
|
+
than inventing them.
|
|
579
|
+
- Notices are a wake-up outbox, not the source of truth. Deleting this file is
|
|
580
|
+
the least destructive reset; the next write recreates it.
|
|
581
|
+
|
|
582
|
+
### Important
|
|
583
|
+
|
|
584
|
+
- Do not put `~/.dsh/collab` on a cloud-synced or network filesystem.
|
|
585
|
+
- Do not run two DSH Hosts against one profile.
|
|
586
|
+
- Do not edit these files while DSH is running.
|
|
587
|
+
- Per-session `session.json`, `comm/` credentials, and delivery files are
|
|
588
|
+
separate from these six state documents.
|
|
589
|
+
- If JSON is valid but the schema is wrong, the plugin does not create a
|
|
590
|
+
`.corrupt-*` backup; repair or reset it using the same SOP.
|
|
591
|
+
|
|
592
|
+
## Real browser smoke test
|
|
593
|
+
|
|
594
|
+
The client unit tests render with a React stub. An opt-in CDP test launches
|
|
595
|
+
headless Chrome against the running DSH Web app, authenticates with the local
|
|
596
|
+
browser-session credential, and checks the collab sidebar entry, new-session
|
|
597
|
+
menu, and authorization Remote page:
|
|
598
|
+
|
|
599
|
+
```sh
|
|
600
|
+
DSH_BROWSER_TEST=1 npm run test:browser
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
Requirements:
|
|
604
|
+
|
|
605
|
+
- a running DSH Web server (`DSH_WEB_URL` is exported by DSH);
|
|
606
|
+
- Chrome/Chromium, or `DSH_CHROME_PATH` pointing at it;
|
|
607
|
+
- a readable local profile (`DSH_HOME`, default `~/.dsh`) so the test can mint
|
|
608
|
+
the browser-session cookie;
|
|
609
|
+
- `--no-sandbox` is used only for this local headless test.
|
|
610
|
+
|
|
611
|
+
Without these, the test skips instead of failing. An existing supervisor can
|
|
612
|
+
also be checked when its sidebar title is visible:
|
|
613
|
+
|
|
614
|
+
```sh
|
|
615
|
+
DSH_BROWSER_TEST=1 \
|
|
616
|
+
DSH_BROWSER_SUPERVISOR_TITLE='my supervisor' \
|
|
617
|
+
npm run test:browser
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
The optional scenario opens that session, expands the right sidebar once, and
|
|
621
|
+
asserts that the tasks and registration tabs are seeded.
|
|
622
|
+
|
|
623
|
+
## Usage
|
|
624
|
+
|
|
625
|
+
1. Open the Workspace you want the collab session in.
|
|
626
|
+
2. Click **New collab session** / **新建协同会话** directly below the sidebar's
|
|
627
|
+
New session button (the same rounded 38px shape; icon-only in the collapsed
|
|
628
|
+
rail).
|
|
629
|
+
3. The new Session opens in that Workspace; its working directory is the
|
|
630
|
+
per-session `.dsh-collab` directory above.
|
|
631
|
+
4. Authorize the two collaboration sessions in **Collab access** (both sides).
|
|
632
|
+
5. In a second collab session, call `collab_peers` to discover the first
|
|
633
|
+
session id, then `collab_send` with `target=<that id>`. The receiver is
|
|
634
|
+
resumed/woken; its page activates; its prompt asks it to read the queued
|
|
635
|
+
message with `collab_inbox`, process it, and reply with `collab_send`.
|
|
636
|
+
|
|
637
|
+
## Tools
|
|
638
|
+
|
|
639
|
+
| Tool | Purpose |
|
|
640
|
+
|---|---|
|
|
641
|
+
| `collab_info` | Session id, working directories, peers, unread counts |
|
|
642
|
+
| `collab_peers` | Exact peer session ids, online state, credentials |
|
|
643
|
+
| `collab_send` | Send one authenticated message (`target`, `message`) |
|
|
644
|
+
| `collab_inbox` | Read and acknowledge queued messages (`peer`, `mark_read`) |
|
|
645
|
+
|
|
646
|
+
## Limitations
|
|
647
|
+
|
|
648
|
+
- Another session's whole work directory is protected, not only its `private/`
|
|
649
|
+
directory, because `comm/` holds the pair credential. The guard covers the
|
|
650
|
+
`bash`/`pwsh` tools (including `workdir` and command tokens), `working_directory`
|
|
651
|
+
(`cd`), `read`, `read_image`, `write`, `edit`, `glob`, `grep`,
|
|
652
|
+
`apply_patch`, and `office_render`/`office_convert`/`office_recalculate`,
|
|
653
|
+
plus `present` file paths. Managed-worker writes are additionally checked for
|
|
654
|
+
`write`, `edit`, `apply_patch`, and bash/PowerShell destination targets. Paths are resolved through symlinks before
|
|
655
|
+
comparison, including shared-delivery paths. For a collaboration session,
|
|
656
|
+
wildcard tokens that could expand into `.dsh-collab/sessions`, recursive
|
|
657
|
+
searches, and shells whose effective directory contains another session's
|
|
658
|
+
work directory are refused; ancestor checks are not skipped when a shell
|
|
659
|
+
starts in an authorized delivery directory.
|
|
660
|
+
Normal project sessions keep their full shell and search behavior; only their
|
|
661
|
+
direct access to a collaboration work directory is denied.
|
|
662
|
+
- The guard is not itself an OS security sandbox. On macOS/Linux, with
|
|
663
|
+
`perSessionSandbox` enabled and a DSH `sandboxPolicy` provider, the OS
|
|
664
|
+
boundary is narrowed to the session workdir plus open delivery roots; on
|
|
665
|
+
Windows this per-session narrowing is disabled and the guard is the
|
|
666
|
+
boundary. Another OS user is kept out by `0700` mode, but the same OS user
|
|
667
|
+
running another session is blocked only by the guard on Windows: a
|
|
668
|
+
deliberately obfuscated PowerShell script, a hard link to a protected file, a
|
|
669
|
+
future file-reading tool the guard does not know, or the human GUI's file
|
|
670
|
+
browser is outside that boundary.
|
|
671
|
+
- Messaging is local to this Harness profile. Nothing is sent over the network.
|
|
672
|
+
The pair credential is a shared secret, so either side of a pair can produce
|
|
673
|
+
a valid MAC for that pair; the file guard prevents a third session from
|
|
674
|
+
reading it. The authorization check is a separate human-controlled gate of
|
|
675
|
+
directional grants, stored in `authorization.json` next to the session
|
|
676
|
+
registry; a pair works only when both directions are present.
|
|
677
|
+
- Existing pairs are not authorized automatically after this feature is added;
|
|
678
|
+
authorize them in **Collab access** before messaging.
|
|
679
|
+
- A **disabled** bundle removes the preset. A stored session whose recorded
|
|
680
|
+
preset is `collab` cannot resume until the bundle is re-enabled. Session
|
|
681
|
+
directories remain on disk.
|
|
682
|
+
- The `collab` preset is a copy of the shipped `standard` preset because DSH
|
|
683
|
+
has no preset inheritance. When a DSH upgrade changes `standard`, update
|
|
684
|
+
`cordis.patch.yml` from the installed `dsh-web-app/presets/standard.patch.yml`.
|
|
685
|
+
- The plugin accepts an optional `registryPath` in its row config but does not
|
|
686
|
+
declare a `Config` schema.
|