dsh-question-timeout-protection 0.1.1 → 0.1.2

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.1-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
5
+ [![Version](https://img.shields.io/badge/Version-0.1.2-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,20 +36,18 @@ dsh 默认的提问是阻塞式的: 模型问完就一直等, 你离开一会儿
36
36
 
37
37
  ### 前置条件
38
38
 
39
- - dsh 版本在 `>=0.2.1-rc.1 <=0.2.2-rc.1` 之内, 不满足会被安装与启动阶段拒绝
39
+ - dsh 版本在 `>=0.2.1-rc.1 <=0.2.2-rc.2` 之内, 不满足会被安装与启动阶段拒绝
40
40
  - Node.js >= 20
41
41
 
42
42
  ### 方式一: 从 npm 安装
43
43
 
44
- dsh 原生支持从 npm 安装插件, 但 npm 上的同名包目前只是一个发布占位, 里面没有插件代码, 不能安装: 按下面的命令会装到占位包, dsh 只会打一条警告并跳过该插件, 界面上不会出现任何本插件的功能.
45
-
46
- 真正可用的前提是本项目发布到 npm 且 latest 指向正式版本. 到那时一条命令即可:
44
+ dsh 原生支持从 npm 安装插件:
47
45
 
48
46
  ```
49
47
  dsh plugin --profile <profile> add dsh-question-timeout-protection
50
48
  ```
51
49
 
52
- 在此之前请用下面的方式二至方式四.
50
+ npm 上的 latest 目前是 0.1.1, 它声明的 dsh 上限是 0.2.2-rc.1, 因此在 0.2.2-rc.2 上会被安装与启动阶段拒绝. 想用本版本(0.1.2)请走下面的方式二至方式四; latest 指向 0.1.2 后, 上面的命令即可直接安装本版本.
53
51
 
54
52
  ### 方式二: 从源码构建后安装
55
53
 
@@ -58,10 +56,11 @@ dsh plugin --profile <profile> add dsh-question-timeout-protection
58
56
  ```
59
57
  pnpm install
60
58
  pnpm pack
61
- dsh plugin --profile <profile> add <tarball>
59
+ dsh plugin --profile <profile> add ./release/<tarball>
60
+ dsh plugin --profile <profile> add <绝对路径>
62
61
  ```
63
62
 
64
- `pnpm pack` 会先构建, 完成后把 tarball 放进打包输出目录, 文件名形如 `dsh-question-timeout-protection-0.1.1.tgz`. 按文件名定位后换成实际路径即可.
63
+ `pnpm pack` 会先构建, 完成后把 tarball 移入仓库根目录的 `release/`, 文件名形如 `dsh-question-timeout-protection-0.1.2.tgz`. 沙箱内生命周期脚本被拦截时改用 `pnpm run pack:release`, 产物相同. `add` 的路径要以 `./` 或 `../` 开头才会按你执行命令的目录解析, 不带前缀会被当成包名去查注册表.
65
64
 
66
65
  ### 方式三: 直接从 GitHub 源码安装
67
66
 
@@ -74,6 +73,8 @@ allowBuilds:
74
73
  dsh-question-timeout-protection: true
75
74
  ```
76
75
 
76
+ `allowBuilds` 从 pnpm 10.26 起可用; 更早的 10.x 请把同一个包键写进 `onlyBuiltDependencies` 列表.
77
+
77
78
  然后重新执行 `add`. 跳过这一步装上去没有构建产物, 插件不会工作.
78
79
 
79
80
  ### 方式四: 从 Release 的 tarball 安装
@@ -81,7 +82,8 @@ allowBuilds:
81
82
  下载对应版本的 tarball 后直接:
82
83
 
83
84
  ```
84
- dsh plugin --profile <profile> add <tarball>
85
+ dsh plugin --profile <profile> add ./release/<tarball>
86
+ dsh plugin --profile <profile> add <绝对路径>
85
87
  ```
86
88
 
87
89
  这种方式不需要构建, 也不受 pnpm 构建脚本拦截影响.
@@ -124,7 +126,7 @@ dsh plugin --profile <profile> add <tarball>
124
126
 
125
127
  ### 注入到上下文
126
128
 
127
- 这一项默认开启. 开启后, 插件在你作答期间就把草稿快照持续上报给服务端, 工具到期时取用最新一份, 按题随工具的 pending 结果带回模型上下文, 每道题带自己的已选与补充.
129
+ 这一项默认开启. 客户端在作答期间始终把草稿快照上报给服务端(它读不到服务端配置), 由服务端按这一项决定是否取用: 开启时工具到期取用最新一份, 按题随 pending 结果带回模型上下文, 每道题带自己的已选与补充; 关闭时快照只留在服务端并在调用结束时清掉.
128
130
 
129
131
  超时说明与草稿放在同一个结果里, 并明确要求模型在回复末尾告知你这次超时; 如果带回了草稿, 还要说明准备怎么处理它.
130
132
 
@@ -132,22 +134,24 @@ dsh plugin --profile <profile> add <tarball>
132
134
 
133
135
  ### 配置项
134
136
 
135
- 配置页在**插件详情页顶部**的插件级配置区块, 不在「包含的组件」里. 其中只有「注入到上下文」一个勾选可以调整, 勾选变化立即写入, 不需要保存或刷新.
137
+ 配置页在**插件详情页顶部**的插件级配置区块, 不在「包含的组件」里. 其中只有「注入到上下文」一个勾选可以调整, 勾选变化立即写入, 不需要保存或刷新. 页面以固定行列出「界面保留草稿」与下面三项固定特性, 只作说明, 不提供开关.
136
138
 
137
139
  | 配置项 | 取值 | 默认值 | 界面 | 说明 |
138
140
  |:---:|:---:|:---:|:---:|:---:|
139
141
  | `fallback` | `ui` / `context` / `both` | `both` | 可改一项 | 超时兜底. 界面只给「注入到上下文」勾选, 勾上写 `both`, 不勾写 `ui`. 界面保留草稿恒定开启, 所以不会出现 `context` |
140
- | `cardEnhancements` | 布尔 | `true` | 固定特性 | 只管装饰: 倒计时与闪烁, 单选底色, 提问气泡, 隐藏宿主自带的收起控件与等待文案. 关闭后装饰都不出现, 但超时收尾照常: 该收的卡片仍会被收起与锁定, 草稿仍会按配置上报 |
142
+ | `cardEnhancements` | 布尔 | `true` | 固定特性 | 只管装饰: 倒计时与警示闪烁, 单选选项的方形标号填充底色, 提问气泡, 隐藏宿主自带的收起控件与等待文案. 关闭后装饰都不出现, 但超时收尾照常: 该收的卡片仍会被收起与锁定, 草稿仍会按配置上报 |
141
143
  | `infiniteWait` | 布尔 | `true` | 固定特性 | 提供「无限等待」按钮与工具栏常开开关, 关闭后两者一并移除 |
142
144
  | `draftFallback` | 布尔 | `true` | 固定特性 | 超时收尾开关. 关闭后客户端不再收尾卡片也不再上报草稿, 这一轮交还宿主; 提问仍由插件按时结算 |
143
145
  | `warningSeconds` | 数字 | 5 | 不暴露 | 进入红字闪烁的剩余秒数, 取值 1 至 60 |
144
146
  | `timeoutSeconds` | 数字 | 120 | 不暴露 | 模型没有显式传等待秒数时用的时长, 取值 1 至 2147483 |
145
147
 
148
+ 最后两项不在界面暴露, 需要时在该 profile 的 `cordis.patch.yml` 里本插件行的 `config` 中写入, 例如把等待时长改成 300 秒: `config: { timeoutSeconds: 300 }`. 取值越界会在加载期报错. 三个固定特性同样只能经这条路径关闭, 例如 `config: { cardEnhancements: false }`; 该行的其余键必须一并重述, 不能只写改动的键.
149
+
146
150
  ## 兼容性
147
151
 
148
152
  | 项目 | 版本 |
149
153
  |:---:|:---:|
150
- | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.1` |
154
+ | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.2` |
151
155
  | Node.js | >= 20 |
152
156
 
153
157
  宿主 dsh 自身的 Node.js 要求以对应版本的发行说明为准.
@@ -190,7 +194,7 @@ dsh plugin --profile <profile> add <tarball>
190
194
 
191
195
  **依赖宿主界面**
192
196
 
193
- 卡片与工具行靠宿主的类名后缀, `data-question-key`, `data-chat-call-id`, `aria-checked` 等特征定位, 宿主控件按中英文标签识别; 工具栏开关优先按模型选择控件的无障碍标签定位, 标签不匹配时退回工具栏容器内按结构定位, 再退回全文档查找, 定位失败时按原因各留一条 console.warn 而不是静默消失. 宿主改动这些结构或文案时对应增强会失效, 识别标签与选择器集中在源码的常量文件里.
197
+ 卡片与工具行靠宿主的类名后缀, `data-question-key`, `data-chat-call-id`, `aria-checked` 等特征定位, 宿主控件按中英文标签识别(日文的「回答」与中文同形, 因此那一项也能命中); 结算后恢复宿主入口时还会按 `查看回答` / `View answers` / `回答を表示` 认出「查看回答」入口; 工具栏开关优先按模型选择控件的无障碍标签定位, 标签不匹配时退回工具栏容器内按结构定位, 再退回全文档查找, 定位失败时按原因各留一条 console.warn 而不是静默消失. 宿主改动这些结构或文案时对应增强会失效, 识别标签与选择器集中在源码的常量文件里.
194
198
 
195
199
  **依赖宿主提问投影**
196
200
 
@@ -220,6 +224,7 @@ dsh plugin --profile <profile> add <tarball>
220
224
  - 宿主 0.2.2-rc.1 打开卡片时会预选带推荐标记的选项, 插件按投影里的选项原文剥掉这些预选值; 多选时点过任一选项后, 其余预选项按宿主自己的提交口径一并保留
221
225
  - 只是点了「跳过」而没有选择与输入时, 草稿按空处理, 这次超时由插件关闭卡片
222
226
  - 草稿按题合并三处来源, 优先级为宿主持久化记录, 当前显示题的实时值, 插件自己的快照; 读实时值时已选标签取的是宿主给读屏用的文案, 其中的「(推荐)」这类后缀可能被省略
227
+ - 桌面端(macOS)自 dsh 0.2.2-rc.2 起只在带 `data-window-drag` 的页头行内允许拖动窗口, 带 `data-window-drag-controls` 的容器里的控件由宿主自动排除拖动; 覆盖拖动行的自定义浮层要自身声明 `data-window-drag-exclude` 才可交互, 顶部还留了 `--dsh-frame-top-clearance` 的预留带. 插件的草稿浮层挂在 body 上, 既没有声明拖动排除也不读预留带, 因此桌面端贴近窗口顶部时可能落进预留带; 浮层内没有可点控件, 影响限于位置; 网页客户端不受影响
223
228
  - 注入给模型的超时说明目前只有中文, 英文界面下模型收到的仍是中文说明
224
229
  - 草稿超过单次上报上限 256 KiB 时界面显示「草稿过长, 未送达」, 这一条不计入连续失败次数; 连续失败三次后该轮判定通道不可用, 插件不再接管, 卡片交还宿主继续可作答
225
230
 
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.1-green)](https://github.com/JularDepick/dsh-question-timeout-protection/releases)
5
+ [![Version](https://img.shields.io/badge/Version-0.1.2-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,20 +36,18 @@ 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.1`; installation and startup refuse anything outside it
39
+ - dsh within `>=0.2.1-rc.1 <=0.2.2-rc.2`; installation and startup refuse anything outside it
40
40
  - Node.js >= 20
41
41
 
42
42
  ### Option A: install from npm
43
43
 
44
- dsh installs plugins from npm natively, but the package currently on npm is only a publishing placeholder with no plugin code and cannot be installed: the command below fetches that placeholder, dsh logs a warning and skips the plugin, and none of this plugin's features appear.
45
-
46
- It becomes usable once this project is published to npm and latest points at a real release. At that point one command is all you need:
44
+ dsh installs plugins from npm natively:
47
45
 
48
46
  ```
49
47
  dsh plugin --profile <profile> add dsh-question-timeout-protection
50
48
  ```
51
49
 
52
- Until then, use one of the options below.
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.
53
51
 
54
52
  ### Option B: build from source
55
53
 
@@ -58,10 +56,11 @@ For using the plugin straight from this repository:
58
56
  ```
59
57
  pnpm install
60
58
  pnpm pack
61
- dsh plugin --profile <profile> add <tarball>
59
+ dsh plugin --profile <profile> add ./release/<tarball>
60
+ dsh plugin --profile <profile> add <absolute path>
62
61
  ```
63
62
 
64
- `pnpm pack` builds first, then puts the tarball into the pack output directory under a name like `dsh-question-timeout-protection-0.1.1.tgz`. Locate it by that file name and use the real path.
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.
65
64
 
66
65
  ### Option C: install from the GitHub source
67
66
 
@@ -74,6 +73,8 @@ allowBuilds:
74
73
  dsh-question-timeout-protection: true
75
74
  ```
76
75
 
76
+ `allowBuilds` is available from pnpm 10.26; on earlier 10.x put the same package key into an `onlyBuiltDependencies` list.
77
+
77
78
  Then run `add` again. Without this step the install lands with no build output and the plugin does not work.
78
79
 
79
80
  ### Option D: install from a release tarball
@@ -81,7 +82,8 @@ Then run `add` again. Without this step the install lands with no build output a
81
82
  Download the tarball for the version you want and install it directly:
82
83
 
83
84
  ```
84
- dsh plugin --profile <profile> add <tarball>
85
+ dsh plugin --profile <profile> add ./release/<tarball>
86
+ dsh plugin --profile <profile> add <absolute path>
85
87
  ```
86
88
 
87
89
  No build is needed and the pnpm build-script policy does not apply.
@@ -124,7 +126,7 @@ The draft lives only in memory, so a page refresh loses the bubbles and their re
124
126
 
125
127
  ### Context injection
126
128
 
127
- This is on by default. While you are answering, the plugin keeps reporting draft snapshots to the server; at expiry it takes the latest one and returns it to the model context through the tool's pending result, per question, each keeping its own selections and notes.
129
+ This is on by default. While you are answering, the client always reports draft snapshots to the server (it cannot read the plugin configuration); the server decides whether to use them. When on, expiry takes the latest snapshot and returns it to the model context through the tool's pending result, per question, each keeping its own selections and notes; when off, the snapshot stays on the server and is cleared when the call ends.
128
130
 
129
131
  The timeout notice and the draft share that one result, and the model is explicitly told to report the timeout at the end of its reply, plus what it intends to do with the draft when one came back.
130
132
 
@@ -132,22 +134,24 @@ With this off, the plugin only withdraws the card and hands the model no draft.
132
134
 
133
135
  ### Configuration
134
136
 
135
- The config page sits at the **top of the plugin detail view**, not inside "Included components". Only "Inject into the context" can be changed, and a toggle writes immediately without any save or refresh.
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.
136
138
 
137
139
  | Option | Values | Default | UI | Description |
138
140
  |:---:|:---:|:---:|:---:|:---:|
139
- | `fallback` | `ui` / `context` / `both` | `both` | One switch | Timeout fallback. The page only offers "Inject into the context": checked writes `both`, unchecked writes `ui`. Keeping the draft in the UI is always on, so `context` never appears |
140
- | `cardEnhancements` | boolean | `true` | Fixed | Decoration only: countdown and warning blink, selection fill, question bubble, and hiding the host's collapse controls and wait text. When off no decoration appears, while the timeout wrap-up still runs: the card that should be withdrawn still is and locked, and the draft is still reported per the configuration above |
141
+ | `fallback` | `ui` / `context` / `both` | `both` | One switch | Timeout fallback. The page only offers "Inject into context": checked writes `both`, unchecked writes `ui`. Keeping the draft in the UI is always on, so `context` never appears |
142
+ | `cardEnhancements` | boolean | `true` | Fixed | Decoration only: countdown and warning blink, a background fill on the square marker of the selected single-choice option, the question bubble, and hiding the host's collapse controls and wait text. When off no decoration appears, while the timeout wrap-up still runs: the card that should be withdrawn is still withdrawn and locked, and the draft is still reported per the configuration above |
141
143
  | `infiniteWait` | boolean | `true` | Fixed | Provides the "Wait indefinitely" button and the toolbar switch; turning it off removes both |
142
144
  | `draftFallback` | boolean | `true` | Fixed | Timeout wrap-up switch. When off the client neither withdraws the card nor reports the draft and hands that question back to the host; the plugin still settles the wait on time |
143
145
  | `warningSeconds` | number | 5 | Not exposed | Seconds remaining when the red warning starts, from 1 to 60 |
144
146
  | `timeoutSeconds` | number | 120 | Not exposed | Wait seconds used when the model does not pass one explicitly, from 1 to 2147483 |
145
147
 
148
+ The last two are not exposed in the UI; write them into this plugin's row under `config` in the profile's `cordis.patch.yml`, for example `config: { timeoutSeconds: 300 }` for a 300-second wait. Out-of-range values fail loudly at load time. The three fixed features are switched off the same way, for example `config: { cardEnhancements: false }`; restate every key that row needs rather than only the changed one.
149
+
146
150
  ## Compatibility
147
151
 
148
152
  | Item | Version |
149
153
  |:---:|:---:|
150
- | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.1` |
154
+ | dsh | `>=0.2.1-rc.1 <=0.2.2-rc.2` |
151
155
  | Node.js | >= 20 |
152
156
 
153
157
  The Node.js requirement of the host dsh itself follows the release notes of the matching version.
@@ -160,7 +164,7 @@ Not on this page. At the timeout the plugin keeps your selections and typed text
160
164
 
161
165
  **Can the model see what I typed**
162
166
 
163
- It depends on the "Inject into the context" checkbox. When checked the draft reaches the model context with the tool result; when unchecked it stays in the UI only.
167
+ It depends on the "Inject into context" checkbox. When checked the draft reaches the model context with the tool result; when unchecked it stays in the UI only.
164
168
 
165
169
  **Why did the card disappear**
166
170
 
@@ -190,7 +194,7 @@ No. A timeout never selects an option and never submits a draft as a formal answ
190
194
 
191
195
  **Depends on the host UI**
192
196
 
193
- Cards and tool rows are located through host class-name suffixes, `data-question-key`, `data-chat-call-id` and `aria-checked`; host controls are recognised by their Chinese or English labels. The toolbar switch prefers the model selector's accessible name, falls back to structural placement inside the composer toolbar, then to a document-wide lookup, and logs one console.warn per reason instead of failing silently. If the host changes those structures or labels the matching enhancement stops working; the recognition labels and selectors live in the source constants file.
197
+ Cards and tool rows are located through host class-name suffixes, `data-question-key`, `data-chat-call-id` and `aria-checked`; host controls are recognised by their Chinese or English labels (the Japanese `回答` is identical to the Chinese one, so that entry matches too); when restoring the host entry after settlement the plugin also recognises `查看回答` / `View answers` / `回答を表示`. The toolbar switch prefers the model selector's accessible name, falls back to structural placement inside the composer toolbar, then to a document-wide lookup, and logs one console.warn per reason instead of failing silently. If the host changes those structures or labels the matching enhancement stops working; the recognition labels and selectors live in the source constants file.
194
198
 
195
199
  **Depends on the host question projection**
196
200
 
@@ -220,6 +224,7 @@ dsh 0.2.2-rc.1 ships eight UI languages while the plugin recognises Chinese and
220
224
  - dsh 0.2.2-rc.1 pre-selects recommended options when a card opens, and the plugin strips those presets by matching the original option labels from the projection; in multiple choice, once you click any option the remaining presets are kept under the host's own submit semantics
221
225
  - Skipping every question without any selection or typed text counts as an empty draft, so that timeout closes the card
222
226
  - The draft is merged per question from three sources in this order: the host's persisted record, the live value of the question on screen, then the plugin's own snapshot; when the live value is read, selected labels come from the host's screen-reader text, which may drop suffixes such as "(Recommended)"
227
+ - On the macOS desktop app, dsh 0.2.2-rc.2 allows window dragging only inside header rows carrying `data-window-drag`, and the host automatically excludes drag on controls inside a `data-window-drag-controls` container; a custom overlay covering a drag row must declare `data-window-drag-exclude` to stay interactive, and `--dsh-frame-top-clearance` reserves a strip at the top. The plugin's draft panel is attached to the body and declares neither, so near the top of the window it may fall into the reserved strip. The panel holds no clickable controls, so the effect is positional only; the web client is unaffected
223
228
  - The timeout notice injected for the model is Chinese-only, so on an English UI the model still receives Chinese text
224
229
  - A draft over the 256 KiB per-report limit makes the UI read "Draft too large; not delivered", which does not count towards consecutive failures; after three consecutive failures that question is judged channel-unavailable, the plugin stops taking it over and the card returns to the host and stays answerable
225
230
 
package/dist/client.js CHANGED
@@ -74,7 +74,7 @@ const AUTO_INFINITE_LABEL_ZH = "问答自动无限等待";
74
74
  const AUTO_INFINITE_LABEL_EN = "Auto wait indefinitely";
75
75
  /** 常开开关的悬停提示(中文与英文) */
76
76
  const AUTO_INFINITE_TITLE_ZH = "开启后每次提问都自动进入无限等待, 关闭后回到插件的计时行为";
77
- const AUTO_INFINITE_TITLE_EN = "When on, every question waits indefinitely; when off, the plugin countdown applies";
77
+ const AUTO_INFINITE_TITLE_EN = "When on, every question enters indefinite wait automatically; when off, the plugin countdown applies";
78
78
  /** 常开开关按钮的类名与状态属性 */
79
79
  const AUTO_INFINITE_BUTTON_CLASS = "dqtp-auto-infinite";
80
80
  const AUTO_INFINITE_STATE_ATTRIBUTE = "data-dqtp-auto-infinite";
@@ -110,6 +110,11 @@ const ASK_REOPEN_LABELS = [
110
110
  ];
111
111
  /** 隐藏宿主控件时附加的类名 */
112
112
  const HIDDEN_CONTROL_CLASS = "dqtp-host-control-hidden";
113
+ /**
114
+ * 被插件按文案隐藏的宿主节点标记。
115
+ * 还原时只认这个标记, 不再复判当前文案: 宿主复用同一节点改写文案时也能还原。
116
+ */
117
+ const HIDDEN_WAIT_ATTRIBUTE = "data-dqtp-host-wait";
113
118
  /** 提问工具调用行的选择器(宿主 tool 行根节点) */
114
119
  const ASK_ROW_SELECTOR = "div[data-tool=\"ask_user_question\"]";
115
120
  /** 工具调用行的 callId 属性(宿主 ToolCall 包裹层) */
@@ -706,6 +711,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
706
711
  const callActive = /* @__PURE__ */ new Set();
707
712
  const callTouchedAt = /* @__PURE__ */ new Map();
708
713
  const draftTooLarge = /* @__PURE__ */ new Set();
714
+ const draftTooLargeAt = /* @__PURE__ */ new Map();
709
715
  const callSessions = /* @__PURE__ */ new Map();
710
716
  const readLiveSelected = (card, callId) => {
711
717
  const index = readProgress(card)?.index ?? 0;
@@ -747,6 +753,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
747
753
  for (const id of deferred.keys()) ids.add(id);
748
754
  for (const id of draftSyncFailures.keys()) ids.add(id);
749
755
  for (const id of draftTooLarge.keys()) ids.add(id);
756
+ for (const id of draftTooLargeAt.keys()) ids.add(id);
750
757
  for (const id of dismissedCallIds.keys()) ids.add(id);
751
758
  for (const id of optionInteractions.keys()) ids.add(id);
752
759
  return [...ids];
@@ -771,6 +778,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
771
778
  callActive.delete(callId);
772
779
  callTouchedAt.delete(callId);
773
780
  draftTooLarge.delete(callId);
781
+ draftTooLargeAt.delete(callId);
774
782
  dismissedCallIds.delete(callId);
775
783
  lastDrafts.delete(callId);
776
784
  };
@@ -832,6 +840,12 @@ function installQuestionTimeoutAdapter(ctx, source) {
832
840
  actions.insertBefore(element, actions.firstChild);
833
841
  return element;
834
842
  };
843
+ let countdownWarned = false;
844
+ const warnCountdownOnce = () => {
845
+ if (countdownWarned) return;
846
+ countdownWarned = true;
847
+ console.warn("[question-timeout-protection] 卡片右上角找不到操作区, 无法插入倒计时, 这张卡片保持宿主原样");
848
+ };
835
849
  const ensureInfiniteButton = (card, countdown) => {
836
850
  const actions = card.querySelector(HEADER_ACTIONS_SELECTOR);
837
851
  if (!(actions instanceof HTMLElement)) return void 0;
@@ -996,6 +1010,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
996
1010
  const restoreCard = (card) => {
997
1011
  card.classList.remove(HIDDEN_CONTROL_CLASS);
998
1012
  for (const element of Array.from(card.querySelectorAll("." + HIDDEN_CONTROL_CLASS))) element.classList.remove(HIDDEN_CONTROL_CLASS);
1013
+ for (const element of Array.from(card.querySelectorAll("[data-dqtp-host-wait]"))) element.removeAttribute(HIDDEN_WAIT_ATTRIBUTE);
999
1014
  for (const element of Array.from(card.querySelectorAll("[data-dqtp-countdown], button.dqtp-infinite-wait"))) element.remove();
1000
1015
  restoreDisabled(card);
1001
1016
  card.classList.remove(CARD_LOCKED_CLASS);
@@ -1018,6 +1033,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1018
1033
  if (text === "" || text.length > 40) continue;
1019
1034
  if (!HOST_WAIT_PATTERNS.some((pattern) => text.includes(pattern))) continue;
1020
1035
  element.classList.add(HIDDEN_CONTROL_CLASS);
1036
+ element.setAttribute(HIDDEN_WAIT_ATTRIBUTE, "");
1021
1037
  }
1022
1038
  }
1023
1039
  const decorateCard = (card, identity) => {
@@ -1056,10 +1072,15 @@ function installQuestionTimeoutAdapter(ctx, source) {
1056
1072
  return;
1057
1073
  }
1058
1074
  restoredCards.delete(card);
1075
+ const countdown = ensureCountdown(card, key);
1076
+ if (countdown === void 0) {
1077
+ warnCountdownOnce();
1078
+ restoreCardOnce(card, key, "no-countdown");
1079
+ return;
1080
+ }
1059
1081
  hideHostWaitStatus(card);
1060
1082
  hideHostWaitText(card);
1061
1083
  hideHostControls(card);
1062
- const countdown = ensureCountdown(card, key);
1063
1084
  if (countdown !== void 0) {
1064
1085
  let remainingMs;
1065
1086
  if (frozen !== void 0) remainingMs = frozen;
@@ -1266,6 +1287,13 @@ function installQuestionTimeoutAdapter(ctx, source) {
1266
1287
  const button = findHostReopen(row);
1267
1288
  if (button !== void 0) button.classList.remove(HIDDEN_CONTROL_CLASS);
1268
1289
  };
1290
+ const showHostWaitText = (row) => {
1291
+ for (const element of Array.from(row.querySelectorAll("[data-dqtp-host-wait]"))) {
1292
+ if (!(element instanceof HTMLElement)) continue;
1293
+ element.classList.remove(HIDDEN_CONTROL_CLASS);
1294
+ element.removeAttribute(HIDDEN_WAIT_ATTRIBUTE);
1295
+ }
1296
+ };
1269
1297
  const decoratedRows = /* @__PURE__ */ new WeakMap();
1270
1298
  const decorateRow = (row) => {
1271
1299
  const callId = resolveCallId(row);
@@ -1273,7 +1301,10 @@ function installQuestionTimeoutAdapter(ctx, source) {
1273
1301
  const plain = !timedOut.has(callId) && !passive.has(callId) && !drafts.has(callId);
1274
1302
  const signature = callId + (row.querySelector("button.dqtp-question-bubble") !== null ? "1" : "0") + (timedOut.has(callId) ? "T" : "-") + (passive.has(callId) ? "P" : "-");
1275
1303
  if (plain && decoratedRows.get(row) === signature) return;
1276
- if (!timedOut.has(callId)) showHostReopen(row);
1304
+ if (!timedOut.has(callId)) {
1305
+ showHostReopen(row);
1306
+ showHostWaitText(row);
1307
+ }
1277
1308
  const button = ensureBubble(row);
1278
1309
  if (button === void 0) return;
1279
1310
  if (passive.has(callId)) {
@@ -1324,6 +1355,11 @@ function installQuestionTimeoutAdapter(ctx, source) {
1324
1355
  if (Date.now() - ignoredAt < DRAFT_IGNORED_RETRY_MS) return;
1325
1356
  draftIgnored.delete(identity.callId);
1326
1357
  }
1358
+ const tooLargeAt = draftTooLargeAt.get(identity.callId);
1359
+ if (tooLargeAt !== void 0) {
1360
+ if (Date.now() - tooLargeAt < 5e3) return;
1361
+ draftTooLargeAt.delete(identity.callId);
1362
+ }
1327
1363
  if (timedOut.has(identity.callId) || passive.has(identity.callId)) return;
1328
1364
  if (!callActive.has(identity.callId)) return;
1329
1365
  rememberCallSession(identity);
@@ -1354,6 +1390,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1354
1390
  draftIgnored.set(callId, Date.now());
1355
1391
  return;
1356
1392
  }
1393
+ draftTooLargeAt.delete(callId);
1357
1394
  if (draftTooLarge.delete(callId)) {
1358
1395
  const card = findCard(identity);
1359
1396
  if (card !== void 0) decorateCard(card, identity);
@@ -1362,6 +1399,7 @@ function installQuestionTimeoutAdapter(ctx, source) {
1362
1399
  }
1363
1400
  if (settled) return;
1364
1401
  if (reply.reason === "too-large") {
1402
+ draftTooLargeAt.set(identity.callId, Date.now());
1365
1403
  if (!draftTooLarge.has(identity.callId)) {
1366
1404
  draftTooLarge.add(identity.callId);
1367
1405
  console.warn("[question-timeout-protection] 草稿快照超过通道上限, 本次未能送达");
@@ -1652,6 +1690,11 @@ function installQuestionTimeoutAdapter(ctx, source) {
1652
1690
  }
1653
1691
  if (enhancementOn) {
1654
1692
  for (const root of roots) for (const row of Array.from(root.querySelectorAll(ASK_ROW_SELECTOR))) if (row instanceof HTMLElement) decorateRow(row);
1693
+ } else for (const root of roots) for (const row of Array.from(root.querySelectorAll(ASK_ROW_SELECTOR))) {
1694
+ if (!(row instanceof HTMLElement)) continue;
1695
+ showHostReopen(row);
1696
+ showHostWaitText(row);
1697
+ for (const bubble of Array.from(row.querySelectorAll("button.dqtp-question-bubble"))) bubble.remove();
1655
1698
  }
1656
1699
  repositionPanel();
1657
1700
  };
@@ -1740,7 +1783,7 @@ const ZH = {
1740
1783
  fixedKeepLabel: "界面保留草稿",
1741
1784
  fixedKeepDesc: "超时后把已选选项与已输入内容记入提问气泡, 可在气泡里只读查看",
1742
1785
  cardEnhancementsLabel: "卡片增强",
1743
- cardEnhancementsDesc: "右上角倒计时与警示闪烁, 单选选中底色, 提问标识气泡; 只影响界面装饰",
1786
+ cardEnhancementsDesc: "右上角倒计时与警示闪烁, 单选选项的方形标号填充底色, 提问标识气泡; 只影响界面装饰",
1744
1787
  infiniteWaitLabel: "无限等待",
1745
1788
  infiniteWaitDesc: "倒计时右侧新增「无限等待」按钮, 点击后本次问答倒计时暂停, 直到用户提交",
1746
1789
  draftFallbackLabel: "超时草稿兜底",
@@ -1754,13 +1797,13 @@ const EN = {
1754
1797
  fallbackSection: "Timeout fallback",
1755
1798
  fallbackNote: "What happens to the content the user already typed once the wait expires",
1756
1799
  injectLabel: "Inject into context",
1757
- injectDesc: "The draft snapshot is sent to the server before the timeout and comes back per question in the tool result into the model context, then the model decides whether to ask again",
1800
+ injectDesc: "The draft snapshot is sent to the server before the timeout; on expiry it comes back with the tool result per question and enters the model context, so the model can decide whether to ask again",
1758
1801
  fixedSection: "Fixed features",
1759
1802
  fixedNote: "Follows the plugin's enabled state and cannot be turned off separately",
1760
1803
  fixedKeepLabel: "Keep the draft in the UI",
1761
1804
  fixedKeepDesc: "At timeout, records the selected options and typed text into the question bubble, where they can be viewed read-only",
1762
1805
  cardEnhancementsLabel: "Card enhancements",
1763
- cardEnhancementsDesc: "Top-right countdown with warning blink, selected-option background and question bubble; affects decoration only",
1806
+ cardEnhancementsDesc: "Top-right countdown with warning flash, a background fill on the square marker of the selected single-choice option, and the question bubble; affects decoration only",
1764
1807
  infiniteWaitLabel: "Wait indefinitely",
1765
1808
  infiniteWaitDesc: "Adds a \"Wait indefinitely\" button next to the countdown; clicking it pauses the countdown of this question until the user submits",
1766
1809
  draftFallbackLabel: "Draft fallback at timeout",
package/dist/index.mjs CHANGED
@@ -314,9 +314,11 @@ function handleStateRequest(request, response) {
314
314
  }
315
315
  });
316
316
  request.on("error", (error) => {
317
+ if (oversized) return;
317
318
  console.warn("[question-timeout-protection] 状态上报请求体读取失败, 本次上报已丢弃", String(error));
318
319
  });
319
320
  request.on("aborted", () => {
321
+ if (oversized) return;
320
322
  console.warn("[question-timeout-protection] 状态上报请求被客户端中断, 本次上报已丢弃");
321
323
  });
322
324
  request.on("end", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-question-timeout-protection",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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.1"
14
+ "dsh": ">=0.2.1-rc.1 <=0.2.2-rc.2"
15
15
  },
16
16
  "main": "./dist/index.mjs",
17
17
  "types": "./dist/index.d.mts",
@@ -25,6 +25,9 @@
25
25
  },
26
26
  "./package.json": "./package.json"
27
27
  },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
28
31
  "files": [
29
32
  "dist",
30
33
  "COPYRIGHT",
@@ -48,23 +51,23 @@
48
51
  },
49
52
  "peerDependencies": {
50
53
  "@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
51
- "@deepseek-ai/dsh-agent": ">=0.2.1-rc.1 <=0.2.2-rc.1",
52
- "@deepseek-ai/dsh-tools": ">=0.2.1-rc.1 <=0.2.2-rc.1",
53
- "@deepseek-ai/dsh-user-questions": ">=0.2.1-rc.1 <=0.2.2-rc.1"
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
57
  },
55
58
  "devDependencies": {
56
59
  "@deepseek-ai/cordis": "~4.1.0",
57
- "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
58
- "@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
59
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.1",
60
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1",
61
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.1",
62
- "@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.1",
63
- "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
64
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
65
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
66
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
67
- "@deepseek-ai/dsh-user-questions": "0.2.2-rc.1",
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",
68
71
  "@types/node": "^26.2.0",
69
72
  "@types/react": "^18.3.31",
70
73
  "react": "^18.2.0",
@@ -1,8 +1,8 @@
1
1
  [meta]
2
- for=v0.1.1
2
+ for=v0.1.2
3
3
  lang=zh-CN
4
4
  name=简体中文
5
- endtime=2026-11-06 14:15:00+08:00
5
+ endtime=2026-11-12 18:50:00+08:00
6
6
 
7
7
  [translation]
8
8
  settings.settingsSummary=提问超时保护
@@ -15,7 +15,7 @@ settings.fixedNote=随插件启用状态生效, 不可单独关闭
15
15
  settings.fixedKeepLabel=界面保留草稿
16
16
  settings.fixedKeepDesc=超时后把已选选项与已输入内容记入提问气泡, 可在气泡里只读查看
17
17
  settings.cardEnhancementsLabel=卡片增强
18
- settings.cardEnhancementsDesc=右上角倒计时与警示闪烁, 单选选中底色, 提问标识气泡; 只影响界面装饰
18
+ settings.cardEnhancementsDesc=右上角倒计时与警示闪烁, 单选选项的方形标号填充底色, 提问标识气泡; 只影响界面装饰
19
19
  settings.infiniteWaitLabel=无限等待
20
20
  settings.infiniteWaitDesc=倒计时右侧新增「无限等待」按钮, 点击后本次问答倒计时暂停, 直到用户提交
21
21
  settings.draftFallbackLabel=超时草稿兜底
@@ -1,21 +1,21 @@
1
1
  [meta]
2
- for=v0.1.1
2
+ for=v0.1.2
3
3
  lang=en-US
4
4
  name=English (US)
5
- endtime=2026-11-06 14:15:00+08:00
5
+ endtime=2026-11-12 19:20:00+08:00
6
6
 
7
7
  [translation]
8
8
  settings.settingsSummary=Question timeout protection
9
9
  settings.fallbackSection=Timeout fallback
10
10
  settings.fallbackNote=What happens to the content the user already typed once the wait expires
11
11
  settings.injectLabel=Inject into context
12
- settings.injectDesc=The draft snapshot is sent to the server before the timeout and comes back per question in the tool result into the model context, then the model decides whether to ask again
12
+ settings.injectDesc=The draft snapshot is sent to the server before the timeout; on expiry it comes back with the tool result per question and enters the model context, so the model can decide whether to ask again
13
13
  settings.fixedSection=Fixed features
14
14
  settings.fixedNote=Follows the plugin's enabled state and cannot be turned off separately
15
15
  settings.fixedKeepLabel=Keep the draft in the UI
16
16
  settings.fixedKeepDesc=At timeout, records the selected options and typed text into the question bubble, where they can be viewed read-only
17
17
  settings.cardEnhancementsLabel=Card enhancements
18
- settings.cardEnhancementsDesc=Top-right countdown with warning blink, selected-option background and question bubble; affects decoration only
18
+ settings.cardEnhancementsDesc=Top-right countdown with warning flash, a background fill on the square marker of the selected single-choice option, and the question bubble; affects decoration only
19
19
  settings.infiniteWaitLabel=Wait indefinitely
20
20
  settings.infiniteWaitDesc=Adds a "Wait indefinitely" button next to the countdown; clicking it pauses the countdown of this question until the user submits
21
21
  settings.draftFallbackLabel=Draft fallback at timeout
@@ -31,7 +31,7 @@ control.infiniteWait=Wait indefinitely
31
31
  control.autoInfiniteLabel=Auto wait indefinitely
32
32
  control.autoInfiniteOn=On
33
33
  control.autoInfiniteOff=Off
34
- control.autoInfiniteTitle=When on, every question waits indefinitely; when off, the plugin countdown applies
34
+ control.autoInfiniteTitle=When on, every question enters indefinite wait automatically; when off, the plugin countdown applies
35
35
  bubble.draftLabel=Question · timed-out draft
36
36
  draft.selected=Selected: {items}
37
37
  draft.custom=Additional: {text}
@@ -1,8 +1,8 @@
1
1
  [meta]
2
- for=v0.1.1
2
+ for=v0.1.2
3
3
  lang=zh-CN
4
4
  name=简体中文
5
- endtime=2026-11-06 14:15:00+08:00
5
+ endtime=2026-11-12 18:50:00+08:00
6
6
 
7
7
  [translation]
8
8
  settings.settingsSummary=提问超时保护
@@ -15,7 +15,7 @@ settings.fixedNote=随插件启用状态生效, 不可单独关闭
15
15
  settings.fixedKeepLabel=界面保留草稿
16
16
  settings.fixedKeepDesc=超时后把已选选项与已输入内容记入提问气泡, 可在气泡里只读查看
17
17
  settings.cardEnhancementsLabel=卡片增强
18
- settings.cardEnhancementsDesc=右上角倒计时与警示闪烁, 单选选中底色, 提问标识气泡; 只影响界面装饰
18
+ settings.cardEnhancementsDesc=右上角倒计时与警示闪烁, 单选选项的方形标号填充底色, 提问标识气泡; 只影响界面装饰
19
19
  settings.infiniteWaitLabel=无限等待
20
20
  settings.infiniteWaitDesc=倒计时右侧新增「无限等待」按钮, 点击后本次问答倒计时暂停, 直到用户提交
21
21
  settings.draftFallbackLabel=超时草稿兜底