dsh-client-auto-continue 0.18.0 → 0.20.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +230 -310
  3. package/README.ru.md +382 -0
  4. package/README.zh.md +229 -308
  5. package/docs/auto-continue-workflow.archify.json +3 -3
  6. package/docs/auto-continue-workflow.en.archify.json +3 -3
  7. package/docs/auto-continue-workflow.en.html +1 -1
  8. package/docs/auto-continue-workflow.html +1 -1
  9. package/docs/auto-continue-workflow.ru.svg +530 -0
  10. package/docs/banner-ru-dark.svg +38 -0
  11. package/docs/banner-ru.svg +38 -0
  12. package/docs/demo-ru-static.svg +115 -0
  13. package/docs/demo-ru.svg +147 -0
  14. package/docs/releases/v0.19.0.md +62 -0
  15. package/docs/releases/v0.20.0.md +46 -0
  16. package/docs/social-preview.png +0 -0
  17. package/docs/social-preview.svg +30 -1
  18. package/lib/client.js +297 -99
  19. package/lib/client.js.map +3 -3
  20. package/lib/index.js +496 -43
  21. package/lib/types/client/auto-continue-icon.d.ts +7 -0
  22. package/lib/types/client/bridge.d.ts +2 -0
  23. package/lib/types/client/composer-toggle.d.ts +2 -0
  24. package/lib/types/client/locales.d.ts +5 -0
  25. package/lib/types/client/settings-card.d.ts +1 -0
  26. package/lib/types/host/engine.d.ts +88 -4
  27. package/lib/types/index.d.ts +8 -0
  28. package/lib/types/shared/core.d.ts +21 -1
  29. package/locale/ru.json +6 -0
  30. package/package.json +5 -3
  31. package/scripts/build-docs-assets.mjs +126 -0
  32. package/src/client/auto-continue-icon.tsx +6 -27
  33. package/src/client/bridge.ts +26 -6
  34. package/src/client/composer-toggle.tsx +22 -11
  35. package/src/client/index.ts +5 -1
  36. package/src/client/locales.ts +215 -40
  37. package/src/client/settings-card.tsx +8 -2
  38. package/src/client/settings-notifications.ts +3 -2
  39. package/src/client/styles.ts +17 -19
  40. package/src/host/engine.ts +571 -41
  41. package/src/host/settings-migration.ts +1 -1
  42. package/src/index.ts +23 -1
  43. package/src/shared/core.ts +32 -2
package/README.md CHANGED
@@ -5,384 +5,298 @@
5
5
  </picture>
6
6
  </p>
7
7
 
8
- <h1 align="center">dsh-auto-continue</h1>
9
-
10
8
  <p align="center">
11
- <em>Recover interrupted DSH sessions automatically, with an optional loop to continue after successful turns.</em>
9
+ A <a href="https://github.com/deepseek-ai/deepseek-harness">DeepSeek Harness</a> plugin that resumes interrupted sessions for you, with an optional autonomous loop.
12
10
  </p>
13
11
 
14
12
  <p align="center">
15
13
  <a href="https://www.npmjs.com/package/dsh-client-auto-continue"><img src="https://img.shields.io/npm/v/dsh-client-auto-continue?logo=npm&label=npm" alt="npm version"></a>
16
14
  <a href="https://www.npmjs.com/package/dsh-client-auto-continue"><img src="https://img.shields.io/npm/dm/dsh-client-auto-continue?label=downloads" alt="npm downloads"></a>
17
15
  <a href="https://github.com/HsiangNianian/dsh-auto-continue/stargazers"><img src="https://img.shields.io/github/stars/HsiangNianian/dsh-auto-continue?logo=github&label=Stars" alt="GitHub stars"></a>
18
- <a href="https://github.com/HsiangNianian/dsh-auto-continue/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-65a30d?style=flat" alt="MIT license"></a>
19
- <br>
16
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-65a30d" alt="MIT license"></a>
20
17
  <a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome · DSH plugin"></a>
21
18
  <a href="https://www.dsh.so/artifact/dsh-auto-continue/"><img src="https://www.dsh.so/badge/install/dsh-auto-continue.svg" alt="dsh.so install"></a>
22
- <br>
23
- <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=fff" alt="TypeScript">
24
- <img src="https://img.shields.io/badge/esbuild-FFCF00?style=flat&logo=esbuild&logoColor=000" alt="esbuild">
25
- <img src="https://img.shields.io/badge/GUI--configurable-0ea5e9?style=flat" alt="GUI configurable">
26
19
  </p>
27
20
 
28
21
  <p align="center">
29
- <b>English</b> · <a href="README.zh.md">中文</a> · <a href="CHANGELOG.md">Changelog</a>
22
+ <b>English</b> · <a href="README.zh.md">中文</a> · <a href="README.ru.md">Русский</a> · <a href="CHANGELOG.md">Changelog</a>
30
23
  </p>
31
24
 
