dsh-question-timeout-protection 0.1.2 → 0.1.3

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  # dsh-question-timeout-protection
4
4
 
5
- [![Version](https://img.shields.io/badge/Version-0.1.2-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
5
+ [![Version](https://img.shields.io/badge/Version-0.1.3-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
6
6
  [![Copyright](https://img.shields.io/badge/Copyright-JularDepick-0066AA)](./COPYRIGHT)
7
7
  [![License](https://img.shields.io/badge/License-Apache--2.0-yellow)](./LICENSE)
8
8
 
@@ -36,7 +36,7 @@ dsh 默认的提问是阻塞式的: 模型问完就一直等, 你离开一会儿
36
36
 
37
37
  ### 前置条件
38
38
 
39
- - dsh 版本在 `>=0.2.1-rc.1 <=0.2.2-rc.2` 之内, 不满足会被安装与启动阶段拒绝
39
+ - dsh 版本在 `>=0.2.1-rc.1 <0.2.3-rc.1` 之内, 不满足会被安装与启动阶段拒绝
40
40
  - Node.js >= 20
41
41
 
42
42
  ### 方式一: 从 npm 安装
@@ -47,7 +47,7 @@ dsh 原生支持从 npm 安装插件:
47
47
  dsh plugin --profile <profile> add dsh-question-timeout-protection
48
48
  ```
49
49
 
50
- npm 上的 latest 目前是 0.1.1, 它声明的 dsh 上限是 0.2.2-rc.1, 因此在 0.2.2-rc.2 上会被安装与启动阶段拒绝. 想用本版本(0.1.2)请走下面的方式二至方式四; latest 指向 0.1.2 后, 上面的命令即可直接安装本版本.
50
+ 按包名安装默认取 npm 上 latest 标签指向的版本. 0.1.2 声明的 dsh 上限是 `0.2.2-rc.2`, 在 dsh `0.2.2-rc.3` 起的宿主上会被安装与启动阶段拒绝; 需要固定版本时用 `dsh plugin --profile <profile> add dsh-question-timeout-protection@<版本>`. 本版本 0.1.3 的上限是 `<0.2.3-rc.1`, 也可以按下面的方式二至方式四从源码或 tarball 安装.
51
51
 
52
52
  ### 方式二: 从源码构建后安装
53
53
 
@@ -60,7 +60,7 @@ dsh plugin --profile <profile> add ./release/<tarball>
60
60
  dsh plugin --profile <profile> add <绝对路径>
61
61
  ```
62
62
 
63
- `pnpm pack` 会先构建, 完成后把 tarball 移入仓库根目录的 `release/`, 文件名形如 `dsh-question-timeout-protection-0.1.2.tgz`. 沙箱内生命周期脚本被拦截时改用 `pnpm run pack:release`, 产物相同. `add` 的路径要以 `./` 或 `../` 开头才会按你执行命令的目录解析, 不带前缀会被当成包名去查注册表.
63
+ `pnpm pack` 会先构建, 完成后把 tarball 移入仓库根目录的 `release/`, 文件名形如 `dsh-question-timeout-protection-0.1.3.tgz`. 沙箱内生命周期脚本被拦截时改用 `pnpm run pack:release`, 产物相同. `add` 的路径要以 `./` 或 `../` 开头才会按你执行命令的目录解析, 不带前缀会被当成包名去查注册表.
64
64
 
65
65
  ### 方式三: 直接从 GitHub 源码安装
66
66
 
@@ -151,7 +151,7 @@ dsh plugin --profile <profile> add <绝对路径>
151
151
 
152
152
  | 项目 | 版本 |
153
153
  |:---:|:---:|
154
- | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.2` |
154
+ | dsh | `>=0.2.1-rc.1 <0.2.3-rc.1` |
155
155
  | Node.js | >= 20 |
156
156
 
157
157
  宿主 dsh 自身的 Node.js 要求以对应版本的发行说明为准.
package/README_en-US.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # dsh-question-timeout-protection
4
4
 
5
- [![Version](https://img.shields.io/badge/Version-0.1.2-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
5
+ [![Version](https://img.shields.io/badge/Version-0.1.3-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
6
6
  [![Copyright](https://img.shields.io/badge/Copyright-JularDepick-0066AA)](./COPYRIGHT)
7
7
  [![License](https://img.shields.io/badge/License-Apache--2.0-yellow)](./LICENSE)
8
8
 
@@ -36,7 +36,7 @@ This plugin adds three things: you can see how long is left, you can pause the w
36
36
 
37
37
  ### Requirements
38
38
 
39
- - dsh within `>=0.2.1-rc.1 <=0.2.2-rc.2`; installation and startup refuse anything outside it
39
+ - dsh within `>=0.2.1-rc.1 <0.2.3-rc.1`; installation and startup refuse anything outside it
40
40
  - Node.js >= 20
41
41
 
42
42
  ### Option A: install from npm
@@ -47,7 +47,7 @@ dsh installs plugins from npm natively:
47
47
  dsh plugin --profile <profile> add dsh-question-timeout-protection
48
48
  ```
49
49
 
50
- The npm latest tag currently points at 0.1.1, which declares dsh support only up to 0.2.2-rc.1, so installation and startup reject it on 0.2.2-rc.2. For this version (0.1.2) use Options B to D below; once latest points at 0.1.2 the command above installs this version directly.
50
+ Installing by package name takes whatever the npm latest tag points at. Version 0.1.2 declares dsh support only up to `0.2.2-rc.2`, so installation and startup reject it on dsh `0.2.2-rc.3` and later; pin a version with `dsh plugin --profile <profile> add dsh-question-timeout-protection@<version>`. This version (0.1.3) supports up to `<0.2.3-rc.1`, and Options B to D below install it from source or a tarball.
51
51
 
52
52
  ### Option B: build from source
53
53
 
@@ -60,7 +60,7 @@ dsh plugin --profile <profile> add ./release/<tarball>
60
60
  dsh plugin --profile <profile> add <absolute path>
61
61
  ```
62
62
 
63
- `pnpm pack` builds first, then moves the tarball into `release/` at the repository root under a name like `dsh-question-timeout-protection-0.1.2.tgz`. Where a sandbox blocks lifecycle scripts, use `pnpm run pack:release` for the same artifact. A path passed to `add` is resolved against your current directory only when it starts with `./` or `../`; otherwise it is treated as a package name and looked up in the registry.
63
+ `pnpm pack` builds first, then moves the tarball into `release/` at the repository root under a name like `dsh-question-timeout-protection-0.1.3.tgz`. Where a sandbox blocks lifecycle scripts, use `pnpm run pack:release` for the same artifact. A path passed to `add` is resolved against your current directory only when it starts with `./` or `../`; otherwise it is treated as a package name and looked up in the registry.
64
64
 
65
65
  ### Option C: install from the GitHub source
66
66
 
@@ -134,7 +134,7 @@ With this off, the plugin only withdraws the card and hands the model no draft.
134
134
 
135
135
  ### Configuration
136
136
 
137
- The config page sits at the **top of the plugin detail view**, not inside "Components". Only "Inject into context" can be changed, and a toggle writes immediately without any save or refresh. Keep the draft in the UI and the three fixed features below are listed as fixed rows for reference; the page offers no switches for them.
137
+ The config page sits at the **top of the plugin detail view**, not inside "Components". Only "Inject into context" can be changed, and a toggle writes immediately without any save or refresh. The page lists "keep the draft in the UI" and the three fixed features below as fixed rows for reference; none of them has a switch.
138
138
 
139
139
  | Option | Values | Default | UI | Description |
140
140
  |:---:|:---:|:---:|:---:|:---:|
@@ -151,7 +151,7 @@ The last two are not exposed in the UI; write them into this plugin's row under
151
151
 
152
152
  | Item | Version |
153
153
  |:---:|:---:|
154
- | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.2` |
154
+ | dsh | `>=0.2.1-rc.1 <0.2.3-rc.1` |
155
155
  | Node.js | >= 20 |
156
156
 
157
157
  The Node.js requirement of the host dsh itself follows the release notes of the matching version.
package/dist/client.js CHANGED
@@ -377,6 +377,16 @@ function parseRemainingSeconds(text) {
377
377
  if (matched !== null) return Number(matched[1]);
378
378
  }
379
379
  }
380
+ function hostStillWaiting(card) {
381
+ for (const element of Array.from(card.querySelectorAll(WAIT_STATUS_SELECTOR))) {
382
+ const text = (element.textContent ?? "").trim();
383
+ if (text === "") continue;
384
+ if (parseRemainingSeconds(text) !== void 0) return true;
385
+ if (PAUSED_TEXT_PATTERNS.some((pattern) => pattern.test(text))) return true;
386
+ if (HOST_WAIT_PATTERNS.some((pattern) => text.includes(pattern))) return true;
387
+ }
388
+ return false;
389
+ }
380
390
  function readAutoInfinite() {
381
391
  try {
382
392
  return window.localStorage.getItem(AUTO_INFINITE_STORAGE_KEY) === "on";
@@ -538,7 +548,9 @@ function mergeDrafts(host, live, snapshot, count, liveIndex) {
538
548
  const merged = [];
539
549
  for (let i = 0; i < count; i += 1) {
540
550
  const hostItem = host?.[i];
541
- if (hostItem !== void 0) {
551
+ const liveItem = live?.[i];
552
+ const liveUsable = i === liveIndex && liveItem !== void 0 && hasItemContent(liveItem);
553
+ if (hostItem !== void 0 && !(liveUsable && !hasItemContent(hostItem))) {
542
554
  merged.push({
543
555
  selected: [...hostItem.selected],
544
556
  custom: hostItem.custom,
@@ -546,8 +558,7 @@ function mergeDrafts(host, live, snapshot, count, liveIndex) {
546
558
  });
547
559
  continue;
548
560
  }
549
- const liveItem = live?.[i];
550
- if (i === liveIndex && liveItem !== void 0 && hasItemContent(liveItem)) {
561
+ if (liveUsable && liveItem !== void 0) {
551
562
  merged.push({
552
563
  selected: [...liveItem.selected],
553
564
  custom: liveItem.custom,
@@ -1008,6 +1019,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1008
1019
  card.classList.add(HIDDEN_CONTROL_CLASS);
1009
1020
  };
1010
1021
  const restoreCard = (card) => {
1022
+ if (card.getAttribute(CARD_DISMISSED_ATTRIBUTE) !== null) return;
1011
1023
  card.classList.remove(HIDDEN_CONTROL_CLASS);
1012
1024
  for (const element of Array.from(card.querySelectorAll("." + HIDDEN_CONTROL_CLASS))) element.classList.remove(HIDDEN_CONTROL_CLASS);
1013
1025
  for (const element of Array.from(card.querySelectorAll("[data-dqtp-host-wait]"))) element.removeAttribute(HIDDEN_WAIT_ATTRIBUTE);
@@ -1361,7 +1373,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1361
1373
  draftTooLargeAt.delete(identity.callId);
1362
1374
  }
1363
1375
  if (timedOut.has(identity.callId) || passive.has(identity.callId)) return;
1364
- if (!callActive.has(identity.callId)) return;
1376
+ if (!callActive.has(identity.callId) && !hostStillWaiting(card)) return;
1365
1377
  rememberCallSession(identity);
1366
1378
  const progress = readProgress(card);
1367
1379
  const projected = projectedCounts.get(identity.callId) ?? 1;
@@ -1464,7 +1476,13 @@ function installQuestionTimeoutAdapter(ctx, source) {
1464
1476
  const evaluateProjection = (sessionId, snapshot) => {
1465
1477
  if (typeof snapshot !== "object" || snapshot === null) return;
1466
1478
  const active = snapshot.active;
1467
- if (!Array.isArray(active)) return;
1479
+ if (!Array.isArray(active)) {
1480
+ if (!evaluateWarned.has(sessionId)) {
1481
+ evaluateWarned.add(sessionId);
1482
+ console.warn("[question-timeout-protection] 提问投影结构不符, 该会话的超时接管可能不会生效");
1483
+ }
1484
+ return;
1485
+ }
1468
1486
  const live = /* @__PURE__ */ new Set();
1469
1487
  for (const row of active) {
1470
1488
  if (typeof row.callId !== "string") continue;
@@ -1563,9 +1581,16 @@ function installQuestionTimeoutAdapter(ctx, source) {
1563
1581
  subscriptionSeen.delete(oldestSession);
1564
1582
  const evictedSession = oldestSession;
1565
1583
  polledSessions.set(evictedSession, () => {
1566
- const face = resolveProjectionFace(ctx, evictedSession);
1567
- if (face === void 0) return;
1568
- evaluateProjection(evictedSession, face.getSnapshot?.());
1584
+ try {
1585
+ const face = resolveProjectionFace(ctx, evictedSession);
1586
+ if (face === void 0) return;
1587
+ evaluateProjection(evictedSession, face.getSnapshot?.());
1588
+ } catch (error) {
1589
+ if (!evaluateWarned.has(evictedSession)) {
1590
+ evaluateWarned.add(evictedSession);
1591
+ console.warn("[question-timeout-protection] 评估提问投影时出错, 该会话的兜底可能受影响", error);
1592
+ }
1593
+ }
1569
1594
  });
1570
1595
  subscriptionSeen.set(evictedSession, Date.now());
1571
1596
  enforcePolledLimit();
@@ -1677,7 +1702,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1677
1702
  }
1678
1703
  subscriptionSeen.set(identity.sessionId, Date.now());
1679
1704
  ensureSubscription(identity.sessionId);
1680
- if (enhancementOn && callActive.has(identity.callId)) {
1705
+ if (enhancementOn && (callActive.has(identity.callId) || hostStillWaiting(element))) {
1681
1706
  const previous = lastDrafts.get(identity.callId);
1682
1707
  const progress = readProgress(element);
1683
1708
  const count = Math.max(progress?.count ?? 1, previous?.length ?? 1);
package/dist/index.mjs CHANGED
@@ -136,6 +136,7 @@ function markCallSettled(callId) {
136
136
  if (oldest.done) break;
137
137
  settledCalls.delete(oldest.value);
138
138
  }
139
+ sweepTrackedCalls();
139
140
  }
140
141
  function sleep(ms) {
141
142
  return new Promise((resolve) => {
@@ -310,7 +311,6 @@ function handleStateRequest(request, response) {
310
311
  reason: "too-large"
311
312
  }));
312
313
  chunks.length = 0;
313
- request.destroy();
314
314
  }
315
315
  });
316
316
  request.on("error", (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-question-timeout-protection",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "dsh提问超时保护插件: 一旦模型提问超时,将你的回答草稿保留在UI或上下文中,而不是直接丢弃。",
5
5
  "type": "module",
6
6
  "author": "JularDepick",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "engines": {
13
13
  "node": ">=20",
14
- "dsh": ">=0.2.1-rc.1 <=0.2.2-rc.2"
14
+ "dsh": ">=0.2.1-rc.1 <0.2.3-rc.1"
15
15
  },
16
16
  "main": "./dist/index.mjs",
17
17
  "types": "./dist/index.d.mts",
@@ -51,23 +51,23 @@
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
54
- "@deepseek-ai/dsh-agent": ">=0.2.1-rc.1 <=0.2.2-rc.2",
55
- "@deepseek-ai/dsh-tools": ">=0.2.1-rc.1 <=0.2.2-rc.2",
56
- "@deepseek-ai/dsh-user-questions": ">=0.2.1-rc.1 <=0.2.2-rc.2"
54
+ "@deepseek-ai/dsh-agent": ">=0.2.1-rc.1 <0.2.3-rc.1",
55
+ "@deepseek-ai/dsh-tools": ">=0.2.1-rc.1 <0.2.3-rc.1",
56
+ "@deepseek-ai/dsh-user-questions": ">=0.2.1-rc.1 <0.2.3-rc.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@deepseek-ai/cordis": "~4.1.0",
60
- "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
61
- "@deepseek-ai/dsh-client-locale": "0.2.2-rc.2",
62
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.2",
63
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.2",
64
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.2",
65
- "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.2",
66
- "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.2",
67
- "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
68
- "@deepseek-ai/dsh-session": "0.2.2-rc.2",
69
- "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
70
- "@deepseek-ai/dsh-user-questions": "0.2.2-rc.2",
60
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.3",
61
+ "@deepseek-ai/dsh-client-locale": "0.2.2-rc.3",
62
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.3",
63
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.3",
64
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.3",
65
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.3",
66
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.3",
67
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.3",
68
+ "@deepseek-ai/dsh-session": "0.2.2-rc.3",
69
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.3",
70
+ "@deepseek-ai/dsh-user-questions": "0.2.2-rc.3",
71
71
  "@types/node": "^26.2.0",
72
72
  "@types/react": "^18.3.31",
73
73
  "react": "^18.2.0",
@@ -1,5 +1,5 @@
1
1
  [meta]
2
- for=v0.1.2
2
+ for=v0.1.3
3
3
  lang=zh-CN
4
4
  name=简体中文
5
5
  endtime=2026-11-12 18:50:00+08:00
@@ -1,5 +1,5 @@
1
1
  [meta]
2
- for=v0.1.2
2
+ for=v0.1.3
3
3
  lang=en-US
4
4
  name=English (US)
5
5
  endtime=2026-11-12 19:20:00+08:00
@@ -1,5 +1,5 @@
1
1
  [meta]
2
- for=v0.1.2
2
+ for=v0.1.3
3
3
  lang=zh-CN
4
4
  name=简体中文
5
5
  endtime=2026-11-12 18:50:00+08:00