dsh-unlimited-retry 2.4.0 → 2.5.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.
package/README.md CHANGED
@@ -18,6 +18,10 @@ delay ceiling — until it succeeds or you stop it.
18
18
  Standard DSH bundle plugin, one-command install. **The same package supports both
19
19
  the DSH Web UI and the official desktop client (Electron).**
20
20
 
21
+ ![The Settings panel: live retry counters, the effective retry ladder, and the policy editor](assets/screenshot-1.png)
22
+
23
+ <sub>Figures above are sample data. The layout, copy, and controls are the plugin's own.</sub>
24
+
21
25
  ## Where to install it
22
26
 
23
27
  This repository maintains one product line (`main`). The same package supports
@@ -25,36 +29,35 @@ both surfaces.
25
29
 
26
30
  | Surface | Install |
27
31
  |---|---|
28
- | **DSH Web UI** | Terminal: `dsh plugin --profile web add dsh-unlimited-retry` |
29
- | **Official desktop client (Electron)** | **No terminal** — ask the desktop session to install it with the built-in `plugin_manager` (below) |
32
+ | **DSH Web UI** | Open the **Plugins** page, click **Add plugin**, and enter `dsh-unlimited-retry` — or run `dsh plugin --profile web add dsh-unlimited-retry` in a terminal |
33
+ | **Official desktop client (Electron)** | Open the **Plugins** page, click **Add plugin**, and enter `dsh-unlimited-retry` |
30
34
 
31
- ### Desktop client: do not use a terminal command
35
+ ### Installing from the UI
32
36
 
33
- The desktop reads the **`desktop` profile**, and the CLI refuses to touch it by
34
- design:
37
+ Both surfaces ship the plugin manager, so the shortest path is the same:
35
38
 
36
- ```
37
- error: profile "desktop" is managed exclusively by the Electron application
38
- ```
39
+ 1. Open **Plugins** in the app.
40
+ 2. Click **Add plugin**.
41
+ 3. Enter `dsh-unlimited-retry` (or `dsh-unlimited-retry@<version>` to pin one).
42
+ 4. Confirm, then reopen the app or reload the page if the Settings page does not
43
+ appear immediately.
39
44
 
40
- A `--profile web` install therefore lands in the `web` profile, and the desktop
41
- window reads none of it — the symptom is a Settings page that simply is not there,
42
- with nothing in the console.
45
+ The dialog accepts npm packages, Git repositories, and local directories, so the
46
+ same box also takes `github:xalor888/dsh-unlimited-retry` or a `link:` path.
43
47
 
44
- **Instead**, say this in a desktop-client session:
48
+ ### Why the desktop must not use `dsh plugin --profile desktop`
45
49
 
46
- > Please install `dsh-unlimited-retry` using this host's built-in
47
- > `plugin_manager`. Check the current profile and whether a package of that name
48
- > is already installed first; if it is, report its source and version. Then tell
49
- > me the result and whether a restart is needed.
50
+ The desktop client reads a profile named `desktop`, which is reserved for the
51
+ Electron application — the CLI refuses to touch it on purpose:
50
52
 
51
- `plugin_manager` is scoped to the **current profile** (the desktop's is
52
- `desktop`) and uses the host's own package manager to install and register the
53
- plugin. No terminal, no cookie construction, no hand-editing a host-managed
54
- profile file. Pin a version by asking for `dsh-unlimited-retry@<version>`.
53
+ ```
54
+ error: profile "desktop" is managed exclusively by the Electron application
55
+ ```
55
56
 
56
- If Settings does not show the page after a first install, **fully quit the client
57
- (including the tray) and reopen it** rather than stacking a second install.
57
+ A `--profile web` install therefore lands in the `web` profile, while the desktop
58
+ window reads `desktop`, so nothing appears. The UI path above is scoped to
59
+ whichever profile the running app actually owns, which is why it is the one to
60
+ use.
58
61
 
59
62
  > Why the desktop works: the desktop profile *is* the Web template (`base` +
60
63
  > `web-app`), and Electron loads the local Web UI URL. The `dsh.client` panel is
@@ -136,6 +139,8 @@ record with no matching `llm/retry-started`, which is exactly what happened.
136
139
 
137
140
  ### Settings panel
138
141
 