32
- ---
25
+ ## Contents
26
+
27
+ - [What it does](#what-it-does)
28
+ - [Install](#install)
29
+ - [Usage](#usage)
30
+ - [Configuration](#configuration)
31
+ - [How it works](#how-it-works)
32
+ - [Troubleshooting](#troubleshooting)
33
+ - [Privacy and permissions](#privacy-and-permissions)
34
+ - [Development](#development)
35
+ - [Links](#links)
36
+ - [License](#license)
33
37
 
34
- ## What It Does
38
+ ## What it does
35
39
 
36
- Automatic recovery for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), in the Web UI and desktop app. When a recoverable failure interrupts a session, the plugin sends your configured continuation prompt through DSH. The engine runs **inside the host process**, so it keeps watching while browser tabs are closed; all tabs share that engine. Recovery is enabled by default. Continuing after successful turns is a separate, **opt-in autonomous loop**.
40
+ When a turn fails with a recoverable error, hits the output limit, ends without visible output, or is cut off by a host restart, the plugin waits a few seconds and sends a continue message for you. It runs inside the DSH host, so it keeps working after you close the browser tab, and all tabs share one engine.
37
41
 
38
42
  <p align="center">
39
43
  <picture>
40
44
  <source media="(prefers-reduced-motion: reduce)" srcset="docs/demo-static.svg">
41
- <img src="docs/demo.svg" alt="Recovery demo: a network interruption, a 3-second wait, an automatic Continue message, and resumed work." width="720">
45
+ <img src="docs/demo.svg" alt="Recovery demo: a network error interrupts the assistant, the plugin waits 3 seconds, sends Continue, and the assistant resumes." width="720">
42
46
  </picture>
43
47
  </p>
44
48
 
45
- **Smart recovery** (all configurable):
46
-
47
- - **Session modes** — switch auto-continue on or off beside the message input, for that conversation only. The mode menu next to the switch shows the current mode and opens Follow default, Off, Recovery only or Autonomous loop. Choices save on the host, survive restarts and sync across tabs; hiding the control does not change them
48
- - **Error classification** — transient failures (network / timeout / 5xx / 429…) are auto-resumed; permanent ones are **skipped** and notified, because retrying them never helps. A failure counts as permanent when its HTTP status is 401/403 or, except for `MALFORMED_RESPONSE`, its code/message matches auth, credential/API-key, balance/quota, unknown-model, or context-length/overflow keywords. Provider-specific exceptions can be opted into with literal custom retryable patterns; turn classification off to resume everything
49
- - **Adaptive backoff** — consecutive failures wait longer each time (cooldown × factor: 20s → 40s → 80s…), capped at the max backoff, instead of hammering a broken upstream
50
- - **Offline hold** — on by default (`pauseWhenOffline`). Before retrying a network failure (`TRANSPORT`, `TIMEOUT`, DNS or connection errors), the host checks it is online: a non-loopback network interface plus one resolvable public name. While offline the retry waits and re-checks every `offlineCheckMs` (15s) without using up **Max consecutive**, then goes through the normal grace period and cooldown once the network is back. Server errors (5xx, 429) are not held. With `HTTP(S)_PROXY` / `ALL_PROXY` set, only interfaces are checked, since local DNS may not work behind such a proxy
51
- - **English / Chinese localization** — the settings card uses DSH's locale service. Built-in resume / guard / loop text and browser notifications use Chinese for `zh` and `zh-*` (case-insensitive), and English for every other or unset locale. Switching languages updates built-in defaults without overwriting custom text
52
- - **Templated continue text** — `continueText` supports `{code}` `{message}` `{status}` `{tool}` `{turn}` `{errorCount}` `{elapsed}` placeholders, so the resume message can carry the failure context ("Continue ({tool} failed: {code})"); a **separate template** fires on `max-tokens` (e.g. "Continue the output without repeating anything already generated")
53
- - **Idempotency guard** — before resuming, the plugin inspects the last tool call: if its result is unconfirmed (the turn died mid-tool, e.g. a `git push` that may have gone through), the resume message tells the model to check state first and not to rerun; if the tool is confirmed done, it says so and asks not to repeat it; a failed tool gets no guard (retrying it is the point). Both guard texts are configurable (`{tool}` / `{result}` placeholders)
54
- - **Silent turn resume** — recover an observed model step or reasoning-only response that completes without visible output. A no-op turn with no model activity is left alone. Text, tool calls, images and extension blocks count as visible, including streamed output. Unobserved turns are not guessed to be silent. Explicit `no-visible-output` markers also recover after restart. Disabling **Resume silent turns** cancels queued silent sends; silent turns never reset the retry cap, even while the option is off.
55
- - **Autonomous loop** — off by default (`resumeCompletedTurns`). When enabled, normally completed turns continue after the grace period, without the recovery cooldown or attempt cap. Reasoning-only turns and explicit `no-visible-output` endings still consume the recovery budget and obey backoff. Global pause, a session pause, manual Stop or changing that session to Recovery only / Off stops the loop. The profile default only affects sessions using Follow default. Its prompt is separate from the loop guard’s prompt (`continueTextLoop`, default `Continue`). `loopMaxIterations` caps the rounds per session (0 = unlimited, the default): once reached, the loop stops and reports it once (log line, plus a notification when notifications are on). Sending a message yourself or turning the loop back on starts the count over
56
- - **Pause** — turning off **Enable auto-continue globally** in **General** and saving stops automatic sends from live events and startup scanning; per-session pauses (e.g. via a notification button) suspend only one session until they expire. **Resume now** requests one send even when both pauses are active. It leaves the pauses in place, so later automatic recovery and autonomous-loop sends remain paused
57
- - **Notification buttons** — notifications carry **Resume now** (send immediately, ignoring cooldown, the consecutive cap and any pause) and **Pause this session 1h** actions
58
- - **Child-session hand-off** — opt-in (`resumeInterruptedChildren`, off by default): when the startup scan finds subagent or team-member sessions that a restart interrupted, the plugin sends each **root session** one message listing those children, once per batch. The child itself is still never resumed — the root decides whether to continue each task or wrap it up. A wake only goes to a parent whose own last turn ended cleanly or was closed by that same restart; a parent still mid-turn is left to the normal recovery path, and one you stopped yourself is never woken
59
- - **Goal re-arm** — opt-in (`resumeGoals`, off by default): after any auto-continue send (or a child-session wake-up), re-arm an `active` goal that the host disarmed on restart, so its continuation rounds can run again. **Resume paused goals** (`resumePausedGoals`) additionally resumes goals you paused by hand, and only takes effect when `resumeGoals` is on as well
60
- - **Loop guard** — watches **running** turns too. Four signals trip the guard, which cancels the turn and restarts it with a configurable loop text ("stop repeating, try another way"): the model repeating the **exact same message** several times (any length — e.g. "Let me test variants of the regex…" ×7), repeated near-duplicate paragraphs **inside one streamed assistant message**, many short messages inside a short time window with no tool call in between (the "Let me read…" spin), or the same tool called repeatedly with the **same arguments and the same results** (a changed argument or result counts as progress). The cancel carries an internal marker so it is never confused with a user stop — the restart only happens for guard-initiated cancels. Thresholds, the time window and the loop text are configurable
61
- - **Stats panel** — the settings card shows today's auto-continue count, recoveries, failures, permanent skips, give-ups and loop breaks, broken down by error code, with a one-click reset
62
- - **Browser notifications** — optional alerts for auto-continue events and successful settings saves. Saving a change to the notification switch confirms its new state, including one final confirmation when turning it off. The browser may ask for permission when you enable it; a denial is explained in the settings page and does not prevent saving.
63
-
64
- It watches the live event streams and reacts to:
65
-
66
- | Event | Meaning |
67
- | --- | --- |
68
- | `turn/end` → `error` | Turn failed (model / network / timeout, …) |
69
- | `turn/end` → `interrupted` | Crash-orphaned turn left behind by a host restart (recovered by the startup scan) |
70
- | `turn/end` → `max-tokens` | Output token ceiling reached |
71
- | `turn/end` → `completed` / `no-visible-output` with no visible output | Observed model activity without visible output, or an explicit silent-ending marker |
72
- | `turn/end` → `completed` | Continue a normal completion only when autonomous loop is enabled |
73
-
74
- What each kind of turn gets, and which switch gates it:
75
-
76
- | Scenario | Auto-continues? | Trigger path | Gated by |
77
- | --- | --- | --- | --- |
78
- | This session's turn failed, hit the output ceiling, or was closed by a host restart | Yes — one followup message in the same session | Live event, or the startup scan after a restart | **Enable auto-continue globally**, the session mode, **Scan on host startup** (`scanOnBoot`) |
79
- | This session's turn ended with no visible output | Yes | Live event, or the startup scan | **Resume silent turns** (`resumeSilentTurns`) |
80
- | This session's turn completed normally | Only in **Autonomous loop** | `turn/end` → `completed` | `resumeCompletedTurns` / the session mode |
81
- | A subagent or team-member session was interrupted by a restart | **No** — the child session is never resumed directly | Startup scan collects the list, then sends **one wake-up message to its root session** | `resumeInterruptedChildren` (off by default) |
82
- | The session carries an `active` goal that the restart disarmed | Not by itself: the resumed turn needs the goal armed again | After any auto-continue send for that session | `resumeGoals` (off by default) |
83
- | The session carries a goal you paused by hand | Only if you opt in | Same path | `resumeGoals` **and** `resumePausedGoals` (both off by default) |
84
-
85
- **Recovery stops for:** manual Stop, policy rejection (`blocked`), paused sessions, subagent sessions and the consecutive-attempt cap. A new turn or manual user message cancels a queued continuation. Live `interrupted` markers are left to the startup recovery scan. Recoverable failures during cooldown are **deferred**, not discarded. If an interrupted session already has queued turns, the continuation runs first and the existing turns retain their order behind it. The loop guard can separately cancel and restart a running turn that is repeating itself.
86
-
87
- Subagent sessions stay under their parent agent's control. The plugin skips them during live recovery and startup scanning, ignores **Resume now** for them, and leaves them out of loop-guard cancellation. Any queued recovery is cancelled when a session is identified as a subagent. The optional **Wake child sessions after restart** (`resumeInterruptedChildren`, off by default) does not change that: the plugin still never resumes a child, it only tells the child's root session which children a restart interrupted, so the root can continue them or wrap them up.
88
-
89
- ---
90
-
91
- ## How It Works
92
-
93
- The host-side engine subscribes to the session event firehose inside the dsh host process — one engine shared by every browser tab. On an interruption it waits a **grace period** (default 3 s) — if the host starts a new turn by itself (`turn/start`), the auto-continue is cancelled — then sends the configured text through the agent registry (`agent.followup`, the same queue the Send button uses). When that queue already contains turns, the engine promotes only its newly inserted continuation before the host wakes the agent; it does not remove or reorder the queued user turns.
94
-
95
- On host boot it also scans the live sessions: a session whose last turn ended with a non-human reason **within the scan window** (default 15 minutes), with no later `turn/start` or user message, gets resumed automatically too (e.g. the host crashed while the browser was closed — the agent-loop resumes the session and the engine picks it up). Persisted sessions the host never reloaded are enumerated from session storage and materialized into the registry first; a journal that stopped mid-turn is completed with an interrupted marker on read, so restart-orphaned turns are recovered the same way.
96
-
97
- Storage scanning runs separately from live-session recovery. Each storage read has a five-second timeout, and the scan yields every 16 observations without waiting for the next polling interval. This lets recently interrupted sessions deep in the storage listing be reached within the startup window. Recovery restores the session's preset and recorded model; stopping the plugin cancels pending storage work.
98
-
99
- Startup recovery isolates failures per session. If history cannot be read or contains invalid events, that session is skipped for the current startup scan and an error is logged; other sessions can still recover, without losing a recovery slot. Invalid entries are not silently removed, since they could hide a manual stop or a newer turn. Valid empty histories and a registry that is still loading remain retryable within the scan window. Reloading a repaired session as a new session object also makes it eligible for scanning again. See [#58](https://github.com/HsiangNianian/dsh-auto-continue/issues/58).
100
-
101
- The browser provides the settings card and the composer switch and mode menu, plus a status bridge that shows notifications (with Resume now / Pause this session 1h buttons, routed back to the host engine) and feeds the card's stats / paused-sessions panels.
102
-
103
- ### Recovery workflow
104
-
105
- The diagram summarizes the automatic recovery path, the loop-guard restart path, and the exit to human intervention. Click it to open the full-size version.
106
-
107
- [![dsh-auto-continue recovery workflow](docs/auto-continue-workflow.en.svg)](docs/auto-continue-workflow.en.svg)
108
-
109
- ## Quick Start
110
-
111
- DSH plugins install into a **profile** (`dsh web` → `web` profile). The commands below install into the web profile; restart `dsh web` after installation. In the desktop app, install through its **Plugins** page instead.
112
-
113
- ### Compatibility
114
-
115
- | DSH runtime | Plugin version | Configuration entry point |
116
- | --- | --- | --- |
117
- | **0.2.2-rc.1** | **0.18.0 verified** | **Plugins → dsh-client-auto-continue** |
118
- | **0.2.1-rc.2** | **0.18.0 verified** | **Plugins → dsh-client-auto-continue** |
119
- | **0.2.1-alpha.1** | **0.18.0 verified** | **Plugins → dsh-client-auto-continue** |
120
- | **0.2.0-rc.1** | **0.12.1 or newer** | **Plugins → dsh-client-auto-continue** |
121
- | **0.1.7-rc.2** | **0.11.9 or newer** | Same Plugins page |
122
- | Older hosts with the legacy settings API | Legacy UI retained | **Settings → Plugins → Plugin configuration** |
123
-
124
- DSH 0.1.0-rc.6 and earlier are unsupported. Automated settings and compatibility checks cover **0.1.7-rc.2**, **0.2.0-rc.1**, **0.2.1-alpha.1** and **0.2.1-rc.2**; startup failure isolation is also checked against **0.2.0-rc.2** and **0.2.1-alpha.1**. Desktop app versions and embedded DSH runtime versions are different; use the runtime version when checking compatibility. For the CLI, run `dsh --version`; see [official DSH releases](https://github.com/deepseek-ai/deepseek-harness/releases) for available versions.
49
+ - **Error recovery.** Network errors, timeouts, 5xx and 429 are retried with a grace period, a cooldown that grows after each failure, and a cap on consecutive attempts. Permanent errors (auth, balance, unknown model, context too long) are skipped.
50
+ - **Offline hold.** Network failures wait for the connection to come back instead of burning retries.
51
+ - **Startup recovery.** After a host restart, sessions interrupted in the last 15 minutes are resumed, including ones you have not reopened.
52
+ - **Per-session modes.** A switch next to the message box sets each conversation to Follow default, Off, Recovery only or Autonomous loop.
53
+ - **Autonomous loop (opt-in).** Keep a session going after normal completions, with an optional round limit.
54
+ - **Safety.** An idempotency guard tells the model whether the last tool call finished, and a loop guard stops turns that repeat themselves.
55
+ - **Visibility.** A settings page with today's statistics, recent recovery attempts and paused sessions, plus optional browser notifications with **Resume now** and **Pause this session 1h** buttons.
125
56
 
126
- **Plugins 0.11.9 and 0.12.0 are rejected by DSH 0.2.0-rc.1’s version check.** Upgrade the plugin to 0.12.1 or newer; its existing configuration-form integration works on this runtime. See [#50](https://github.com/HsiangNianian/dsh-auto-continue/issues/50).
57
+ ## Install
127
58
 
128
- On current DSH, **Settings → Built-in plugins** is a component inventory, not the configuration editor. Use the main **Plugins** page. The screenshots below show plugin **0.14.0** on **DSH 0.2.1-alpha.1**. If you previously installed with a symlink or hand-written loader entry, see [Migrating an older installation](#migrating-an-older-installation).
59
+ DSH plugins install into a profile; `dsh web` uses the `web` profile. In the desktop app, install from its **Plugins** page instead of the CLI.
129
60
 
130
61
  ### From npm (recommended)
131
62
 
132
- Published as [`dsh-client-auto-continue`](https://www.npmjs.com/package/dsh-client-auto-continue):
133
-
134
63
  ```bash
135
64
  dsh plugin --profile web add dsh-client-auto-continue@latest
136
65
  dsh web
137
66
  ```
138
67
 
139
- ### Updating an installed plugin
68
+ Restart DSH and reload the browser after installing. Then open **Plugins → dsh-client-auto-continue** from the main sidebar to check that it is **Running**.
69
+
70
+ To update, let running work finish, stop DSH, run the same command again, then restart DSH and reload the browser. Your settings stay in the profile. The desktop app has its own profile: update it from the app's **Plugins** page.
71
+
72
+ ### Compatibility
73
+
74
+ | DSH runtime | Plugin version | Settings location |
75
+ | --- | --- | --- |
76
+ | 0.2.2-rc.1, 0.2.1-rc.2, 0.2.1-alpha.1 | 0.20.0 verified | **Plugins → dsh-client-auto-continue** |
77
+ | 0.2.0-rc.1 | 0.12.1 or newer | **Plugins → dsh-client-auto-continue** |
78
+ | 0.1.7-rc.2 | 0.11.9 or newer | **Plugins → dsh-client-auto-continue** |
79
+ | Older hosts with the legacy settings API | legacy UI | **Settings → Plugins → Plugin configuration** |
140
80
 
141
- Let active work finish and stop DSH. Run the npm command above again to replace the installed version with `@latest`, then restart DSH and reload the browser. Existing configuration overrides remain in the profile. For a desktop installation, update the plugin from that app’s **Plugins** page and restart the app; updating the CLI’s `web` profile does not update the desktop profile.
81
+ DSH 0.1.0-rc.6 and earlier are not supported. Plugin 0.11.9 and 0.12.0 are rejected by DSH 0.2.0-rc.1's version check ([#50](https://github.com/HsiangNianian/dsh-auto-continue/issues/50)). The desktop app's version is not the DSH runtime version; check the runtime (`dsh --version` for the CLI).
142
82
 
143
- ### Directly from GitHub (no clone needed)
83
+ <details>
84
+ <summary>Install from GitHub (tracks <code>main</code>)</summary>
144
85
 
145
- Installs straight from the repository's default branch — built artifacts are committed, so no local clone or build step:
86
+ Built files are committed, so no clone or build is needed:
146
87
 
147
88
  ```bash
148
89
  dsh plugin --profile web add github:HsiangNianian/dsh-auto-continue
149
90
  dsh web
150
91
  ```
151
92
 
152
- > This tracks the `main` branch rather than released tags — great for trying the latest changes, while the npm method above is the stable choice. Switching between install sources is just re-running `dsh plugin --profile web add <other-spec>`; the profile dependency is replaced in place.
93
+ This follows the `main` branch rather than releases. To switch install sources, run `dsh plugin --profile web add <other-spec>`; the profile dependency is replaced in place.
153
94
 
154
- ### From this repository
95
+ </details>
96
+
97
+ <details>
98
+ <summary>Install from a local checkout</summary>
155
99
 
156
- Use Node.js 22, the version used by CI.
100
+ Use Node.js 22.
157
101
 
158
102
  ```bash
159
103
  git clone https://github.com/HsiangNianian/dsh-auto-continue.git
160
104
  cd dsh-auto-continue
161
105
  npm ci
162
106
  npm run build
163
-
164
- # the package carries its own cordis.patch.yml (dsh.bundle.patch),
165
- # so the plugin row registers itself
166
107
  dsh plugin --profile web add "link:$(pwd)"
167
-
168
108
  dsh web
169
109
  ```
170
110
 
171
- ### Migrating an older installation
111
+ The package ships its own `cordis.patch.yml` (`dsh.bundle.patch`), so the plugin registers itself. After editing the code, run `npm run build`, restart DSH and reload the browser.
112
+
113
+ </details>
114
+
115
+ <details>
116
+ <summary>Migrating an older manual installation</summary>
172
117
 
173
- A manual loader entry can start the engine without registering a bundle in the **Plugins** page. Use the profile's package manager to install the bundle; a symlink and `insert` entry alone are no longer the recommended setup.
118
+ Older setups used a symlink plus a hand-written `insert` row in the loader config. That can start the engine without showing the plugin on the **Plugins** page.
174
119
 
175
- 1. Let active work finish, then stop `dsh web`. Back up `package.json`, `cordis.patch.yml` and `pnpm-lock.yaml` in `~/.dsh/profiles/web/`, plus `~/.dsh/settings.yaml` if it exists. If you set `DSH_HOME`, use that directory instead of `~/.dsh`.
176
- 2. Keep your existing auto-continue values. Remove only the manually added `auto-continue` row **inside an `insert` list** (and the list if it becomes empty). The installed bundle supplies that row. A top-level `- id: auto-continue` with `config:` is a configuration override: **keep it**.
177
- 3. Install with either the npm or GitHub command above. In the profile's `package.json`, `dsh.profile.bundles` should now include `dsh-client-auto-continue`, alongside the existing DSH bundles. If it already does and the plugin appears in **Plugins**, this part is already complete.
178
- 4. On DSH 0.1.7 / 0.2, merge any saved values from the old `settings.yaml` → `auto-continue` section or the removed row's `config` into the profile's `cordis.patch.yml`. For example, a custom cooldown becomes:
120
+ 1. Let running work finish and stop `dsh web`. Back up `package.json`, `cordis.patch.yml` and `pnpm-lock.yaml` in `~/.dsh/profiles/web/`, and `~/.dsh/settings.yaml` if it exists (use `$DSH_HOME` instead of `~/.dsh` if you set it).
121
+ 2. In `cordis.patch.yml`, remove only the hand-written `auto-continue` row inside an `insert` list (and the list if it becomes empty). Keep a top-level `- id: auto-continue` entry with `config:`; that is your settings.
122
+ 3. Install with the npm or GitHub command above. The profile's `package.json` should now list `dsh-client-auto-continue` under `dsh.profile.bundles`.
123
+ 4. If you had settings in the old `settings.yaml` `auto-continue` section, merge them into the profile's `cordis.patch.yml` entry:
179
124
 
180
125
  ```yaml
181
126
  - id: auto-continue
182
127
  config:
183
- cooldownMs: 45000 # example: preserve your own saved value
128
+ cooldownMs: 45000 # your own saved value
184
129
  ```
185
130
 
186
- Merge into an existing override instead of adding another one. Keep unrelated settings intact. DSH 0.1.7 / 0.2 reads this entry config; editing the old `settings.yaml` section will not update the new form.
187
- 5. Start `dsh web` again and reload the browser. Open **Plugins → dsh-client-auto-continue**, select the appropriate settings category, and check that your values are present. Save a change and reload to confirm it persists.
131
+ 5. Start `dsh web`, reload the browser, open **Plugins → dsh-client-auto-continue** and check your values.
188
132
 
189
- The `include:auto-continue` label in **Built-in plugins** is a normal loader prefix. It does not, by itself, indicate a legacy install or a duplicate engine.
133
+ On hosts that offer both profile config and the legacy settings API ([#64](https://github.com/HsiangNianian/dsh-auto-continue/issues/64)), the plugin imports the `auto-continue` section of `$DSH_HOME/settings-legacy.yaml` once per profile. Values already in the profile win, and the old file is left untouched. Recovery waits until the import is done; if the import fails, the host logs an error and recovery stays held until you fix the file or permissions and restart.
190
134
 
191
- For hosts that expose both modern profile config and the legacy settings API ([#64](https://github.com/HsiangNianian/dsh-auto-continue/issues/64)), the plugin uses profile config without registering a second settings namespace. It imports the `auto-continue` section of `$DSH_HOME/settings-legacy.yaml` once per profile, including the saved pause and custom prompts. Existing profile values take precedence. The original file and other plugins' sections stay untouched; completion is recorded separately from editable settings so even a whole-config reset stays reset after restarting.
135
+ The `include:auto-continue` label under **Built-in plugins** is the normal loader prefix, not a sign of a duplicate install.
192
136
 
193
- Recovery and the loop guard wait while this import is pending. If the legacy file cannot be read or validated, or the profile cannot be saved, the host logs an import error and keeps both held. Repair the file or profile permissions and restart the host. Hosts that only support the legacy API continue using their existing settings store.
137
+ </details>
194
138
 
195
- ### Verify & uninstall
139
+ <details>
140
+ <summary>Verify and uninstall</summary>
196
141
 
197
142
  ```bash
143
+ # the composed config should contain exactly one auto-continue entry
198
144
  dsh --profile web --dump-config | grep -A 4 'id: auto-continue'
199
- ```
200
145
 
201
- The composed config should contain one `id: auto-continue` entry. In **Plugins → dsh-client-auto-continue**, check that the component is **Running** and that the **General** category shows editable fields. With verbose logging enabled, engine activity appears in the terminal running DSH.
202
-
203
- ```bash
204
- dsh plugin --profile web remove dsh-client-auto-continue # npm / repo install
205
- # also remove this plugin's config override from cordis.patch.yml, if present
206
- dsh web
146
+ # uninstall
147
+ dsh plugin --profile web remove dsh-client-auto-continue
207
148
  ```
208
149
 
209
- ---
210
-
211
- ## Troubleshooting
150
+ Also remove the `- id: auto-continue` entry from the profile's `cordis.patch.yml`, if there is one, then restart DSH.
212
151
 
213
- - **“Skipping profile bundle” / “incompatible with dsh 0.2.0-rc.1”:** update to plugin 0.12.1 or newer in the profile the app actually uses, then restart it. A version exemption is not needed for this fix.
214
- - **Enabled, but no configuration fields:** open the main **Plugins** page, select the package and open **General**. The Built-in plugins status page has no editable fields.
215
- - **`/api/auto-continue-bridge` returns 404:** check the DSH startup log and composed config to confirm the host component loaded. Refreshing the settings card cannot start a missing host component.
152
+ </details>
216
153
 
217
- ---
154
+ ## Usage
218
155
 
219
- ## Session modes
156
+ Recovery is on by default. Nothing else needs to be set up.
220
157
 
221
- The **Auto-continue** switch beside the input applies only to the current conversation and saves immediately
158
+ ### Session modes
222
159
 
223
- Turning it off selects Off, and turning it back on selects Follow default
224
- Use the mode menu next to the switch to choose a mode:
160
+ The **Auto-continue** switch next to the message box applies to the current conversation only. The menu beside it picks a mode:
225
161
 
226
- | Mode | Behavior |
162
+ | Mode | What happens |
227
163
  | --- | --- |
228
- | Follow default | Use **Default session mode** from the plugin settings, initially Recovery only |
229
- | Off | No automatic followups or loop-guard interruptions in this conversation |
230
- | Recovery only | Recover eligible failures and silent turns; leave normal completions alone |
231
- | Autonomous loop | Also continue normally completed turns, using the loop prompt |
232
-
233
- For example, keep A looping, B recovering failures and C off. Each conversation's choice is saved in the host's profile settings (`sessionModes`), shared across tabs and retained after a host restart. Choosing Follow default explicitly removes that conversation's independent policy, including an inherited override.
234
-
235
- **Enable auto-continue globally** in **General** remains the master control. Turning it off pauses all automatic followups without replacing individual choices; turning it back on restores those choices. Switching a conversation off cancels pending grace, cooldown and loop-guard retries. It leaves any current turn running. Switching Loop to Recovery only cancels pending autonomous followups. Re-enabling does not resurrect cancelled sends.
164
+ | Follow default | Uses **Default session mode** from the settings (Recovery only unless you change it) |
165
+ | Off | No automatic messages and no loop-guard interruptions in this conversation |
166
+ | Recovery only | Recovers errors, output limits, silent turns and restart interruptions; leaves normal completions alone |
167
+ | Autonomous loop | Also continues after every normal completion, using the loop text |
236
168
 
237
- The notification's **Pause this session 1h** still temporarily suspends one conversation. **Resume now** requests a single send even while paused or Off, without changing the stored mode. The global loop-guard setting remains independent of global pause, but a conversation set to Off is excluded from the guard too.
169
+ Turning the switch off selects Off; turning it on again selects Follow default. Choices are saved on the host right away (`sessionModes`), sync across tabs and survive restarts. Switching a conversation to Off cancels anything waiting to be sent but lets a running turn finish.
238
170
 
239
- To hide the controls, open **Plugins → dsh-client-auto-continue → General**, turn off **Show auto-continue switch in the composer**, then **Save**. This only changes visibility (`showComposerToggle`, default `true`). Hosts without the composer slot retain the settings card. A failed save surfaces as a DSH toast instead of inline red text, and a host that stays unavailable for three seconds announces itself once without flashing on a normal load. The switch and mode menu stay disabled while the host bridge or writable settings service is unavailable. When the composer row narrows, the same container query used by the native permission picker collapses the label to its icon and the mode menu to its arrow, keeping the switch and menu on one line.
240
-
241
- For DS-Bot / dsh-pocket layouts that remove the query container, screens up to **640 CSS pixels** use the same icon + switch + arrow layout, with pause/error text below. After updating the plugin, restart DSH and reload the remote page to pick up the new styles.
242
-
243
- ## Configuration
171
+ <p align="center">
172
+ <img src="docs/screenshots/08-composer-toggle.png" alt="Auto-continue switch and mode menu next to the message box" width="560">
173
+ </p>
244
174
 
245
- On **DSH 0.1.7 / 0.2**, open **Plugins** from the main sidebar, choose **dsh-client-auto-continue**, then select a settings category. This is separate from **Settings → Built-in plugins**, which only lists component status. Older DSH versions use **Settings → Plugins → Plugin configuration**.
175
+ In a narrow window the label and menu collapse to an icon. DS-Bot and dsh-pocket get the same compact layout up to 640 CSS pixels. To hide the controls, turn off **Show auto-continue switch in the composer** in **General** and save; this does not change any session's mode.
246
176
 
247
- ![Auto-continue category settings on DSH 0.2](docs/screenshots/01-settings-section.png)
177
+ ### Pausing and manual control
248
178
 
249
- Use **General**, **Retry strategy**, **Startup recovery**, **Continue text**, **Safety**, and **Status and logs** to find controls. Switching categories preserves unsaved changes. **Status and logs** contains today's activity, recent recovery attempts and paused sessions.
179
+ - **Enable auto-continue globally** (in **General**) is the master switch. Turning it off stops all automatic messages without forgetting per-session choices. The loop guard keeps running; turn off **Loop guard** too if you want no interruptions at all.
180
+ - **Pause this session 1h** (notification button) suspends one conversation for an hour.
181
+ - **Resume now** (notification button) sends one continue message immediately. It ignores cooldown, the consecutive limit and any pause, but does not lift the pause.
182
+ - Sending a message yourself, or a new turn starting, cancels any continue message that is still waiting.
250
183
 
251
- **Recent recovery attempts** groups the last 20 recovery prompts across the host by session, showing each session's count in that window, latest cause, time and consecutive count at the last send. It works with browser notifications off. Causes distinguish silent output, output limits, request errors, restart interruptions, loop-guard recovery and manual resume. Normal autonomous continuations are excluded. These are sent prompts, not proof of completion or a model-health score; repeated recovery is a reason to inspect the conversation and consider a handoff. The history contains no message text and resets when the plugin restarts.
184
+ ### Status and logs
252
185
 
253
- The settings card starts with a compact GitHub invitation row, then the category navigation; its fields, switches and default-mode selector use DSH's native settings primitives. The plugin manager above already shows the localized plugin name, version and enabled state. Edits take effect when you click **Save**.
186
+ The **Status and logs** category shows today's counts (continue messages, recoveries, failures, skipped errors, give-ups, loop breaks, by error code, with a reset button), the last 20 recovery attempts grouped by session, and the sessions that are currently paused. These live in host memory and reset when the plugin restarts. With **Verbose logs** on, every decision is logged with an `[auto-continue]` prefix in the DSH log (the terminal running `dsh web` for the CLI).
254
187
 
255
- With **Browser notifications** enabled, each successful save sends one confirmation from the tab where you saved. Turning notifications off sends a final confirmation if browser permission is already granted; later saves stay quiet. Discarded changes, invalid values, and failed saves do not send success notifications. If the browser blocks notifications, the settings page still confirms the save and explains the permission issue.
188
+ ## Configuration
256
189
 
257
- DSH 0.1.7 / 0.2 stores these values in the `auto-continue` entry's config in the active profile patch (`~/.dsh/profiles/web/cordis.patch.yml` for the default web profile). **Save** applies changes live without restarting the engine. Omitted fields use the defaults below.
190
+ Open **Plugins → dsh-client-auto-continue** from the main sidebar and pick a category. (**Settings → Built-in plugins** only lists component status; it is not the editor.) Edits are staged and take effect when you click **Save**; switching categories keeps your drafts, invalid values block the save, and **Reset to default** removes an override.
258
191
 
259
- Startup recovery polls every three seconds for sessions that load late, up to `freshMs` after the engine starts. Each settled session history is inspected once. `scanLimit` limits eligible recoveries per pass, so healthy or permanent-error sessions cannot crowd out interrupted ones. Pausing suspends recovery within the same window; unloading cancels the poller.
192
+ ![Plugin settings, General category](docs/screenshots/01-settings-section.png)
260
193
 
261
- The browser mirrors DSH's active language into the internal `locale` field: `zh` and `zh-*` (case-insensitive) are stored as `zh`; every other or unset locale uses `en`. The host applies the same rule when reading settings, including values such as `ru` written by an older tab, so built-in prompts stay English even if the browser's bounded sync attempts are exhausted. The stored value may remain `ru`; refreshing all tabs allows it to converge to `en`. This requires the updated host plugin to be loaded. Leave localized text fields empty or omit them to follow that language automatically; any non-empty value is treated as your own template and is never rewritten when the language changes:
194
+ Settings are stored in the `auto-continue` entry of the active profile patch, `~/.dsh/profiles/web/cordis.patch.yml` for the default web profile (older hosts: `~/.dsh/settings.yaml`, under `auto-continue:`). You can edit the file directly; omitted keys use their defaults:
262
195
 
263
196
  ```yaml
264
197
  - id: auto-continue
265
198
  config:
266
- locale: 'en' # normally managed by the browser
267
- paused: false
268
- showComposerToggle: true
269
- usePluginSource: false
270
- continueText: ''
271
- resumeSilentTurns: true
272
- resumeCompletedTurns: false
273
- resumeInterruptedChildren: false # Startup recovery: wake the root session about interrupted children
274
- resumeGoals: false # Retry strategy: re-arm a goal the host disarmed on restart
275
- resumePausedGoals: false # Retry strategy: also resume goals paused by hand (needs resumeGoals)
276
- pauseWhenOffline: true # Retry strategy: hold network-error retries while the host is offline
277
- offlineCheckMs: 15000
278
- loopMaxIterations: 0 # Autonomous loop rounds per session; 0 = unlimited
279
- continueTextSilent: ''
280
- continueTextLoop: ''
281
- continueTextInterrupted: ''
282
- continueTextMaxTokens: ''
283
- guardTools: true
284
- guardPendingText: ''
285
- guardDoneText: ''
286
- graceMs: 3000
287
- cooldownMs: 20000
288
- maxConsecutive: 3
289
- scanOnBoot: true
290
- scanLimit: 8
291
- freshMs: 900000
292
- verbose: true
293
- classify: true
294
- retryableErrorPatterns: ''
295
- backoffFactor: 2
296
- backoffMaxMs: 300000
297
- notify: false
298
- loopGuard: true
299
- loopShortChars: 40
300
- loopWindowMs: 30000
301
- loopShortCount: 12
302
- loopRepeatText: 4
303
- loopToolRepeat: 5
304
- loopText: ''
199
+ cooldownMs: 45000
200
+ resumeCompletedTurns: true
201
+ loopMaxIterations: 20
305
202
  ```
306
203
 
307
- <details>
308
- <summary>Configuration files on older DSH versions</summary>
309
-
310
- Older hosts store user settings in `~/.dsh/settings.yaml` under the plugin namespace instead of a profile entry:
204
+ Times are in milliseconds. Text fields left empty use the built-in text in the current language.
311
205
 
312
- ```yaml
313
- auto-continue:
314
- cooldownMs: 45000
315
- ```
206
+ ### General
316
207
 
317
- When migrating from the legacy settings file to DSH 0.1.7 / 0.2, move these values into the profile entry's `config` as described in [Migrating an older installation](#migrating-an-older-installation).
208
+ | Setting | Key | Default | Notes |
209
+ | --- | --- | --- | --- |
210
+ | Enable auto-continue globally | `paused` | `false` | Stored inverted: `paused: true` stops all automatic messages and cancels queued ones |
211
+ | Show auto-continue switch in the composer | `showComposerToggle` | `true` | Only hides or shows the controls |
212
+ | Send continue messages with plugin source | `usePluginSource` | `false` | Off sends as the `user` source; on marks messages as `plugin:dsh-client-auto-continue` |
213
+ | Resume silent turns | `resumeSilentTurns` | `true` | Resume turns that had model activity but no visible output; they still count toward **Max consecutive** |
214
+ | Resume subagent sessions | `resumeSubagentSessions` | `false` | Resume a failed, cut-off or silent subagent, using its main conversation's mode. When DSH already disposed the child, the engine cold-resumes it from its persisted session through the host subagent service; if the host cannot resume it, the failure is handed to the main conversation instead |
215
+ | Default session mode | `resumeCompletedTurns` | `false` | `false` = Recovery only, `true` = Autonomous loop, for sessions on Follow default |
216
+ | Autonomous loop round limit | `loopMaxIterations` | `0` | Loop rounds per session, `0` = no limit. Resets when you send a message or turn the loop back on |
217
+ | Browser notifications | `notify` | `false` | Notifications for sends, skips, give-ups and saved settings. The browser asks for permission the first time |
218
+
219
+ ### Retry strategy
220
+
221
+ | Setting | Key | Default | Notes |
222
+ | --- | --- | --- | --- |
223
+ | Grace period (ms) | `graceMs` | `3000` | Wait before sending; a new turn or your own message cancels it |
224
+ | Cooldown (ms) | `cooldownMs` | `20000` | Minimum gap between recovery attempts in one session. A failure during cooldown waits for the rest of it |
225
+ | Max consecutive | `maxConsecutive` | `3` | Attempts before giving up. Resets when you send a message or a turn ends with visible output. Loop continuations after normal completions do not count |
226
+ | Classify errors | `classify` | `true` | Retry transient errors only; skip permanent ones. Off = retry every error |
227
+ | Custom retryable errors | `retryableErrorPatterns` | `''` | One literal per line, case-insensitive, matched against code, HTTP status and message. Overrides the built-in classifier |
228
+ | Backoff factor | `backoffFactor` | `2` | Cooldown multiplier per consecutive failure (20 s → 40 s → 80 s) |
229
+ | Max backoff (ms) | `backoffMaxMs` | `300000` | Upper bound for the cooldown |
230
+ | Pause while offline | `pauseWhenOffline` | `true` | Hold network-error retries while the host is offline, without using up attempts |
231
+ | Offline re-check interval (ms) | `offlineCheckMs` | `15000` | How often a held retry checks the network. Minimum 1000 |
232
+ | Re-arm goals disarmed by a restart | `resumeGoals` | `false` | After a continue message, re-arm an `active` goal the restart disarmed. This acts on your behalf, hence off |
233
+ | Resume paused goals | `resumePausedGoals` | `false` | Also resume goals you paused by hand. Needs `resumeGoals` |
234
+
235
+ ### Startup recovery
236
+
237
+ | Setting | Key | Default | Notes |
238
+ | --- | --- | --- | --- |
239
+ | Scan on host startup | `scanOnBoot` | `true` | Look for interrupted sessions, open or stored, after the host starts |
240
+ | Wake child sessions after restart | `resumeInterruptedChildren` | `false` | Send each root session one message listing its interrupted subagent or team-member sessions |
241
+ | Scan limit | `scanLimit` | `8` | Recoveries per scan pass, most recently active first |
242
+ | Scan window (ms) | `freshMs` | `900000` | Only interruptions newer than this are recovered; scanning also stops after this long |
318
243
 
319
- </details>
244
+ ### Continue text
320
245
 
321
- **How the card works:**
246
+ | Setting | Key | Used when |
247
+ | --- | --- | --- |
248
+ | Continue text | `continueText` | A turn failed with an error |
249
+ | Continue text (max tokens) | `continueTextMaxTokens` | The output token limit was reached |
250
+ | Continue text (silent turn) | `continueTextSilent` | A turn ended with reasoning only |
251
+ | Continue text (after harness restart) | `continueTextInterrupted` | The startup scan resumes a turn a restart cut off |
252
+ | Continue text (autonomous loop) | `continueTextLoop` | Each autonomous-loop round |
253
+ | Guard text (unconfirmed result) | `guardPendingText` | Appended when the last tool call may not have finished |
254
+ | Guard text (tool succeeded) | `guardDoneText` | Appended when the last tool call succeeded |
255
+ | Loop text | `loopText` | The loop guard restarted a turn |
322
256
 
323
- ![Retry strategy settings on DSH 0.2](docs/screenshots/02-settings-card.png)
257
+ All default to `''`, which means the built-in text. Continue texts accept `{code}`, `{message}`, `{status}`, `{tool}`, `{turn}`, `{errorCount}` and `{elapsed}`; for example `Continue ({tool}: {code})` becomes `Continue (git push: UPSTREAM)`. Guard texts and the loop text accept `{tool}`, and `guardDoneText` also `{result}` (a short excerpt of the tool output).
324
258
 
325
- - Edits are **staged** — nothing reaches the disk until you hit **Save**; leaving the page drops unsaved drafts
326
- - If you edit or reset a field while a save is in progress, the newer draft stays in the card. Click **Save** again after the current save finishes to apply it
327
- - An overridden field shows a **Reset to default** button that removes the override and restores the inherited value (normally the built-in default)
328
- - Boolean fields use native switches and are staged until Save. **Reset to default** removes the override and restores the inherited value. **Enable auto-continue globally** is on when recovery is enabled (`paused: false`)
329
- - Invalid drafts (non-numbers, values below the minimum) block the save and mark their category, even when another category is selected
330
- - In a read-only deployment the card shows the stored values but disables editing while keeping category navigation available
331
- - Changes apply immediately after Save and persist in the active profile config (or `~/.dsh/settings.yaml` on older hosts)
259
+ Built-in texts exist in English, Chinese and Russian. They follow the DSH language: `zh` and `zh-*` use Chinese, `ru` and `ru-*` use Russian, every other locale uses English. Your own non-empty text is never replaced when the language changes.
332
260
 
333
261
  <details>
334
- <summary>Live status and the native Save button</summary>
262
+ <summary>Built-in English texts</summary>
335
263
 
336
- ![Live status and the native save button in the DSH 0.2 configuration card](docs/screenshots/07-card-panels.png)
264
+ | Key | Text |
265
+ | --- | --- |
266
+ | `continueText`, `continueTextMaxTokens`, `continueTextLoop` | `Continue` |
267
+ | `continueTextSilent` | `Continue. Your previous turn ended with internal reasoning only, with no message and no tool call, so nothing reached the user. Always finish a turn with a tool call or a visible answer.` |
268
+ | `continueTextInterrupted` | `Continue. The harness was restarted while your previous turn was still running; tool calls pending at the restart are recorded with unknown outcomes. Resume where you left off, verifying external state before retrying anything that may have side effects.` |
269
+ | `guardPendingText` | `(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)` |
270
+ | `guardDoneText` | `(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)` |
271
+ | `loopText` | `(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)` |
337
272
 
338
273
  </details>
339
274
 
340
- | Field | Default | Description |
341
- | --- | --- | --- |
342
- | Pause auto-continue | `off` | Global pause: no live or scan auto-send fires, queued pending sends are cancelled |
343
- | Show auto-continue switch in the composer | `on` | Show the session switch and mode menu (`showComposerToggle`); hiding them does not change modes |
344
- | Send continue messages with plugin source | `off` | `usePluginSource`: off keeps the legacy `user` source; on uses `plugin:dsh-client-auto-continue` |
345
- | Continue text | `Continue` | Text automatically sent after an interruption |
346
- | Continue text (max tokens) | `Continue` | Text sent when the output token ceiling is reached (same placeholders) |
347
- | Resume silent turns | `on` | Resume a turn that ended normally with reasoning only (no text, no tool call); does not reset the consecutive count |
348
- | Continue text (silent turn) | `Continue. Your previous turn ended with internal reasoning only, ...` | Text sent to resume a silent turn (same placeholders) |
349
- | Default session mode | Recovery only | For sessions following the default; stored as `resumeCompletedTurns` (`false` = Recovery only, `true` = Autonomous loop) |
350
- | Autonomous loop round limit | `0` | Maximum autonomous rounds per session (`loopMaxIterations`); `0` means no limit. Resets when you send a message or turn the loop back on |
351
- | Continue text (autonomous loop) | `Continue` | Text sent on each autonomous-loop resume (same placeholders) |
352
- | Continue text (harness restart) | `Continue. The harness was restarted while your previous turn was still running; …` | Text sent when the boot scan resumes a session that a harness restart closed mid-turn (same placeholders) |
353
- | Idempotency guard | `on` | Inspect the last tool call before resuming and steer the model (see What It Does) |
354
- | Loop guard | `on` | Detect a running turn spinning in place and restart it (see What It Does) |
355
- | Short-sentence max (chars) | `40` | A model message shorter than this counts as a short sentence (spinning signal) |
356
- | Short-sentence window (ms) | `30000` | Consecutive short sentences must land inside this window; normal thinking spread over time is not misjudged |
357
- | Short-sentence threshold | `12` | Consecutive short sentences inside the window, with no tool call in between, trip the loop guard |
358
- | Identical message count | `4` | Consecutive identical messages (any length) trip the loop guard — the strongest spinning signal; the same threshold is also used for repeated near-duplicate streamed paragraphs inside one message |
359
- | Same-tool repeat count | `5` | Consecutive calls of the same tool with identical arguments and results trip the loop guard |
360
- | Loop text | `(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)` | Text sent after the loop guard restarts a turn; `{tool}` placeholder |
361
- | Guard text (unconfirmed result) | `(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)` | Appended when the last tool may have partially executed; `{tool}` placeholder |
362
- | Guard text (tool succeeded) | `(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)` | Appended when the last tool is confirmed done; `{tool}` / `{result}` placeholders |
363
- | Grace period (ms) | `3000` | Wait after an interruption; cancelled if the host recovers on its own |
364
- | Cooldown (ms) | `20000` | Min interval between recovery attempts per session; failures during cooldown wait for the remaining interval, then grace |
365
- | Max consecutive | `3` | Consecutive recovery-attempt cap; resets on user intervention or an observed completion with visible output. Normal autonomous-loop handoffs are exempt |
366
- | Pause while offline | `on` | **Retry strategy** — hold network-error retries while the host is offline, without using up consecutive attempts (`pauseWhenOffline`) |
367
- | Offline re-check interval (ms) | `15000` | **Retry strategy** — how often a held retry checks the network again (`offlineCheckMs`, minimum 1000) |
368
- | Re-arm goals disarmed by a restart | `off` | **Retry strategy** — after an auto-continue send, re-arm an `active` goal the host disarmed on restart, so its continuation rounds run again (`resumeGoals`). `goals.resume` performs no human-authorization check in the service layer, so calling it automatically acts on your behalf — that is why this is off by default |
369
- | Resume paused goals | `off` | **Retry strategy** — also resume goals you paused by hand (`resumePausedGoals`). Pausing is normally a deliberate human decision; takes effect only together with **Re-arm goals disarmed by a restart** |
370
- | Scan on host startup | `on` | Recover interrupted sessions that become available during the startup window |
371
- | Scan limit | `8` | Maximum eligible recoveries per pass, most recently active first |
372
- | Scan window (ms) | `900000` | Maximum interruption age and duration of startup polling |
373
- | Wake child sessions after restart | `off` | **Startup recovery** — when the startup scan finds subagent / team-member sessions that a restart interrupted, send their root session one message listing them (`resumeInterruptedChildren`). Children are never resumed directly; at most 8 child logs are cold-read per pass, independent of **Scan limit** |
374
- | Verbose logs | `on` | `[auto-continue]` engine logs in the DSH terminal |
375
- | Classify errors | `on` | Auto-resume transient failures only; auth / balance / model errors are skipped and notified |
376
- | Custom retryable errors | empty | One case-insensitive literal per line; matching the error code, HTTP status, or message explicitly overrides the built-in classifier |
377
- | Backoff factor | `2` | Cooldown multiplier per consecutive failure (2 = 20s → 40s → 80s…) |
378
- | Max backoff (ms) | `300000` | Cap on the adaptive backoff interval |
379
- | Browser notifications | `off` | Notify about auto-continue events and successful settings saves; confirm switching notifications on or off |
380
-
381
- Pausing auto-continue stops automatic follow-ups, but leaves the loop guard active. Disable **Loop guard** too if you want to stop automatic interruptions. Invisible-only text does not count as repeated visible output, and fresh tool calls reset the repeated-message streak; repeated tool calls with identical arguments and results are still checked independently.
382
-
383
- `MALFORMED_RESPONSE` errors are retryable even when echoed tool arguments contain words such as `auth`, `permission` or `quota`. Explicit HTTP 401/403 failures are still skipped by the built-in classifier, and normal cooldown/backoff and retry limits still apply. This covers live errors and startup scans; the temporary `malformed_response` / `non-whitespace character after json` retry patterns from [#75](https://github.com/HsiangNianian/dsh-auto-continue/issues/75) are no longer needed.
384
-
385
- For a provider-specific error that is safe to resume (confirm first that manually sending "continue" recovers), add a narrow, stable fragment rather than disabling classification globally:
275
+ ### Safety
276
+
277
+ | Setting | Key | Default | Notes |
278
+ | --- | --- | --- | --- |
279
+ | Idempotency guard | `guardTools` | `true` | Before resuming, tell the model whether the last tool call finished so it does not run it twice |
280
+ | Loop guard | `loopGuard` | `true` | Cancel a running turn that repeats itself and restart it with the loop text |
281
+ | Short-sentence max (chars) | `loopShortChars` | `40` | Messages shorter than this count as short sentences |
282
+ | Short-sentence window (ms) | `loopWindowMs` | `30000` | Window for counting short sentences. Minimum 1000 |
283
+ | Short-sentence threshold | `loopShortCount` | `12` | Short sentences in the window, with no tool call, that trip the guard |
284
+ | Identical message count | `loopRepeatText` | `4` | Identical messages in a row (or repeated paragraphs within one streamed message) that trip the guard |
285
+ | Same-tool repeat count | `loopToolRepeat` | `5` | Calls of the same tool with identical arguments and results that trip the guard |
286
+
287
+ ### Status and logs
288
+
289
+ | Setting | Key | Default | Notes |
290
+ | --- | --- | --- | --- |
291
+ | Verbose logs | `verbose` | `true` | Log decisions with the `[auto-continue]` prefix |
292
+
293
+ Two keys are written by the plugin itself: `locale` (mirrors the DSH language, default `en`) and `sessionModes` (per-session choices from the composer, default `{}`). You normally do not edit them.
294
+
295
+ ### Error classification
296
+
297
+ With **Classify errors** on, network errors, timeouts, HTTP 5xx and 429 are retried. HTTP 401 and 403, and codes or messages about auth, credentials or API keys, balance or quota, unknown models, or context length are treated as permanent and skipped (with a notification if enabled). `MALFORMED_RESPONSE` is always retryable unless it carries an explicit 401 or 403.
298
+
299
+ If a provider returns an error that you know is safe to retry (check first that typing "continue" by hand works), add a narrow, stable fragment instead of turning classification off:
386
300
 
387
301
  ```yaml
388
302
  - id: auto-continue
@@ -391,70 +305,76 @@ For a provider-specific error that is safe to resume (confirm first that manuall
391
305
  Upstream rejected the request as invalid
392
306
  ```
393
307
 
394
- Patterns are literal substrings, not regular expressions. Blank lines are ignored; any matching line wins before the built-in permanent-error rules. Cooldown and consecutive-attempt limits still apply.
308
+ Patterns are plain substrings, not regular expressions. Cooldown and **Max consecutive** still apply.
395
309
 
396
- `continueText` (and `continueTextMaxTokens`, `continueTextSilent`, `continueTextLoop`, `continueTextInterrupted`) accept the placeholders `{code}`, `{message}`, `{status}`, `{tool}` (last tool call before the failure), `{turn}`, `{errorCount}` (consecutive failures including this one) and `{elapsed}` (time since the failure, e.g. `1m5s`) — e.g. `Continue ({tool}: {code})` becomes `Continue (git push: UPSTREAM)`. `continueTextInterrupted` is sent when the boot scan resumes a session that a harness restart had closed mid-turn; its default explains the restart and asks the model to verify external state before retrying. The guard texts accept `{tool}` and `{result}` (a truncated excerpt of the last tool output). The host engine currently leaves `{sessionTitle}` empty.
310
+ ## How it works
397
311
 
398
- ---
312
+ [![Auto-continue decision flow](docs/auto-continue-workflow.en.svg)](docs/auto-continue-workflow.en.html)
399
313
 
400
- ## Privacy & permissions
314
+ 1. **Triggers.** The engine listens to session events in the host. A `turn/end` with `error`, `max-tokens`, a silent ending, or `completed` (loop mode only) starts the flow. After a host restart, the startup scan checks open and stored sessions every 3 seconds until the scan window ends. The loop guard watches running turns and cancels one that repeats itself.
315
+ 2. **Session check.** Nothing is sent while auto-continue is paused globally, the session is Off or paused for an hour, or the session is a subagent and **Resume subagent sessions** is off. A subagent follows its main conversation's mode unless it has its own, and never runs the autonomous loop or the loop guard.
316
+ 3. **End reason.** Manual Stop and policy blocks (`blocked`) are left alone, and so are permanent errors. Everything else recoverable goes to recovery. A normal completion only continues in Autonomous loop mode, which skips the cooldown and the consecutive limit but respects `loopMaxIterations`.
317
+ 4. **Retry budget.** Recovery stops at **Max consecutive**. Inside the cooldown, the send is deferred rather than dropped. The cooldown is multiplied by the backoff factor after each failure, up to the maximum.
318
+ 5. **Grace period.** The engine waits `graceMs`. A new turn or a message from you cancels the send.
319
+ 6. **Offline hold.** For network errors, the host checks for a non-loopback network interface and one resolvable public name. While offline it waits and re-checks every `offlineCheckMs`, then goes through grace and cooldown again. With `HTTP(S)_PROXY` or `ALL_PROXY` set, only interfaces are checked.
320
+ 7. **Send.** The engine picks the text for the reason, appends the idempotency-guard note, and sends it with `agent.followup` using the session's preset and model. If user turns are already queued, the continue message is moved ahead of them while their order is kept. With `resumeGoals` on, a goal the restart disarmed is re-armed.
401
321
 
402
- The recovery engine runs inside the DSH host. The browser provides the configuration card, live status and optional notifications:
322
+ **Child sessions.** Outside of **Resume subagent sessions**, subagent and team-member sessions are never resumed directly. With the setting on, a failed child is recovered in two steps: the engine first asks the host to cold-resume the disposed child from its persisted session, delivering the continuation to the child itself, so the main conversation is not woken; when the host cannot resume it (no persistence, no live parent, or a child that is not continuable), the failure is handed to the main conversation as one message, at most once per five minutes. That hand-off stays silent while the main conversation is recovering itself, because any user message cancels its queued continuation. If the main conversation has no live agent at that moment, the hand-off is kept until it is live again. A manual **Resume now** also cold-resumes a disposed child. After a restart, with **Wake child sessions after restart** on, the startup scan collects children a restart interrupted (at most 8 child logs per pass) and sends their root session one message listing them, once per batch. The root decides whether to continue or wrap up. A root still mid-turn is left to normal recovery, and a root you stopped yourself is never woken.
403
323
 
404
- - The engine reads session events and history through DSH's services. The browser talks to that host; the plugin adds no third-party service or credential store
405
- - Recovery sends your configured text through `agent.followup`. The loop guard can cancel a looping turn through `agent.cancel` before sending its recovery prompt. Resumed agents continue with the session's existing tools and permissions
406
- - Saving configuration uses DSH's settings API: the active profile patch on DSH 0.1.7 / 0.2, or `~/.dsh/settings.yaml` on older hosts
407
- - Retry counters, cooldown timestamps, timed notification pauses and stats stay in host process memory and reset when the engine restarts. Session mode choices (`sessionModes`) and global `paused` are saved with your other configuration
408
- - Browser notifications are opt-in (`notify` setting). Enabling and saving can request browser permission; denied permission is not requested again. Turning the option off never requests permission.
324
+ **Unreadable sessions.** If a session's history cannot be read during the startup scan, that session is skipped and an error is logged; other sessions still recover ([#58](https://github.com/HsiangNianian/dsh-auto-continue/issues/58)). Repair it and restart DSH within the scan window to try again.
325
+
326
+ ## Troubleshooting
409
327
 
410
- ---
328
+ | Symptom | What to check |
329
+ | --- | --- |
330
+ | "Skipping profile bundle" or "incompatible with dsh 0.2.0-rc.1" | Update to plugin 0.12.1 or newer in the profile the app actually uses, then restart |
331
+ | Plugin enabled, but no settings fields | Open the main **Plugins** page, not **Settings → Built-in plugins**, and select **General** |
332
+ | `/api/auto-continue-bridge` returns 404 | The host component did not load. Check the DSH startup log and `--dump-config`, then reload the page |
333
+ | An error was not resumed | Check the global switch and the session mode. Look for `[auto-continue]` log lines: they say whether the error was classified as permanent, the session hit **Max consecutive**, or the retry is held offline |
334
+ | Sessions not resumed after a restart | **Scan on host startup** must be on, and the interruption must be newer than the scan window (15 minutes by default) |
335
+ | Settings are ignored after migrating | Make sure there is one top-level `- id: auto-continue` entry in `cordis.patch.yml` and no leftover `insert` row; see the migration notes under [Install](#install) |
336
+ | Compact composer layout missing on a phone | Restart DSH and reload the remote page after updating the plugin |
337
+
338
+ ## Privacy and permissions
339
+
340
+ - The engine runs in the DSH host and reads session events and history through DSH services. No third-party service is contacted and no credentials are stored.
341
+ - Continue messages go through `agent.followup`; the loop guard may call `agent.cancel` first. A resumed agent keeps the session's existing tools and permissions.
342
+ - The offline check reads the local network interfaces and does a DNS lookup of `api.deepseek.com`, `www.baidu.com` and `one.one.one.one`. It opens no connection and sends no request.
343
+ - Settings are saved through DSH's settings API to the active profile (or `~/.dsh/settings.yaml` on older hosts). Retry counters, cooldowns, one-hour pauses and statistics are kept in memory only.
344
+ - Browser notifications are opt-in. Permission is requested only when you turn them on and save.
411
345
 
412
346
  ## Development
413
347
 
414
- Use Node.js 22. Install the pinned runtime fixtures to reproduce CI locally:
348
+ Use Node.js 22.
415
349
 
416
350
  ```bash
417
351
  npm ci
418
- npm ci --prefix tests/fixtures/dsh-0.1.7
419
- npm ci --prefix tests/fixtures/dsh-0.2.0
420
- npm ci --prefix tests/fixtures/dsh-0.2.0-rc.2
421
- npm ci --prefix tests/fixtures/dsh-0.2.1
422
- npm ci --prefix tests/fixtures/dsh-0.2.1-rc.2
423
352
  npm run typecheck
424
353
  npm run build
425
354
  npm test
426
- npm run test:runtime
427
355
  ```
428
356
 
429
- `npm test` covers recovery, autonomous-loop limits and toggles, child-session exclusion and the post-restart hand-off, manual resume during pauses, startup scanning and malformed-session isolation, queue ordering, statistics, localization, settings UI lifecycle and edits made during pending saves. `npm run test:runtime` uses published DSH **0.1.7-rc.2**, **0.2.0-rc.1** and **0.2.1-alpha.1** Settings, Loader and HTTP services. It also runs the actual 0.2 profile compatibility gate and checks client activation when one settings provider is absent. Startup recovery tests inject session read failures into real **0.2.0-rc.2** and **0.2.1-alpha.1** Session/Cordis/HTTP components and verify that healthy sessions still recover. These controlled faults do not imply that normal DSH loading produces malformed logs. The runtime harness controls agent events; it does not send requests to a model provider.
430
-
431
- The rc.2 check also loads the published client settings service and verifies card save/reset, per-session composer choices, concurrent saves, disk reloads, locale synchronization and a fresh Host read, using snapshots without the removed `mode` field.
432
-
433
- The rc.2 restart test uses real agent, query, and JSONL persistence services: it kills a host mid-turn, starts a fresh host without opening the conversation, and checks one recovery with the recorded model and matching prompt variables. The model adapter is deterministic; no external model requests are made.
434
-
435
- After editing a linked checkout, run `npm run build` to write the updated `lib/` files, then restart DSH and refresh the browser. Hosts with client HMR enabled can reload a rebuilt client bundle automatically.
436
-
437
- CI typechecks, rebuilds, runs both test suites, verifies committed `lib/` artifacts and runs [dsh-plugin-check](https://github.com/omdsh-dev/dsh-plugin-check). The same checks gate releases. See [screenshot capture notes](docs/screenshots/README.md) when updating the UI documentation.
357
+ `npm run test:runtime` runs the settings, startup-recovery and restart tests against published DSH packages. Install the pinned fixtures first:
438
358
 
439
- ---
440
-
441
- ## Activity
359
+ ```bash
360
+ for v in 0.1.7 0.2.0 0.2.0-rc.2 0.2.1 0.2.1-rc.2; do npm ci --prefix "tests/fixtures/dsh-$v"; done
361
+ npm run test:runtime
362
+ ```
442
363
 
443
- [![HsiangNianian/dsh-auto-continue GitStock K-Line Chart](https://gitstock.org/HsiangNianian/dsh-auto-continue/stock.svg)](https://gitstock.org/HsiangNianian/dsh-auto-continue)
364
+ The runtime tests drive real DSH services with a deterministic model adapter; they make no requests to a model provider. CI also checks that the committed `lib/` matches a fresh build and runs [dsh-plugin-check](https://github.com/omdsh-dev/dsh-plugin-check).
444
365
 
445
- ---
366
+ The banners and social preview are generated by `npm run docs:assets`; the workflow map is an [Archify](https://github.com/tt-a1i/archify) export (`docs/auto-continue-workflow.*`, sources in `*.archify.json`) (render the PNG with `rsvg-convert -w 1280 -h 640 docs/social-preview.svg -o docs/social-preview.png`). See [docs/screenshots/README.md](docs/screenshots/README.md) for how the screenshots are captured.
446
367
 
447
368
  ## Links
448
369
 
449
- - **Repository**: [github.com/HsiangNianian/dsh-auto-continue](https://github.com/HsiangNianian/dsh-auto-continue)
450
- - **LINUX DO**: [linux.do](https://linux.do)
451
- - **DeepSeek Harness**: [github.com/deepseek-ai/deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)
452
- - **dsh-plugin-check**: [github.com/omdsh-dev/dsh-plugin-check](https://github.com/omdsh-dev/dsh-plugin-check) — health-check your own DSH plugin repos
370
+ - Repository: [github.com/HsiangNianian/dsh-auto-continue](https://github.com/HsiangNianian/dsh-auto-continue)
371
+ - npm: [dsh-client-auto-continue](https://www.npmjs.com/package/dsh-client-auto-continue)
372
+ - DeepSeek Harness: [github.com/deepseek-ai/deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)
373
+ - dsh-plugin-check: [github.com/omdsh-dev/dsh-plugin-check](https://github.com/omdsh-dev/dsh-plugin-check)
374
+ - LINUX DO: [linux.do](https://linux.do)
453
375
 
454
- ---
376
+ [![GitStock chart for HsiangNianian/dsh-auto-continue](https://gitstock.org/HsiangNianian/dsh-auto-continue/stock.svg)](https://gitstock.org/HsiangNianian/dsh-auto-continue)
455
377
 
456
378
  ## License
457
379
 
458
- [![MIT](https://img.shields.io/badge/license-MIT-65a30d)](LICENSE)
459
-
460
- MIT © Hsiang Nianian
380
+ [MIT](LICENSE) © Hsiang Nianian