dsh-hello 0.1.7 → 0.1.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 CHANGED
@@ -1,595 +1,74 @@
1
1
  # DSH Hello
2
2
 
3
+ English | [中文](https://github.com/ada87/dsh-hello/blob/main/README.zh.md) | [日本語](https://github.com/ada87/dsh-hello/blob/main/README.ja.md) | [Español](https://github.com/ada87/dsh-hello/blob/main/README.es.md) | [Français](https://github.com/ada87/dsh-hello/blob/main/README.fr.md) | [Deutsch](https://github.com/ada87/dsh-hello/blob/main/README.de.md) | [Русский](https://github.com/ada87/dsh-hello/blob/main/README.ru.md) | [Português](https://github.com/ada87/dsh-hello/blob/main/README.pt.md)
4
+
3
5
  [![npm version](https://img.shields.io/npm/v/dsh-hello?color=3d7bfd)](https://www.npmjs.com/package/dsh-hello)
4
6
  [![license](https://img.shields.io/npm/l/dsh-hello?color=3d7bfd)](https://github.com/ada87/dsh-hello/blob/main/LICENSE)
5
7
  [![dsh](https://img.shields.io/badge/dsh-0.2.x-3d7bfd)](https://github.com/ada87/dsh-hello/blob/main/docs/COMPATIBILITY.md)
6
8
 
7
- Non-official mobile BFF for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`).
8
- It is a normal dsh plugin: it runs inside the Host process, calls the Host's own
9
- Cordis services, and speaks a small JSON + SSE protocol to the React Native app.
10
-
11
- It does **not** use Typert Remote, does **not** fork dsh, and does **not** put a
12
- relay server between the user's phone and the user's Host.
13
-
14
- ## Features
15
-
16
- - **The session list, everywhere.** Open the drawer to read every session with tags, unread weight and live status.
17
- - **Reply without opening a laptop.** Send a prompt, queue it behind the current turn, or steer mid-turn.
18
- - **Approve tool calls from the phone.** Allow, always-allow or deny; answer the agent's structured questions.
19
- - **Terminal and files.** Open a real PTY for the session, leave it running in the background, and browse the workspace.
20
- - **Push when you leave.** Optional FCM/APNs notifications for turn end, approvals and questions, plus webhook targets (WeCom, ServerChan, ntfy, Bark, generic) that work without Google services.
21
- - **One token per device.** Pair once; revoke any device from Settings at any time.
9
+ 1. **Your sessions, everywhere.** Every workspace, live run state, pending counts, pins and unread sessions, with search over the whole list.
10
+ 2. **Reply without opening a laptop.** Follow the output, queue a message behind the current turn, or steer the agent mid-turn.
11
+ 3. **Approve tool calls and answer questions.** Allow once, allow the tool for the session, or deny, with command, diff and URL previews.
12
+ 4. **A real terminal and the workspace.** Open a PTY in the session directory, preview code, Markdown, PDF and Office files, and browse session media.
13
+ 5. **Push when you leave.** Optional FCM/APNs, or webhooks to WeCom, ntfy, Bark and ServerChan without Google services.
14
+ 6. **Direct connection.** The app talks to your own Host through this plugin: no account, no relay, one token per device.
22
15
 
23
- | Phone | Tablet |
24
- |---|---|
25
- | ![Session drawer on a phone](https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/phone-drawer.png) | ![Session list and chat side by side on a tablet](https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/tablet-split.png) |
16
+ ![DSH Hello on a tablet](https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/tablet.png)
26
17
 
27
18
  ## Install
28
19
 
29
- ```sh
30
- dsh plugin --profile web add dsh-hello
31
- ```
32
- From a checkout or a packed tarball:
33
-
34
- ```sh
35
- dsh plugin --profile web add /path/to/dsh-hello
36
- # or
37
- pnpm pack
38
- dsh plugin --profile web add ./dsh-hello-<version>.tgz
39
- ```
40
-
41
- Restart `dsh web`. The terminal prints:
42
-
43
- ```text
44
- [dsh-hello] dsh 0.2.2-rc.3 satisfies >=0.2.2-0 <0.3.0
45
- [dsh-hello] routes mounted at /dsh-hello (protocol 2, push none)
46
- [dsh-hello] pairing code 1234 — open the app, enter the server URL, then this code.
47
- ```
48
-
49
- The code has a five-minute TTL by default. After a successful pairing it rotates;
50
- the terminal prints the next one.
51
-
52
- ### Pairing and compatibility
53
-
54
- The pairing code is **four digits** by default (`1234`). The Settings page offers
55
- three modes: **One-time** (fresh code, `pairingTtlMs` TTL), **Permanent** (does
56
- not expire until changed) and **Locked** (no new devices; paired ones keep
57
- working). Each client address gets `pairingMaxAttempts` (8) tries per TTL. Four
58
- digits are convenient but low entropy: keep dsh on a trusted LAN/Tailscale, or
59
- raise `pairingCodeLength` / lower `pairingMaxAttempts` before exposing it to the
60
- internet.
61
-
62
- The Host's compatibility gate enforces the `engines.dsh` range at install and
63
- profile startup. If a linked or exempted install runs outside the tested range,
64
- the plugin logs a warning and reports `dshCompatible: false` in `/health`
65
- instead of failing to load.
66
-
67
- Supported window: the latest three **minor** lines, starting with 0.2.2.
68
- Prerelease suffixes (`alpha`, `rc`) do not create a new line; `0.2.2-rc.1` and
69
- `0.2.2-rc.3` are one line. The current matrix and test record live in
70
- [`docs/COMPATIBILITY.md`](docs/COMPATIBILITY.md) and `compat/versions.json`.
71
-
72
- `engines.dsh` reads `>=0.2.2-0 <0.3.0`. 0.2.1 is outside the support window: it
73
- lacks `sessionController.state()` and the page cursor, so the plugin no longer
74
- carries shims for it. A Host outside the range still loads with a warning and
75
- reports `dshCompatible: false` in `/health`.
76
-
77
- ## Usage
78
-
79
- - Open `dsh web` → **Settings → DSH Hello** to read the pairing code and manage paired devices.
80
- - In the app, enter the Host URL and the four-digit code; the device stores its own bearer token.
81
- - The drawer lists sessions: open one to read, reply, approve tool calls, or open its terminal and files.
82
- - Push is optional; register an FCM/APNs token under Settings when a relay is configured.
83
-
84
- ## Why a plugin
85
-
86
- The official browser client uses generated Typert codecs and `/api/remote.mux`.
87
- Those artifacts are browser bundles, and dsh's `/api` route sits behind a
88
- Host/Origin fence and browser cookies. A native app cannot consume either
89
- cleanly. This plugin registers its own routes on the same `webServer`, authenticates
90
- devices with its own bearer token, and uses the Host's own
91
- `sessionController` / `approval` / `userQuestions` services.
92
-
93
- ## Upgrade
94
-
95
- Install from the npm registry (the default `dsh plugin add dsh-hello`) so dsh can
96
- track releases. The **dsh-hello** page under **Plugins** then shows **Update
97
- available** and a **Versions** section; **Update** removes the old version,
98
- installs the selected one, keeps the bundle enabled, and recomposes with HMR or
99
- asks for a restart. A failed update restores the previous version when possible.
100
-
101
- The **Update / Versions** section is a dsh 0.2.2 feature. When the page has no
102
- update action, update from the CLI instead:
103
-
104
- ```sh
105
- dsh plugin --profile web remove dsh-hello
106
- dsh plugin --profile web add dsh-hello@latest
107
- # restart dsh
108
- ```
20
+ Open **Plugins → Add plugin**, enter `dsh-hello`, then install. Restart `dsh web` if the terminal asks.
109
21
 
110
- The Web UI is preferred on 0.2.2+ because it checks `engines.dsh` before
111
- touching the profile and rolls back a failed install. From the CLI:
112
-
113
- ```sh
114
- dsh plugin --profile web add dsh-hello@latest
115
- # restart dsh if the result asks for it
116
- ```
117
-
118
- If you installed from a tarball or a `link:` path, that entry is not updatable;
119
- switch it once:
120
-
121
- ```sh
122
- dsh plugin --profile web remove dsh-hello
123
- dsh plugin --profile web add dsh-hello@latest
124
- ```
125
-
126
- ### dsh upgrades
22
+ | 1. Plugins | 2. Add plugin |
23
+ |---|---|
24
+ | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/install-plugins.png" width="420" alt="Open Plugins"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/install-add.png" width="420" alt="Add dsh-hello"> |
127
25
 
128
- The plugin is a profile dependency, so upgrading dsh keeps it installed. dsh
129
- 0.2.x releases stay inside the supported range. A dsh 0.3.x Host refuses this
130
- version at startup and marks it incompatible: update dsh-hello to a release with
131
- a matching range instead of reinstalling. Pairings and device tokens live in the
132
- credential store under `dsh-hello/*` and survive plugin updates.
26
+ Then open **Settings → DSH Hello**. The page prints a four-digit pairing code and a QR code.
133
27
 
134
- ### Coming from `@xdnote/dsh-mobile`
28
+ | 3. Settings | 4. Pair your phone |
29
+ |---|---|
30
+ | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/install-settings.png" width="300" alt="Settings menu"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/install-pair.png" width="300" alt="Pairing code and QR code"> |
135
31
 
136
- Remove the old package once; it owns the old `/dsh-mobile` routes and the old
137
- credential keys:
32
+ From the CLI:
138
33
 
139
34
  ```sh
140
- dsh plugin --profile web remove @xdnote/dsh-mobile
141
35
  dsh plugin --profile web add dsh-hello
36
+ # restart dsh web if the result asks for it
142
37
  ```
143
38
 
144
- Device records now live under `dsh-hello/*`, so pairings are not migrated: pair
145
- the phone again. The app's storage keys are also `@dsh-hello/*` now, so install
146
- the new app build rather than upgrading the old one in place.
147
-
148
- ## Pairing code in the browser
149
-
150
- Open dsh Web UI and go to **Settings → dsh-hello**, the section placed directly
151
- after **General** (slot `settings.section`, order `5`). It uses dsh's React
152
- runtime and locale dictionaries, so it follows the Web UI theme and language.
153
-
154
- The page shows:
155
-
156
- - a **lock** switch: while locked, `POST /pair` answers `403 pair-locked` and no
157
- new device can join, while devices that are already paired keep working;
158
- - the current numeric code and expiry;
159
- - a QR payload (`{"v":1,"url":…,"code":…}`);
160
- - the paired-device table;
161
- - buttons to generate a new one-time code, set a **fixed code**, or restore
162
- one-time rotation.
163
-
164
- The lock is persisted next to the fixed code in the credential store, so it
165
- survives a Host restart. There is no standalone HTML page. The panel is
166
- contributed by `client/client.js` through the `settings.section` and
167
- `settings.section.icon` slots and reads three cookie-authenticated endpoints:
168
-
169
- - `GET /admin/data` – current code, QR payload, lock state and device list;
170
- - `POST /admin/pair-code` – rotate, set or clear a fixed code;
171
- - `POST /admin/lock` – `{ "locked": true | false }`.
172
-
173
- Both are protected by the dsh browser session: the plugin calls
174
- `ctx.connection.admit()` on the request headers, with loopback accepted as a
175
- local fallback. Without a valid dsh login the endpoints return 401.
176
-
177
- The browser half is part of the page's boot manifest, so after installing or
178
- updating the plugin, restart `dsh web` and reload the Web UI (a hard refresh,
179
- not just the settings tab). An already-open tab keeps the old module graph and
180
- will not show the section.
181
-
182
- ### Local development without publishing
183
-
184
- Install the checkout once as a link; every rebuild is served from the same path:
185
-
186
- ```sh
187
- dsh plugin --profile web add link:/absolute/path/to/dsh-hello
188
- ```
189
-
190
- Then:
191
-
192
- - **Host + client half**: `pnpm dev:host` (TypeScript types, esbuild bundle, and
193
- the `client/client.js` copy); restart `dsh web`.
194
- - **Before publishing**: `pnpm build` (types + bundle) and `pnpm test`.
195
-
196
- Use a separate home if you do not want to touch your real profile:
197
-
198
- ```sh
199
- DSH_HOME=$HOME/.dsh-dev dsh plugin --profile web add link:/absolute/path/to/dsh-hello
200
- DSH_HOME=$HOME/.dsh-dev dsh web --port 4001
201
- ```
202
-
203
- On Windows PowerShell:
39
+ ## Pair your phone
204
40
 
205
- ```powershell
206
- $env:DSH_HOME="$HOME\.dsh-dev"
207
- dsh plugin --profile web add link:D:/all-in-dsh/apps/dsh-hello
208
- dsh web --port 4001
209
- ```
210
-
211
- Fixed codes are normalized (letters/digits, 4–32 chars, dashes ignored) and
212
- persisted in the dsh credential store under `dsh-hello/pairing`. They remain
213
- valid until changed; use them only on a trusted network. One-time codes rotate
214
- after a successful pairing and expire after `pairingTtlMs`.
215
-
216
- ## Pairing
217
-
218
- - The plugin generates a one-time code, prints it, and optionally prints a QR
219
- payload (`{"v":1,"url":"http://host:port/dsh-hello","code":"..."}`). The
220
- Settings-page QR uses the browser's base URL; the terminal QR uses the bind
221
- origin.
222
- - The app sends the code plus a stable public-key fingerprint
223
- (`devicePublicKey`). The server stores a hash of the bearer token and pins the
224
- fingerprint as the device id.
225
- - Tokens are not bound to `host:port`, so changing IP, port, or tunnel does not
226
- require re-pairing.
227
- - Device records live in the dsh credential store under the owner-scoped key
228
- `dsh-hello/devices` (grant payload). No token is stored in `cordis.yml`.
229
- - `GET /dsh-hello/pair/code` is loopback-only and only exists to make local
230
- setup/curl tests convenient. Remote users read the code from the terminal.
231
-
232
- ## Configuration
233
-
234
- `basePath` defaults to `/dsh-hello`. The app's v1 discovery probes that exact
235
- path, so a deployment that changes it also needs an app-side setting (planned).
236
-
237
- The wire prefix and the persisted credential keys use the same `dsh-hello` name:
238
- the app probes `/dsh-hello/health`, and pairings live under `dsh-hello/*`.
239
-
240
- ```yaml
241
- - id: dsh-hello
242
- name: 'dsh-hello'
243
- config:
244
- basePath: /dsh-hello
245
- allowedHosts: ['dsh.example.com'] # extra Host-header authorities
246
- requireSecure: false # true when the Host itself serves TLS
247
- strictHostCheck: false # true binds requests to a known authority
248
- pairingTtlMs: 300000
249
- pairingCodeLength: 4
250
- pairingMaxAttempts: 8
251
- interactionTarget: browser-only # browser-only | browser-first | phone-first (Default | DSH first | Device first)
252
- approvalWaitTimeoutMs: 120000
253
- questionWaitTimeoutMs: 120000
254
- allowSessionWideGrants: true
255
- enableDebugRoutes: false # true exposes authenticated /debug/* test routes
256
- maxBodyBytes: 65536
257
- rateLimitWindowMs: 60000
258
- rateLimitMax: 240
259
- dshVersionRange: '>=0.2.2-0 <0.3.0'
260
- push:
261
- provider: none # none | fcm | apns | relay
262
- # provider: relay
263
- # relayUrl: https://push.example.com
264
- # relayHostToken: dshr_...
265
- notifyTurnEnd: true
266
- notifyApproval: true
267
- notifyQuestion: true
268
- ```
269
-
270
- `relay` mode sends only the notification payload and host token to your relay;
271
- the relay holds the FCM/APNs credentials. Device tokens are registered with the
272
- relay automatically when the app calls `PUT /devices/me/push`.
273
-
274
- The `notify*` config values are host-wide defaults. Each device can then set its own `approval`, `question` and `turnEnd` subscriptions with `PUT /devices/me/push/subscriptions`; both direct sending and relay mode filter unsubscribed devices. Turn-end pushes are sent only when no app has a live global SSE connection. A connected app handles the event locally instead.
275
-
276
- Push credentials are BYO. Put secrets in the dsh credential store under the
277
- owner-scoped record `dsh-hello/push` when possible; the plugin reads that record
278
- first and falls back to configuration:
279
-
280
- ```json
281
- {
282
- "provider": "fcm",
283
- "fcmServiceAccountJson": "{\"type\":\"service_account\",...}",
284
- "fcmProjectId": "my-project"
285
- }
286
- ```
287
-
288
- The equivalent configuration fallback (useful for tests) is:
289
-
290
- ```yaml
291
- push:
292
- provider: fcm
293
- fcmServiceAccountJson: '{"type":"service_account",...}'
294
- fcmProjectId: my-project
295
- ```
296
-
297
- or APNs:
298
-
299
- ```yaml
300
- push:
301
- provider: apns
302
- apnsKey: |
303
- -----BEGIN PRIVATE KEY-----
304
- ...
305
- apnsKeyId: ABC123DEFG
306
- apnsTeamId: TEAM123456
307
- apnsTopic: com.example.dshapp
308
- apnsEnvironment: production
309
- ```
310
-
311
- The plugin talks directly to Google/Apple; there is no author-operated relay.
312
-
313
- ### Webhook notifications
314
-
315
- Webhooks are independent of the app push provider: they work with
316
- `provider: none`, and they do not need a phone token or GMS. Add one or more
317
- targets under `push.webhooks`:
318
-
319
- ```yaml
320
- push:
321
- webhooks:
322
- - name: wecom
323
- url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...
324
- format: wecom
325
- - name: ntfy
326
- url: https://ntfy.sh/my-dsh-topic
327
- format: ntfy
328
- - name: bark
329
- url: https://api.day.app/<device-key>
330
- format: bark
331
- - name: serverchan
332
- url: https://<uid>.push.ft07.com/send/<sendkey>.send
333
- format: serverchan
334
- - name: hook
335
- url: https://example.com/dsh
336
- format: generic
337
- webhookContent: minimal # minimal | standard
338
- webhookCooldownMs: 60000
339
- ```
340
-
341
- - `wecom` posts a markdown bot message, `serverchan` posts `title`/`desp`,
342
- `ntfy` posts the body with a `Title` header, `bark` accepts either
343
- `https://api.day.app/<key>` or the full `/push` endpoint, and `generic` posts
344
- JSON `{ kind, title, body, data }`.
345
- - `webhookContent: minimal` (default) never puts conversation text in the body;
346
- `standard` sends the same rendered body as the app push.
347
- - `webhookCooldownMs` suppresses repeated sends to one target for the same kind
348
- (turn end, approval, question), so a burst produces one notification.
349
- - The `notify*` switches gate webhooks too; a disabled kind is not sent anywhere.
350
-
351
- ## HTTP API
352
-
353
- All routes are under `basePath` (default `/dsh-hello`). Except for `/health`
354
- and `/pair`, every route requires `Authorization: Bearer <device token>`.
355
- `/admin/*` instead accepts the Host's own browser session (or a loopback
356
- caller), because the settings page talks to it.
357
-
358
- | Method | Path | Purpose |
359
- |---|---|---|
360
- | GET | `/health` | Public capability and version facts (also reports `pairingOpen`) |
361
- | GET/POST | `/pair/code` | Loopback-only current/rotated code + QR payload |
362
- | POST | `/pair` | One-time code → device token (`201`) |
363
- | GET | `/devices/me` | This device's record, including push subscriptions |
364
- | DELETE | `/devices/me` | Unpair this device and close its streams |
365
- | PUT | `/devices/me/push` | Register/replace this device's FCM/APNs token |
366
- | PUT | `/devices/me/push/subscriptions` | Set `approval` / `question` / `turnEnd` |
367
- | DELETE | `/devices/me/push` | Remove this device's push registration |
368
- | POST | `/presence` | Foreground claim (`{ foreground: boolean }`) |
369
- | GET | `/speech` | Host speech provider readiness |
370
- | POST | `/speech/transcribe` | Transcribe a raw WAV body (`audio/wav`; optional `?language=&providerId=`) |
371
- | GET | `/sessions` | Session list with title projections and optional `vitals` |
372
- | POST | `/sessions` | Create/reuse a blank Session |
373
- | PATCH | `/sessions/:id` | Rename (`{ "title": string }`) |
374
- | PUT | `/sessions/:id/pin` | Pin/unpin (`{ "pinned": boolean }`) |
375
- | PUT | `/sessions/:id/archive` | Archive/unarchive (`{ "archived": boolean, "stopActivity"?: boolean }`) |
376
- | PUT | `/sessions/:id/model` | Select provider/model (`{ provider, model, reasoningEffort? }`) |
377
- | GET | `/sessions/:id/model` | Current selection |
378
- | GET | `/sessions/:id/transcript?beforeSeq=&limit=` | Message-aligned history page |
379
- | GET | `/sessions/:id/state` | Running/queue state + projections |
380
- | POST | `/sessions/:id/prompt` | Send text (`queue` or `steer`), `202` |
381
- | POST | `/sessions/:id/cancel` | Stop the current turn, `202` |
382
- | POST | `/sessions/:id/fork` | Child Session at an optional inclusive `atSeq`, `201` |
383
- | POST | `/sessions/:id/uploads` | Raw attachment bytes (`?kind=&name=&mediaType=`), `201` |
384
- | GET | `/sessions/:id/events` | SSE follow stream (snapshot + events) |
385
- | GET | `/sessions/:id/files?path=` | Directory listing inside the Session cwd (300 entries max) |
386
- | GET | `/sessions/:id/file?path=`, `/sessions/:id/raw?path=` | UTF-8 preview / base64 byte chunk |
387
- | GET | /sessions/:id/image?path=, /workspaces/:id/image?path= | Raw image bytes for markdown image tags (device header auth, 24 MiB cap) |
388
- | GET | `/sessions/:id/terminals` | List retained phone terminals |
389
- | POST | `/sessions/:id/terminals` | Open a PTY in the Session working directory |
390
- | GET | `/sessions/:id/terminals/:tid/events` | SSE replay + live terminal output |
391
- | POST | `/sessions/:id/terminals/:tid/input` | Write terminal input |
392
- | POST | `/sessions/:id/terminals/:tid/resize` | Resize the PTY |
393
- | DELETE | `/sessions/:id/terminals/:tid` | Terminate the terminal (`204`) |
394
- | POST | `/sessions/:id/questions/:callId/answer` | Answer a continued question |
395
- | GET | `/workspaces` | Workspace registry (id, path, title) |
396
- | POST | `/workspaces` | Adopt an existing directory (`{ "path", "title"? }`) |
397
- | PUT | `/workspaces/:id` | Rename a workspace (`{ "title": string }`) |
398
- | GET | `/workspaces/:id/files`, `/workspaces/:id/file`, `/workspaces/:id/raw` | Same file surface, keyed by workspace |
399
- | GET | `/schedules` | Automation catalog; `available: false` without a schedule service |
400
- | GET | `/schedules/marks` | Active scheduled-task counts per Session (drawer clock) |
401
- | GET | `/schedules/:id` | One task with target, last delivery and execution flags |
402
- | GET | `/schedules/:id/history?limit=&before=` | Delivery history, newest first |
403
- | POST | `/schedules/:id/run` | Deliver one occurrence now |
404
- | PUT | `/schedules/:id` | Pause/resume (`{ "active": boolean, "expectedUpdatedAt"?: string }`) |
405
- | DELETE | `/schedules/:id` | Delete the task and its saved deliveries |
406
- | GET | `/read-state` | Shared read watermarks (proxied to dsh-tag) |
407
- | PATCH | `/read-state` | Merge this device's watermarks and return the merged map |
408
- | GET | `/events` | Global SSE: approvals, questions, sessions, turn end |
409
- | GET | `/approvals` | Pending approvals |
410
- | POST | `/approvals/:id/decision` | `allow` / `always` / `deny` |
411
- | GET | `/questions` | Pending questions |
412
- | POST | `/questions/:id/answer` | Structured answer batch |
413
- | GET | `/web-url` | This Host's Web UI, launch token attached |
414
- | POST | `/debug/approval` | Debug-only synthetic approval (enableDebugRoutes) |
415
- | POST | `/debug/question` | Debug-only synthetic question (enableDebugRoutes) |
416
-
417
- `GET /sessions` returns rows already ordered by `updatedAt` (newest first).
418
- `updatedAt` is the Host's last-prompt time: renaming, pinning, archiving or
419
- assistant activity does not move it, so the phone can use it for sorting and
420
- unread watermarks without flicker. Titles and `vitals` come from the projections
421
- the Host attaches to each row, so a list costs one Host call rather than one per
422
- Session. The Host's list is not paginated; the phone searches the whole set
423
- locally, which is why this route deliberately returns every row.
424
-
425
- Admin page (browser session or loopback):
41
+ Open the app, then **Connection → Add server → Plugin pairing**, and scan the QR code or type the code.
426
42
 
427
- | Method | Path | Purpose |
428
- |---|---|---|
429
- | GET | `/admin/data` | Code, QR, lock, policy, paired devices |
430
- | POST | `/admin/pair-code` | Rotate / set fixed / auto |
431
- | POST | `/admin/interaction` | `phone-first` / `browser-first` / `browser-only` |
432
- | POST | `/admin/lock` | Lock or unlock pairing |
433
- | PUT | `/admin/devices/:id` | Rename a paired device |
434
- | DELETE | `/admin/devices/:id` | Revoke a paired device |
43
+ - The code is **one-time** by default and expires after five minutes; Settings offers **Permanent** and **Locked** modes.
44
+ - Each device gets its own token and can be renamed or revoked under **Settings → DSH Hello**.
45
+ - Four digits are convenient but low entropy. Keep dsh on a trusted LAN or Tailscale, or raise the code length before exposing it to the internet.
435
46
 
436
- A schedule delivery receipt acknowledges that the target Session persisted the
437
- message, not that the Agent finished or succeeded. Open the target Session for
438
- the actual result. `GET /health` advertises `schedules`, `scheduleActions` and
439
- `scheduleHistory` so older plugins can stay read-only; `workspaceRename` gates
440
- the phone's workspace rename entry, and `readState` tells the app that read
441
- watermarks are shared across paired devices.
442
-
443
- ### Approval policy
444
-
445
- dsh hands an approval or a question to **one** answerer: the first listener that
446
- does not call `next()`. `interactionTarget` decides who that is; the admin page
447
- calls the same three choices Default, DSH first and Device first.
448
-
449
- | Admin label | Value | Who answers |
450
- |---|---|---|
451
- | Default (default) | `browser-only` | Nobody here: the plugin registers no listener, so dsh behaves exactly as if it were not installed. The app shows a read-only prompt and hands the decision to the Web UI. |
452
- | DSH first | `browser-first` | A live web UI always answers. With no browser connected the app holds the request, even in the background. |
453
- | Device first | `phone-first` | A foreground app answers, even when a browser is connected; otherwise dsh's own listeners do. |
454
-
455
- The plugin registers unscoped (`global`) waterfall listeners ahead of the
456
- browser's answerer, so the policy rather than listener order decides. dsh 0.2.2
457
- dispatches both waterfalls with `scopeTarget(agent, agent)`; a listener bound to
458
- the plugin's own scope never sees them.
459
-
460
- With a request claimed, the app is asked over SSE (and push) and its answer
461
- becomes the tool's outcome:
462
-
463
- 1. A claim expires after 45 seconds without a `POST /presence` heartbeat, and
464
- backgrounding the app releases it immediately, so a browser can take over.
465
- 2. Timeout, abort, "no", or the app leaving falls back to `next()`, so dsh's own
466
- fail-closed `unavailable` path still applies.
467
-
468
- `always` is a process-local session grant for one `session + tool` pair. dsh only
469
- defines one-shot `allowed-once`; the plugin does not invent durable grants.
470
-
471
- Approval events try to include a presentation-only `preview` by reading the
472
- matching `tool/call` event (`bash` command, `edit` diff, `web_fetch` URL, etc.).
473
- The lookup is best-effort and bounded so it never blocks the approval. Push data
474
- also carries `hostId` (when the Host origin is known) and the approval's
475
- `sessionId`, so a multi-host app can switch to the right Host before opening the
476
- session.
477
-
478
- ### Questions
479
-
480
- Questions use the same policy: a foreground app with a live SSE connection claims
481
- the question before a connected browser. If the app leaves the foreground, the
482
- claim is released and dsh shows the question in the browser. If the foreground
483
- wait is already gone, the app can still answer the projection's `continued`
484
- questions through the `callId` route, which calls
485
- `ctx.userQuestions.answer(agent, callId, ...)`.
486
-
487
- ### SSE frames
488
-
489
- `GET /sessions/:id/events`:
490
-
491
- ```text
492
- event: ready
493
- data: {"sessionId":"..."}
494
-
495
- event: frame
496
- data: {"type":"snapshot","header":{...},"records":[...],"projections":{...}}
497
-
498
- event: frame
499
- data: {"type":"event","event":{"type":"assistant/message",...}}
500
- ```
501
-
502
- `GET /events`:
503
-
504
- ```text
505
- event: hello
506
- data: {"server":{...},"features":{...},"pendingApprovals":[],"pendingQuestions":[]}
507
-
508
- event: approval
509
- data: {"id":"...","sessionId":"...","toolName":"bash","displayReason":{"en":"..."}}
510
-
511
- event: session
512
- data: {"action":"status","sessionId":"...","running":true}
513
- ```
514
-
515
- ### Debug interaction routes
516
-
517
- `enableDebugRoutes: true` adds authenticated `POST /debug/approval` and
518
- `POST /debug/question` routes. They create the same pending items the real
519
- interaction seams create, so a phone can exercise the approval/question UI
520
- without a model key or a tool call. They are off by default and are not a
521
- replacement for the real waterfall; turn them off after testing.
522
-
523
- ## Security model
524
-
525
- - Route registration is outside dsh's `/api` cookie fence, so the plugin owns
526
- its own fence:
527
- - A `Host` header is required. Unauthenticated routes accept loopback, the
528
- listener's bind address, a configured `allowedHosts` entry, or an authority
529
- recorded at pairing.
530
- - An authenticated device request is accepted across address/tunnel changes:
531
- the bearer token is the boundary, so changing IP, port, or tunnel does not
532
- require re-pairing. Set `strictHostCheck: true` to bind requests to the
533
- authority allowlist instead.
534
- - An attached web `Origin` must match the request authority; cross-site web
535
- requests are refused (`403`).
536
- - Installed browser-extension origins (`chrome-extension://`,
537
- `moz-extension://`, `safari-web-extension://`) are accepted as paired
538
- clients and receive scoped CORS headers plus `OPTIONS` preflight. The
539
- device token or pairing code remains the authentication boundary. Web pages
540
- still receive no CORS headers.
541
- - Native clients do not need CORS; their requests are unchanged.
542
- - The pairing admin page uses dsh's own browser authentication
543
- (`ctx.connection.admit`) and only falls back to loopback; it is not an
544
- unauthenticated code-dump route.
545
- - Bearer tokens are compared in constant time after hashing.
546
- - The phone terminal runs the Host's default shell through
547
- `ctx.subprocess.spawnTerminal`, so it runs as the dsh OS user outside the
548
- agent sandbox — the same permission model as dsh's Web sidebar terminal. It
549
- is reachable only with a device token, input is capped at 64 KiB per request,
550
- at most four terminals are kept per Session, and unattached terminals are
551
- reclaimed after 30 idle minutes. Output is bounded to 200k characters.
552
- - Revoking a device deletes its token and immediately ends every SSE stream
553
- opened with it (global events and per-Session follows), so a lost phone stops
554
- receiving events at revoke time rather than on its next reconnect.
555
- - JSON bodies are bounded (`maxBodyBytes`) and rate-limited per client address.
556
- - Pairing has a TTL, a one-time code, and a per-address failure cap.
557
- - Plain HTTP on a public address is the user's choice and is surfaced by the
558
- app as a strong warning; the app refuses to pair publicly over HTTP until the
559
- user explicitly confirms. Prefer Tailscale, a private address, or TLS.
560
-
561
- ## Verification
562
-
563
- The plugin ships an integration suite that mounts the real router on a local
564
- HTTP server with a fake Host context:
47
+ ## Usage
565
48
 
566
- ```sh
567
- node --import tsx --test tests/*.test.ts
568
- # or, when deps are installed:
569
- pnpm test
570
- ```
49
+ - **Sessions**: the drawer groups sessions by workspace and shows run state, pending approvals and unread weight.
50
+ - **Chat**: read the transcript, queue or steer, switch model, and fork a completed turn.
51
+ - **Approvals and questions**: answer from the phone with command, diff, URL or file-path previews.
52
+ - **Terminal, files and media**: a real shell in the session folder, syntax-highlighted code, document previews, and images grouped by month.
53
+ - **Automations**: inspect scheduled tasks, run one now, pause it, or read the delivery history.
54
+ - **Settings → DSH Hello**: pairing code, lock, approval policy, and the paired-device table.
571
55
 
572
- It covers health, pairing and one-time-code consumption, token auth, session
573
- projection, Host/Origin fences, approval claim/answer, browser-first delegation,
574
- session-wide grants, question answers, terminal create/input/resize/close,
575
- revoke stream teardown, body limits, and JSON-safe device persistence.
56
+ | Sessions | Chat | Terminal |
57
+ |:--:|:--:|:--:|
58
+ | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/sessions.png" width="220" alt="Session drawer"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/chat.png" width="220" alt="Chat with tool calls"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/terminal.png" width="220" alt="Terminal"> |
59
+ | **Files** | **Media** | **Automations** |
60
+ | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/files.png" width="220" alt="Workspace files"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/media.png" width="220" alt="Session media"> | <img src="https://raw.githubusercontent.com/ada87/dsh-hello/main/docs/images/automation.png" width="220" alt="Scheduled task"> |
576
61
 
577
- The app repository also contains a recorded M1 curl walkthrough in
578
- `docs/M1-ACCEPTANCE.md` (https://cnb.cool/ada87/app-dsh-hello).
62
+ ## Requirements
579
63
 
580
- ## Known limitations
64
+ - dsh **0.2.2 – 0.2.x** on the Host, with the `web` profile.
65
+ - The **DSH Hello** app for Android and iOS: <https://dsh.xdnote.com/>. It is a third-party client, not affiliated with DeepSeek.
66
+ - HTTPS or Tailscale for access outside a trusted network. Plain HTTP is a deliberate choice and the app warns before pairing over it.
581
67
 
582
- - dsh is developer preview; the plugin is pinned to `0.2.x`.
583
- - Session title/list reads call the projection service per row (fine for a
584
- personal Host; not optimized for thousands of sessions).
585
- - `always` is process-local and disappears on restart.
586
- - Push is implemented for FCM v1 and APNs token auth, but this repository cannot
587
- exercise Apple/Google credentials.
588
- - The app reads committed `assistant/message` events; assistant token deltas
589
- (`assistant-stream` frames) are not rendered yet.
590
- - The browser escape hatch opens the Web root; dsh does not expose the launch
591
- token to plugins, so an already-authenticated browser session is required.
68
+ ## Documentation
592
69
 
593
- ## License
70
+ - [Reference](https://github.com/ada87/dsh-hello/blob/main/docs/REFERENCE.md): configuration, HTTP API, push, security model and development.
71
+ - [Compatibility](https://github.com/ada87/dsh-hello/blob/main/docs/COMPATIBILITY.md): tested dsh versions and the support window.
72
+ - [Extending](https://github.com/ada87/dsh-hello/blob/main/docs/EXTENDING.md): configure, extend with a companion plugin, or fork.
594
73
 
595
74
  MIT