dsh-question-timeout-protection 0.0.0-stage → 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.
@@ -0,0 +1,76 @@
1
+ import Schema from "@deepseek-ai/schemastery";
2
+ import { Context, Volatile } from "@deepseek-ai/cordis";
3
+ /**
4
+ * 提问超时后的兜底范围:
5
+ * ui 仅保留到界面;context 仅注入到对话上下文;both 两者同时做。
6
+ */
7
+ declare const FALLBACK_MODES: readonly ["ui", "context", "both"];
8
+ /** 兜底范围类型 */
9
+ type FallbackMode = (typeof FALLBACK_MODES)[number];
10
+ interface Config {
11
+ /** 提问超时后的兜底范围: 仅界面、仅上下文或两者 */
12
+ fallback: Volatile<FallbackMode>;
13
+ /** 倒计时剩余多少秒时进入红字闪烁警示(默认 5) */
14
+ warningSeconds: Volatile<number>;
15
+ /** 提问等待时长(秒),仅在本插件接管提问等待时生效(默认 120) */
16
+ timeoutSeconds: Volatile<number>;
17
+ /** 是否启用卡片增强(倒计时文案、无限等待按钮、单选底色、提问气泡、隐藏宿主控件) */
18
+ cardEnhancements: Volatile<boolean>;
19
+ /** 是否提供「无限等待」入口与点击后的阻塞行为 */
20
+ infiniteWait: Volatile<boolean>;
21
+ /** 是否在超时后保存草稿并按兜底范围处理 */
22
+ draftFallback: Volatile<boolean>;
23
+ }
24
+ declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
25
+ fallback: Schema<"ui" | "context" | "both", "ui" | "context" | "both", "volatile-defined">;
26
+ warningSeconds: Schema<number, number, "volatile-defined">;
27
+ timeoutSeconds: Schema<number, number, "volatile-defined">;
28
+ cardEnhancements: Schema<boolean, boolean, "volatile-defined">;
29
+ infiniteWait: Schema<boolean, boolean, "volatile-defined">;
30
+ draftFallback: Schema<boolean, boolean, "volatile-defined">;
31
+ }>>, Schemastery.ObjectT<NoInfer<{
32
+ fallback: Schema<"ui" | "context" | "both", "ui" | "context" | "both", "volatile-defined">;
33
+ warningSeconds: Schema<number, number, "volatile-defined">;
34
+ timeoutSeconds: Schema<number, number, "volatile-defined">;
35
+ cardEnhancements: Schema<boolean, boolean, "volatile-defined">;
36
+ infiniteWait: Schema<boolean, boolean, "volatile-defined">;
37
+ draftFallback: Schema<boolean, boolean, "volatile-defined">;
38
+ }>>, "plain">;
39
+ declare class QuestionTimeoutService {
40
+ private readonly ctx;
41
+ private readonly config;
42
+ private readonly perAgent;
43
+ constructor(ctx: Context, config: Config);
44
+ /** 建立 agent 创建监听,并为已存在的 agent 补齐工具注册 */
45
+ start(): void;
46
+ /** 释放插件持有的全部工具注册 */
47
+ dispose(): void;
48
+ /** 释放并忘掉一个 agent 的工具注册 */
49
+ private forget;
50
+ /** 在一个 agent 的作用域注册同名提问工具, 同一 agent 只注册一次 */
51
+ private registerFor;
52
+ }
53
+ interface TranslationTable {
54
+ [key: string]: string;
55
+ }
56
+ declare class TranslationManager {
57
+ private tables;
58
+ private language;
59
+ private readonly warned;
60
+ private readonly failedAt;
61
+ /** 清空已加载的翻译表, 供测试或热更新后强制重读 */
62
+ reload(): void;
63
+ /** 加载指定语言的翻译表; 读取失败时返回空表但不缓存, 便于修复后自动恢复 */
64
+ load(locale: string): TranslationTable;
65
+ /** 切换当前语言 */
66
+ setLanguage(locale: string): void;
67
+ /** 取翻译文本,未命中回退默认语言,仍未命中返回键名 */
68
+ translate(key: string): string;
69
+ }
70
+ /** 翻译文本快捷方法(使用默认实例) */
71
+ declare const translation: TranslationManager;
72
+ declare const name = "dsh-question-timeout-protection";
73
+ declare const inject: string[];
74
+ /** 插件装配入口 */
75
+ declare function apply(ctx: Context, config: Config): void;
76
+ export { Config, type FallbackMode, QuestionTimeoutService, TranslationManager, apply, inject, name, translation };