142
+ ![The top of the panel: live status, counters, and the ladder showing where this plugin sits](assets/screenshot-2.png)
143
+
139
144
  - 📊 **Live status**: a pill shows whether the host half answers
140
145
  - 🔢 **Counters**: total retries, waits in flight, sessions retrying, last retry, uptime
141
146
  - 🪜 **Effective ladder**: what happens on each attempt, with an honest `No limit` instead of a fabricated cap
@@ -214,8 +219,8 @@ no jitter at all.
214
219
  dsh plugin --profile web add dsh-unlimited-retry
215
220
  ```
216
221
 
217
- For the official desktop client, use the built-in `plugin_manager` from a desktop
218
- session instead — see [Where to install it](#where-to-install-it). The CLI refuses
222
+ For the official desktop client, use the in-app **Plugins → Add plugin** dialog
223
+ instead — see [Where to install it](#where-to-install-it). The CLI refuses
219
224
  `--profile desktop` by design.
220
225
 
221
226
  ### From this repository
@@ -342,9 +347,15 @@ curl -s http://127.0.0.1:3080/unlimited-retry/stats | head -c 400
342
347
  | Requirement | Value |
343
348
  |---|---|
344
349
  | Node.js | **>= 20** |
345
- | DSH | **>= 0.2.0-0 < 0.3.0-0** (`engines.dsh`, enforced by the host's compatibility preflight) |
350
+ | DSH | **>= 0.2.0-0 < 0.3.0-0** (`engines.dsh`, enforced by the host's compatibility preflight). Verified against 0.2.1-rc.3, 0.2.1-rc.5, 0.2.2-alpha.2 and 0.2.2-rc.1 |
346
351
  | Ships `dsh-agent-loop` and `dsh-llm-retry` | Yes — the retry listener hangs off that event |
347
352
 
353
+ The session-projection reader adapts to both registration shapes the Host has
354
+ shipped: the disposer returned before 0.2.2, and the callable thenable returned
355
+ from 0.2.2 on, whose `typeof` is `"function"` while it still carries `then`.
356
+ The handle is preferred where it exists, so no deprecated read is performed on a
357
+ runtime that deprecated it.
358
+
348
359
  The `-0` lower bound in `engines.dsh` is deliberate: the host matches with
349
360
  `includePrerelease: true`, and only a boundary carrying a prerelease tag admits a
350
361
  prerelease runtime such as `0.2.1-rc.3`. A plain `>=0.2.0` would silently exclude
@@ -353,6 +364,20 @@ every `-rc` build.
353
364
  - A 1.x `config` still mounts: `retryAllCodes` is ignored and `terminalCodes` is read as `excludeCodes`, each with a one-line warning naming the replacement.
354
365
  - The Web panel additionally needs `configEditor` and the `settings.section` slot. Without them the policy still applies; the page is simply absent or read-only.
355
366
 
367
+ ## Changelog
368
+
369
+ ### 2.5.0
370
+
371
+ - The ladder's last row printed the plugin's **first** delay beside a label that
372
+ named the ceiling, so it read "every delay capped at 1.0 min — 1.0 s". It now
373
+ shows the ceiling itself.
374
+ - "Sessions retrying" dropped to zero while a wait was still running when two
375
+ failures for one session were waiting at once. The count is now per session
376
+ rather than one flag per session.
377
+ - Install instructions: both surfaces have the plugin manager, so the desktop
378
+ client installs from **Plugins → Add plugin** like any other. The earlier text
379
+ sent you through a chat session for no reason.
380
+
356
381
  ## Releasing
357
382
 
358
383
  Publishing is tag-driven; nothing publishes from a branch.
package/README.zh.md CHANGED
@@ -14,32 +14,40 @@ DeepSeek Harness(DSH)的**无限模型请求重试**插件,附带一个实
14
14
 
15
15
  标准 DSH bundle 插件,`dsh plugin` 一键安装。**同一个包同时支持 DSH Web 与官方桌面客户端**(Electron)。
16
16
 
17
+ ![设置面板:实时重试计数、实际重试阶梯、策略编辑器](assets/screenshot-1.png)
18
+
19
+ <sub>图中数字为样例数据;布局、文案与控件均为插件本身。</sub>
20
+
17
21
  ## 装在哪里
18
22
 
19
23
  本仓库只维护一条产品线(`main`),同一个包同时支持两种界面。
20
24
 
21
25
  | 你要装在哪 | 安装方式 |
22
26
  |---|---|
23
- | **DSH Web 界面** | 终端:`dsh plugin --profile web add dsh-unlimited-retry` |
24
- | **官方桌面客户端(Electron)** | **不用终端** —— 在桌面端会话里让 DSH 用内置的 `plugin_manager` 安装(见下) |
27
+ | **DSH Web 界面** | 打开**插件**页面 → 点「**添加插件**」→ 填 `dsh-unlimited-retry`;或在终端执行 `dsh plugin --profile web add dsh-unlimited-retry` |
28
+ | **官方桌面客户端(Electron)** | 打开**插件**页面 → 点「**添加插件**」→ 填 `dsh-unlimited-retry` |
25
29
 
26
- ### 官方桌面端:不要用终端命令
30
+ ### 从界面安装
27
31
 
28
- 桌面端读的是 **`desktop` profile**,而命令行**按设计拒绝**碰它:
32
+ 两种界面都自带插件管理器,所以最快的路径是一样的:
29
33
 
30
- ```
31
- error: profile "desktop" is managed exclusively by the Electron application
32
- ```
34
+ 1. 在应用里打开**插件**页面。
35
+ 2. 点「**添加插件**」。
36
+ 3. 填 `dsh-unlimited-retry`(要固定版本就写 `dsh-unlimited-retry@<版本>`)。
37
+ 4. 确认;如果设置里没立刻出现这一页,重开应用或刷新页面。
33
38
 
34
- 所以 `--profile web` 的命令装完,插件落在 `web` profile 里,桌面窗口一个字也读不到 —— 表现就是「设置里根本没有这一页,控制台也不报错」。
39
+ 那个输入框接受 npm 包、Git 仓库和本地目录,所以也能填
40
+ `github:xalor888/dsh-unlimited-retry` 或 `link:` 路径。
35
41
 
36
- **正确做法**:在桌面客户端的会话里直接说:
42
+ ### 桌面端为什么不能用 `dsh plugin --profile desktop`
37
43
 
38
- > 请使用当前宿主内置的 `plugin_manager` 安装 `dsh-unlimited-retry`。先核对当前 profile 和是否已有同名插件;已有安装时先报告来源与版本。完成后告诉我安装结果及是否需要重启。
44
+ 桌面端读的是名为 `desktop` 的 profile,它保留给 Electron 应用本身,命令行会**按设计拒绝**:
39
45
 
40
- `plugin_manager` 的作用域就是**当前 profile**(桌面端为 `desktop`),由宿主用它自带的包管理器完成安装与挂载登记 —— 不需要终端、不需要构造 cookie、不需要改写宿主管理的 profile 文件。要固定版本就写 `dsh-unlimited-retry@<版本>`。
46
+ ```
47
+ error: profile "desktop" is managed exclusively by the Electron application
48
+ ```
41
49
 
42
- 首次安装后如果设置里没出现,**完全退出客户端(含系统托盘)再重开**,而不是去堆叠另一份安装。
50
+ 而 `--profile web` 的命令会把插件装进 `web` profile,桌面窗口读的是 `desktop`,自然一个字也看不到。上面那条界面路径的作用域正好是「当前应用真正拥有的那个 profile」,这也是它才是正确做法。
43
51
 
44
52
  > 为什么桌面端也能用:桌面端的 profile 就是 Web 模板(`base` + `web-app`),Electron 加载的是本地 Web UI 的 URL,因此 `dsh.client` 声明的面板在桌面端同样被 `client-modules` 装载。不需要另做一套客户端代码。
45
53
  >
@@ -101,6 +109,8 @@ DSH 自带的 `@deepseek-ai/dsh-llm-retry` 只负责**执行**重试,真正的
101
109
 
102
110
  ### 设置面板
103
111
 
112
+ ![面板顶部:实时状态、计数器,以及标明本插件位置的重试阶梯](assets/screenshot-2.png)
113
+
104
114
  - 📊 **实时状态**:小标签显示宿主端是否有响应
105
115
  - 🔢 **计数器**:累计重试、等待中的请求、正在重试的会话、最近一次重试、运行时长
106
116
  - 🪜 **实际重试顺序**:每次尝试会发生什么;不设上限时如实显示 `No limit`
@@ -160,7 +170,7 @@ markerFile: null
160
170
  dsh plugin --profile web add dsh-unlimited-retry
161
171
  ```
162
172
 
163
- 官方桌面客户端请在桌面端会话里用内置的 `plugin_manager` 安装 ——
173
+ 官方桌面客户端请用应用内的「**插件 → 添加插件**」——
164
174
  见 [装在哪里](#装在哪里)。命令行按设计拒绝 `--profile desktop`。
165
175
 
166
176
  ### 从本仓库
@@ -262,14 +272,26 @@ curl -s http://127.0.0.1:3080/unlimited-retry/stats | head -c 400
262
272
  | 依赖 | 要求 |
263
273
  |---|---|
264
274
  | Node.js | **>= 20** |
265
- | DSH | **>= 0.2.0-0 < 0.3.0-0**(`package.json` 的 `engines.dsh`,由宿主的兼容性预检强制执行) |
275
+ | DSH | **>= 0.2.0-0 < 0.3.0-0**(`package.json` 的 `engines.dsh`,由宿主的兼容性预检强制执行)。已在 0.2.1-rc.3、0.2.1-rc.5、0.2.2-alpha.2、0.2.2-rc.1 上验证 |
266
276
  | 带 `dsh-agent-loop` 与 `dsh-llm-retry` | 是(重试监听器挂在那条事件上) |
267
277
 
278
+ 会话投影读取对宿主先后提供过的两种注册形态都做了适配:0.2.2 之前 `register`
279
+ 返回 disposer,0.2.2 起返回**可调用 thenable**(`typeof` 是 `"function"`,但仍带 `then`)。
280
+ 有句柄时优先用句柄,因此在已弃用旧读取的运行时上不会走那条路。
281
+
268
282
  `engines.dsh` 的 `-0` 下界是刻意的:宿主的预检用 `includePrerelease: true` 匹配,而只有带预发布标签的边界才能放行 `0.2.1-rc.3` 这样的预发布运行时。写成 `>=0.2.0` 会把所有 `-rc` 版本静默排除。
269
283
  - 有 `AbortSignal.any` 就用它,没有则用 controller 方案等价实现。
270
284
  - 1.x 的 `config` 仍可挂载:`retryAllCodes` 被忽略(除非显式排除,否则每个码都会重试),`terminalCodes` 按 `excludeCodes` 读取,两者各打一条替代提示。
271
285
  - Web 面板另需 `configEditor` 与 `settings.section` 槽位;缺这些时策略照常生效,页面只是不存在或只读。
272
286
 
287
+ ## 更新记录
288
+
289
+ ### 2.5.0
290
+
291
+ - 重试阶梯最后一行把插件的**首个**延迟印在一个标明上限的标签旁边,读起来是「此后每一次延迟均封顶 1.0 分钟 —— 1.0 秒」。现在显示上限本身。
292
+ - 同一会话有两个失败同时在等待时,较短的那个结束后「正在重试的会话」会掉到 0。改为按会话计数,而不是每会话一个布尔标记。
293
+ - 安装说明:两种界面都自带插件管理器,桌面端就是**插件 → 添加插件**。早先那版让你绕道一个对话会话来装,纯属多余。
294
+
273
295
  ## 发布流程
274
296
 
275
297
  发布由 tag 驱动,任何分支都不会触发发布。
package/client.js CHANGED
@@ -59,7 +59,7 @@ window.__ModuleLoader__.load({
59
59
  ladderHint: "Earlier layers get the first word. This plugin only handles what nobody recovered.",
60
60
  ladderProvider: "Provider retry policy",
61
61
  ladderPlugin: "This plugin",
62
- ladderBeyond: "and beyond, every delay capped at {max}",
62
+ ladderBeyond: "and beyond, every delay capped",
63
63
  ladderCap: "up to attempt {n}",
64
64
  ladderTerminal: "Terminal",
65
65
  ladderTerminalHint: "Excluded codes stop here and fail the turn immediately.",
@@ -146,7 +146,7 @@ window.__ModuleLoader__.load({
146
146
  ladderHint: "越靠前的恢复层越先决定,本插件只处理没人接手的失败。",
147
147
  ladderProvider: "Provider 重试策略",
148
148
  ladderPlugin: "本插件",
149
- ladderBeyond: "此后每一次延迟都封顶 {max}",
149
+ ladderBeyond: "此后每一次延迟均封顶",
150
150
  ladderCap: "至第 {n} 次",
151
151
  ladderTerminal: "终止",
152
152
  ladderTerminalHint: "被排除的错误码直接结束该轮,不再重试。",
@@ -497,40 +497,62 @@ window.__ModuleLoader__.load({
497
497
  // ---------------------------------------------------------------------
498
498
  // Controls
499
499
  // ---------------------------------------------------------------------
500
- function Switch({ id, checked, disabled, onChange, label, hint }) {
501
- const labelId = `${id}-label`;
502
- const hintId = `${id}-hint`;
500
+ /**
501
+ * A toggle.
502
+ *
503
+ * Two shapes: a standalone one that renders its own label and hint, and an
504
+ * embedded one (`labelId` set) that renders only the control because the
505
+ * surrounding {@link Field} already renders that copy. Rendering it in both
506
+ * places printed the label twice.
507
+ * @param props - state, change handler, and either `label`/`hint` or `labelId`.
508
+ * @returns the toggle element.
509
+ */
510
+ function Switch({ id, checked, disabled, onChange, label, hint, labelId, describedById }) {
511
+ const ownLabelId = `${id}-label`;
512
+ const ownHintId = `${id}-hint`;
513
+ const embedded = labelId !== undefined;
514
+ const button = React.createElement("button", {
515
+ key: "switch",
516
+ type: "button",
517
+ role: "switch",
518
+ id,
519
+ className: "duSwitch",
520
+ "aria-checked": checked === true,
521
+ "aria-labelledby": embedded ? labelId : ownLabelId,
522
+ "aria-describedby": embedded ? describedById : (hint === undefined ? undefined : ownHintId),
523
+ disabled: disabled === true,
524
+ onClick: () => onChange(checked !== true),
525
+ });
526
+ if (embedded) return button;
503
527
  return React.createElement("div", {
504
528
  style: { display: "flex", alignItems: "flex-start", gap: 10 },
505
529
  }, [
506
- React.createElement("button", {
507
- key: "switch",
508
- type: "button",
509
- role: "switch",
510
- id,
511
- className: "duSwitch",
512
- "aria-checked": checked === true,
513
- "aria-labelledby": labelId,
514
- "aria-describedby": hint === undefined ? undefined : hintId,
515
- disabled: disabled === true,
516
- onClick: () => onChange(checked !== true),
517
- }),
530
+ button,
518
531
  React.createElement("div", { key: "text", style: { minWidth: 0 } }, [
519
- React.createElement("div", { key: "l", className: "duFieldLabel", id: labelId }, label),
532
+ React.createElement("div", { key: "l", className: "duFieldLabel", id: ownLabelId }, label),
520
533
  hint === undefined
521
534
  ? null
522
- : React.createElement("div", { key: "h", className: "duFieldHint", id: hintId }, hint),
535
+ : React.createElement("div", { key: "h", className: "duFieldHint", id: ownHintId }, hint),
523
536
  ]),
524
537
  ]);
525
538
  }
526
539
 
540
+ /**
541
+ * One label/control row.
542
+ *
543
+ * The label and hint carry stable ids (`<id>-label`, `<id>-hint`) so a control
544
+ * that renders no text of its own can point at them instead of repeating the
545
+ * copy. Two copies of the same label is what happens when both sides render it.
546
+ * @param props - row id, label, optional hint, and the control.
547
+ * @returns the row element.
548
+ */
527
549
  function Field({ id, label, hint, children }) {
528
550
  return React.createElement("div", { className: "duField" }, [
529
551
  React.createElement("div", { key: "label" }, [
530
- React.createElement("label", { key: "l", className: "duFieldLabel", htmlFor: id }, label),
552
+ React.createElement("label", { key: "l", className: "duFieldLabel", id: `${id}-label`, htmlFor: id }, label),
531
553
  hint === undefined
532
554
  ? null
533
- : React.createElement("div", { key: "h", className: "duFieldHint" }, hint),
555
+ : React.createElement("div", { key: "h", className: "duFieldHint", id: `${id}-hint` }, hint),
534
556
  ]),
535
557
  React.createElement("div", { key: "body", className: "duFieldBody" }, children),
536
558
  ]);
@@ -848,7 +870,6 @@ window.__ModuleLoader__.load({
848
870
  const stats = data.stats ?? {};
849
871
  const config = draft ?? serverConfig ?? {};
850
872
  const excluded = Array.isArray(config.excludeCodes) ? config.excludeCodes : [];
851
- const providerRung = data.ladder?.[0] ?? null;
852
873
  const maxLabel = fmt.duration(config.maxDelayMs);
853
874
  const unlimited = config.maxAttempts === null || config.maxAttempts === undefined;
854
875
 
@@ -882,10 +903,11 @@ window.__ModuleLoader__.load({
882
903
  "data-layer": "plugin",
883
904
  }, [
884
905
  React.createElement("span", { key: "i", className: "duRungIndex" }, "…"),
885
- React.createElement("span", { key: "n", className: "duRungName" },
886
- fmt.fill(t("ladderBeyond"), { max: maxLabel })),
887
- React.createElement("span", { key: "note", className: "duRungNote" },
888
- providerRung === null ? "" : fmt.duration(providerRung.delayMs)),
906
+ React.createElement("span", { key: "n", className: "duRungName" }, t("ladderBeyond")),
907
+ // The ceiling this row is about. It used to read `data.ladder[0].delayMs`,
908
+ // which is the *first* delay of the plugin's own ladder: the row then
909
+ // said "capped at 1.0 min" on the left and "1.0 s" on the right.
910
+ React.createElement("span", { key: "note", className: "duRungNote" }, maxLabel),
889
911
  ]));
890
912
 
891
913
  const policyCard = React.createElement("div", { key: "policy", className: "duCard" }, [
@@ -895,19 +917,19 @@ window.__ModuleLoader__.load({
895
917
  React.createElement("div", { key: "hint", className: "duCardHint" }, t("policyHint")),
896
918
  React.createElement("div", { key: "b", className: "duCardBody" },
897
919
  React.createElement("div", { className: "duFields" }, [
898
- React.createElement("div", { key: "enabled", className: "duField" }, [
899
- React.createElement("div", { key: "l", className: "duFieldLabel" }, t("enabled")),
900
- React.createElement("div", { key: "b", className: "duFieldBody" },
901
- React.createElement(Switch, {
902
- id: "du-enabled",
903
- checked: config.autoRetry === true,
904
- disabled: !writable || pending,
905
- onChange: (next) => patch({ autoRetry: next }),
906
- label: t("enabled"),
907
- hint: t("enabledHint"),
908
- }),
909
- ),
910
- ]),
920
+ React.createElement(Field, {
921
+ key: "enabled",
922
+ id: "du-enabled",
923
+ label: t("enabled"),
924
+ hint: t("enabledHint"),
925
+ }, React.createElement(Switch, {
926
+ id: "du-enabled",
927
+ checked: config.autoRetry === true,
928
+ disabled: !writable || pending,
929
+ onChange: (next) => patch({ autoRetry: next }),
930
+ labelId: "du-enabled-label",
931
+ describedById: "du-enabled-hint",
932
+ })),
911
933
 
912
934
  React.createElement(Field, {
913
935
  key: "attempts",
@@ -1008,33 +1030,33 @@ window.__ModuleLoader__.load({
1008
1030
  React.createElement("span", { key: "u", className: "duUnit" }, "%"),
1009
1031
  ]),
1010
1032
 
1011
- React.createElement("div", { key: "without", className: "duField" }, [
1012
- React.createElement("div", { key: "l", className: "duFieldLabel" }, t("withoutPolicy")),
1013
- React.createElement("div", { key: "b", className: "duFieldBody" },
1014
- React.createElement(Switch, {
1015
- id: "du-without-policy",
1016
- checked: config.retryWithoutProviderPolicy === true,
1017
- disabled: !writable || pending,
1018
- onChange: (next) => patch({ retryWithoutProviderPolicy: next }),
1019
- label: t("withoutPolicy"),
1020
- hint: t("withoutPolicyHint"),
1021
- }),
1022
- ),
1023
- ]),
1033
+ React.createElement(Field, {
1034
+ key: "without",
1035
+ id: "du-without-policy",
1036
+ label: t("withoutPolicy"),
1037
+ hint: t("withoutPolicyHint"),
1038
+ }, React.createElement(Switch, {
1039
+ id: "du-without-policy",
1040
+ checked: config.retryWithoutProviderPolicy === true,
1041
+ disabled: !writable || pending,
1042
+ onChange: (next) => patch({ retryWithoutProviderPolicy: next }),
1043
+ labelId: "du-without-policy-label",
1044
+ describedById: "du-without-policy-hint",
1045
+ })),
1024
1046
 
1025
- React.createElement("div", { key: "events", className: "duField" }, [
1026
- React.createElement("div", { key: "l", className: "duFieldLabel" }, t("recordEvents")),
1027
- React.createElement("div", { key: "b", className: "duFieldBody" },
1028
- React.createElement(Switch, {
1029
- id: "du-record-events",
1030
- checked: config.recordSessionEvents === true,
1031
- disabled: !writable || pending,
1032
- onChange: (next) => patch({ recordSessionEvents: next }),
1033
- label: t("recordEvents"),
1034
- hint: t("recordEventsHint"),
1035
- }),
1036
- ),
1037
- ]),
1047
+ React.createElement(Field, {
1048
+ key: "events",
1049
+ id: "du-record-events",
1050
+ label: t("recordEvents"),
1051
+ hint: t("recordEventsHint"),
1052
+ }, React.createElement(Switch, {
1053
+ id: "du-record-events",
1054
+ checked: config.recordSessionEvents === true,
1055
+ disabled: !writable || pending,
1056
+ onChange: (next) => patch({ recordSessionEvents: next }),
1057
+ labelId: "du-record-events-label",
1058
+ describedById: "du-record-events-hint",
1059
+ })),
1038
1060
 
1039
1061
  React.createElement("div", { key: "codes", className: "duField" }, [
1040
1062
  React.createElement("div", { key: "l" }, [
package/index.js CHANGED
@@ -40,7 +40,7 @@
40
40
  /** Cordis function-plugin name; also the Loader row id used by the patch. */
41
41
  export const name = "unlimited-retry";
42
42
 
43
- const PLUGIN_VERSION = "2.4.0";
43
+ const PLUGIN_VERSION = "2.5.0";
44
44
  const STATS_PATH = "/unlimited-retry/stats";
45
45
  const CONFIG_PATH = "/unlimited-retry/config";
46
46
  const RESET_PATH = "/unlimited-retry/reset";
@@ -676,8 +676,14 @@ export function apply(ctx, config) {
676
676
  const lifetime = new AbortController();
677
677
  const active = new Set();
678
678
 
679
- /** Sessions with a wait in flight right now, for the panel's live count. */
680
- const activeSessions = new Set();
679
+ /**
680
+ * Session key -> number of waits in flight for that session.
681
+ *
682
+ * A count, not a Set: two failures for one session can be waiting at the same
683
+ * time, and a Set would drop the session as soon as the shorter wait finished,
684
+ * reporting "0 sessions retrying" while another wait was still running.
685
+ */
686
+ const activeSessions = new Map();
681
687
  const mountedAt = Date.now();
682
688
 
683
689
  function log(level, text) {
@@ -780,9 +786,15 @@ export function apply(ctx, config) {
780
786
  const EMPTY_CHAIN = Object.freeze({ attempt: 0, retryId: undefined });
781
787
 
782
788
  let chainsRegistered = false;
789
+ /**
790
+ * A 0.2.2+ registration handle, whose `stateOf(session)` is the supported reader.
791
+ * Absent on runtimes whose `register` returns a disposer; there the service-level
792
+ * `stateOf(session, key)` is the only reader, and it is not yet deprecated.
793
+ */
794
+ let chainHandle;
783
795
  if (cfg.recordSessionEvents && CHAIN_SCHEMA !== undefined) {
784
796
  try {
785
- ctx.sessionProjections.register({
797
+ const registered = ctx.sessionProjections.register({
786
798
  key: CHAIN_KEY,
787
799
  stateVersion: 1,
788
800
  stateSchema: CHAIN_SCHEMA,
@@ -802,6 +814,30 @@ export function apply(ctx, config) {
802
814
  },
803
815
  });
804
816
  chainsRegistered = true;
817
+ // The two runtimes differ only in what `register` returns: a plain disposer
818
+ // before 0.2.2, and from 0.2.2 a *callable thenable* — upstream's own README
819
+ // says `typeof` is "function" and `instanceof Promise` is false. A check for
820
+ // an object misses it and leaves every read on the deprecated service reader,
821
+ // so this test intentionally accepts a function that carries `then`.
822
+ //
823
+ // Deliberately not an async `apply`: upstream's guidance for new plugins is
824
+ // to await registration, but this plugin's routes and mount probe are
825
+ // registered synchronously and its reader is served from a listener that can
826
+ // fire at any time. Definitions install synchronously anyway, and the handle
827
+ // lands on a microtask, so resolving it here keeps `apply` sync without ever
828
+ // reading stale state.
829
+ if (registered !== null && (typeof registered === "object" || typeof registered === "function")
830
+ && typeof registered.then === "function") {
831
+ Promise.resolve(registered).then(
832
+ (handle) => {
833
+ if (handle !== null && typeof handle === "object" && typeof handle.stateOf === "function") chainHandle = handle;
834
+ },
835
+ (error) => {
836
+ chainsRegistered = false;
837
+ log("warn", `session projection registration failed (${String(error)}); retry ladders are bounded and process-local instead`);
838
+ },
839
+ );
840
+ }
805
841
  } catch (error) {
806
842
  log("warn", `session projections unavailable (${String(error)}); retry ladders are bounded and process-local instead`);
807
843
  }
@@ -828,6 +864,16 @@ export function apply(ctx, config) {
828
864
  });
829
865
  }
830
866
 
867
+ /**
868
+ * Release one in-flight wait for a session.
869
+ * @param key - the session key counted by {@link activeSessions}.
870
+ */
871
+ function leaveSession(key) {
872
+ const remaining = (activeSessions.get(key) ?? 1) - 1;
873
+ if (remaining <= 0) activeSessions.delete(key);
874
+ else activeSessions.set(key, remaining);
875
+ }
876
+
831
877
  /**
832
878
  * Read the ladder for one session.
833
879
  * @param session - the session that owns the ladder.
@@ -836,6 +882,11 @@ export function apply(ctx, config) {
836
882
  function chainFor(session) {
837
883
  if (chainsRegistered) {
838
884
  try {
885
+ // Prefer the handle, which is the supported reader from 0.2.2 on; the
886
+ // service reader is deprecated there. The handle resolves on a microtask,
887
+ // so no recorded event can arrive before it is adopted — measured on
888
+ // 0.2.2-alpha.2: zero deprecation warnings across a full ladder.
889
+ if (chainHandle !== undefined) return chainHandle.stateOf(session) ?? EMPTY_CHAIN;
839
890
  return ctx.sessionProjections.stateOf(session, CHAIN_KEY) ?? EMPTY_CHAIN;
840
891
  } catch (error) {
841
892
  // Reading a projection needs a real session (the registry folds its log
@@ -958,7 +1009,7 @@ export function apply(ctx, config) {
958
1009
  });
959
1010
 
960
1011
  const sessionKey = session?.id ?? "unidentified-session";
961
- activeSessions.add(sessionKey);
1012
+ activeSessions.set(sessionKey, (activeSessions.get(sessionKey) ?? 0) + 1);
962
1013
  const at = new Date().toISOString();
963
1014
  stats.totalRetries += 1;
964
1015
  stats.lastRetryAt = at;
@@ -978,7 +1029,7 @@ export function apply(ctx, config) {
978
1029
  );
979
1030
 
980
1031
  const completed = await cancellableDelay(delayMs, [fused.signal]);
981
- activeSessions.delete(sessionKey);
1032
+ leaveSession(sessionKey);
982
1033
  fused.release();
983
1034
  if (!completed || fused.signal.aborted) return false;
984
1035
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unlimited-retry",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Unbounded model-request retry for the DeepSeek Harness agent loop, with a live Settings panel.",
5
5
  "keywords": [
6
6
  "deepseek",