@talex-touch/utils 1.0.31 → 1.0.32

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 (112) hide show
  1. package/animation/window-node.ts +15 -12
  2. package/animation/window.ts +19 -15
  3. package/auth/clerk-types.ts +1 -1
  4. package/auth/index.ts +1 -1
  5. package/auth/useAuthState.ts +6 -5
  6. package/auth/useClerkConfig.ts +4 -4
  7. package/auth/useClerkProvider.ts +3 -2
  8. package/channel/index.ts +23 -22
  9. package/common/file-scan-constants.ts +137 -121
  10. package/common/file-scan-utils.ts +48 -27
  11. package/common/index.ts +3 -3
  12. package/common/search/gather.ts +1 -1
  13. package/common/search/index.ts +5 -6
  14. package/common/storage/constants.ts +3 -2
  15. package/common/storage/entity/app-settings.ts +5 -3
  16. package/common/storage/entity/shortcut-settings.ts +10 -10
  17. package/common/storage/shortcut-storage.ts +6 -4
  18. package/common/utils/file.ts +14 -6
  19. package/common/utils/index.ts +62 -52
  20. package/common/utils/polling.ts +87 -84
  21. package/common/utils/task-queue.ts +11 -10
  22. package/common/utils/time.ts +50 -47
  23. package/common/utils/timing.ts +41 -37
  24. package/core-box/builder/index.ts +1 -1
  25. package/core-box/builder/tuff-builder.ts +254 -229
  26. package/core-box/index.ts +3 -6
  27. package/core-box/preview/index.ts +1 -0
  28. package/core-box/preview/types.ts +43 -0
  29. package/core-box/tuff/index.ts +1 -1
  30. package/core-box/tuff/tuff-dsl.ts +328 -266
  31. package/electron/clipboard-helper.ts +20 -12
  32. package/electron/download-manager.ts +43 -42
  33. package/electron/env-tool.ts +19 -18
  34. package/electron/file-parsers/index.ts +2 -2
  35. package/electron/file-parsers/parsers/text-parser.ts +15 -14
  36. package/electron/file-parsers/registry.ts +9 -7
  37. package/electron/file-parsers/types.ts +4 -4
  38. package/electron/index.ts +1 -1
  39. package/eventbus/index.ts +11 -11
  40. package/index.ts +5 -4
  41. package/intelligence/client.ts +87 -0
  42. package/intelligence/index.ts +1 -0
  43. package/package.json +14 -14
  44. package/permission/index.ts +8 -8
  45. package/plugin/channel.ts +77 -68
  46. package/plugin/index.ts +96 -82
  47. package/plugin/install.ts +8 -8
  48. package/plugin/log/types.ts +5 -5
  49. package/plugin/node/index.ts +1 -1
  50. package/plugin/node/logger-manager.ts +14 -11
  51. package/plugin/node/logger.ts +8 -8
  52. package/plugin/plugin-source.ts +11 -11
  53. package/plugin/preload.ts +1 -1
  54. package/plugin/providers/registry.ts +8 -7
  55. package/plugin/providers/types.ts +6 -6
  56. package/plugin/sdk/channel.ts +20 -20
  57. package/plugin/sdk/clipboard.ts +8 -6
  58. package/plugin/sdk/common.ts +10 -6
  59. package/plugin/sdk/core-box.ts +2 -3
  60. package/plugin/sdk/division-box.ts +266 -0
  61. package/plugin/sdk/enum/bridge-event.ts +1 -1
  62. package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
  63. package/plugin/sdk/features.ts +34 -26
  64. package/plugin/sdk/hooks/bridge.ts +3 -6
  65. package/plugin/sdk/hooks/index.ts +1 -1
  66. package/plugin/sdk/hooks/life-cycle.ts +4 -10
  67. package/plugin/sdk/index.ts +8 -7
  68. package/plugin/sdk/service/index.ts +3 -3
  69. package/plugin/sdk/storage.ts +4 -4
  70. package/plugin/sdk/system.ts +1 -1
  71. package/plugin/sdk/types.ts +147 -141
  72. package/plugin/sdk/window/index.ts +8 -5
  73. package/preload/loading.ts +6 -6
  74. package/preload/renderer.ts +4 -2
  75. package/renderer/hooks/arg-mapper.ts +1 -2
  76. package/renderer/hooks/index.ts +2 -0
  77. package/renderer/hooks/initialize.ts +10 -8
  78. package/renderer/hooks/performance.ts +4 -4
  79. package/renderer/hooks/use-channel.ts +150 -0
  80. package/renderer/hooks/use-intelligence.ts +236 -0
  81. package/renderer/index.ts +6 -2
  82. package/renderer/ref.ts +32 -36
  83. package/renderer/slots.ts +29 -26
  84. package/renderer/storage/app-settings.ts +16 -6
  85. package/renderer/storage/base-storage.ts +222 -114
  86. package/renderer/storage/index.ts +3 -0
  87. package/renderer/storage/intelligence-storage.ts +215 -0
  88. package/renderer/storage/openers.ts +13 -3
  89. package/renderer/touch-sdk/env.ts +41 -41
  90. package/renderer/touch-sdk/index.ts +1 -1
  91. package/renderer/touch-sdk/terminal.ts +5 -5
  92. package/renderer/touch-sdk/utils.ts +4 -3
  93. package/search/levenshtein-utils.ts +11 -11
  94. package/search/types.ts +102 -102
  95. package/service/index.ts +11 -11
  96. package/service/protocol/index.ts +217 -14
  97. package/types/division-box.ts +248 -0
  98. package/types/download.ts +72 -34
  99. package/types/index.ts +3 -1
  100. package/types/intelligence.ts +413 -0
  101. package/types/modules/base.ts +16 -16
  102. package/types/modules/index.ts +1 -1
  103. package/types/modules/module-lifecycle.ts +21 -21
  104. package/types/modules/module-manager.ts +11 -11
  105. package/types/modules/module.ts +16 -16
  106. package/types/storage.ts +0 -1
  107. package/types/touch-app-core.ts +32 -32
  108. package/types/update.ts +79 -21
  109. package/core-box/README.md +0 -218
  110. package/core-box/builder/tuff-builder.example.ts.bak +0 -258
  111. package/core-box/run-tests.sh +0 -7
  112. package/core-box/search.ts +0 -1
@@ -42,63 +42,65 @@
42
42
  * };
43
43
  * ```
44
44
  */
45
+ import type { ITuffIcon } from '../../types/icon'
46
+
45
47
  export interface TuffItem {
46
48
  /**
47
49
  * 唯一标识符
48
50
  * @description 唯一标识符,必须由创建者提供
49
51
  * @required
50
52
  */
51
- id: string;
53
+ id: string
52
54
 
53
55
  /**
54
56
  * 数据来源信息
55
57
  * @description 定义项目的来源,用于权限控制、缓存策略和安全隔离
56
58
  * @required
57
59
  */
58
- source: TuffSource;
60
+ source: TuffSource
59
61
 
60
62
  /**
61
63
  * 项目类型分类
62
64
  * @description 影响展示方式和处理逻辑,系统会根据类型提供默认图标和行为
63
65
  */
64
- kind?: TuffItemKind;
66
+ kind?: TuffItemKind
65
67
 
66
68
  /**
67
69
  * 渲染配置
68
70
  * @description 控制项目的视觉展示方式
69
71
  * @required
70
72
  */
71
- render: TuffRender;
73
+ render: TuffRender
72
74
 
73
75
  /**
74
76
  * 图标定义
75
77
  * @description 项目的视觉标识,会覆盖 render.basic.icon
76
78
  */
77
- icon?: TuffIcon;
79
+ icon?: TuffIcon
78
80
 
79
81
  /**
80
82
  * 交互行为定义
81
83
  * @description 定义项目支持的操作和交互方式
82
84
  */
83
- actions?: TuffAction[];
85
+ actions?: TuffAction[]
84
86
 
85
87
  /**
86
88
  * 匹配与评分信息
87
89
  * @description 用于搜索结果排序和推荐算法
88
90
  */
89
- scoring?: TuffScoring;
91
+ scoring?: TuffScoring
90
92
 
91
93
  /**
92
94
  * 扩展元数据
93
95
  * @description 携带额外的项目相关信息
94
96
  */
95
- meta?: TuffMeta;
97
+ meta?: TuffMeta
96
98
 
97
99
  /**
98
100
  * 上下文信息
99
101
  * @description 用于 AI 推荐和关联分析的上下文数据
100
102
  */
101
- context?: TuffContext;
103
+ context?: TuffContext
102
104
  }
103
105
 
104
106
  // ==================== 数据来源定义 ====================
@@ -116,32 +118,32 @@ export interface TuffSource {
116
118
  * @description 定义数据的基本来源类别
117
119
  * @required
118
120
  */
119
- type: TuffSourceType;
121
+ type: TuffSourceType
120
122
 
121
123
  /**
122
124
  * 来源标识符
123
125
  * @description 如插件ID、模块名等,用于唯一标识来源
124
126
  * @required
125
127
  */
126
- id: string;
128
+ id: string
127
129
 
128
130
  /**
129
131
  * 来源名称
130
132
  * @description 用于用户界面展示的友好名称
131
133
  */
132
- name?: string;
134
+ name?: string
133
135
 
134
136
  /**
135
137
  * 来源版本
136
138
  * @description 数据提供者的版本信息,用于兼容性检查
137
139
  */
138
- version?: string;
140
+ version?: string
139
141
 
140
142
  /**
141
143
  * 权限级别
142
144
  * @description 定义该来源的信任级别和权限范围
143
145
  */
144
- permission?: TuffPermissionLevel;
146
+ permission?: TuffPermissionLevel
145
147
  }
146
148
 
147
149
  /**
@@ -150,17 +152,17 @@ export interface TuffSource {
150
152
  * @description
151
153
  * 定义数据的基本来源类别,系统据此应用不同的安全策略和处理逻辑
152
154
  */
153
- export type TuffSourceType =
154
- | 'system' // 系统内置,最高信任级别
155
- | 'plugin' // 本地插件,受插件权限控制
156
- | 'remote' // 远程服务,需网络访问权限
157
- | 'ai' // AI 推荐,基于机器学习生成
158
- | 'history' // 历史记录,基于用户过往行为
159
- | 'notification' // 系统通知,来自系统事件
160
- | 'workflow' // 工作流,用户自定义流程
161
- | 'file' // 文件系统,本地文件
162
- | 'application' // 应用程序,可启动的软件
163
- | 'service'; // 系统服务,后台运行的程序
155
+ export type TuffSourceType
156
+ = | 'system' // 系统内置,最高信任级别
157
+ | 'plugin' // 本地插件,受插件权限控制
158
+ | 'remote' // 远程服务,需网络访问权限
159
+ | 'ai' // AI 推荐,基于机器学习生成
160
+ | 'history' // 历史记录,基于用户过往行为
161
+ | 'notification' // 系统通知,来自系统事件
162
+ | 'workflow' // 工作流,用户自定义流程
163
+ | 'file' // 文件系统,本地文件
164
+ | 'application' // 应用程序,可启动的软件
165
+ | 'service' // 系统服务,后台运行的程序
164
166
 
165
167
  /**
166
168
  * 权限级别
@@ -168,11 +170,11 @@ export type TuffSourceType =
168
170
  * @description
169
171
  * 定义数据来源的信任级别和权限范围,影响允许执行的操作
170
172
  */
171
- export type TuffPermissionLevel =
172
- | 'safe' // 安全级别,仅允许基本展示和无害操作
173
- | 'trusted' // 信任级别,允许访问用户数据但有限制
174
- | 'elevated' // 提升级别,允许更广泛的系统访问
175
- | 'system'; // 系统级别,完全访问权限
173
+ export type TuffPermissionLevel
174
+ = | 'safe' // 安全级别,仅允许基本展示和无害操作
175
+ | 'trusted' // 信任级别,允许访问用户数据但有限制
176
+ | 'elevated' // 提升级别,允许更广泛的系统访问
177
+ | 'system' // 系统级别,完全访问权限
176
178
 
177
179
  // ==================== 项目类型分类 ====================
178
180
 
@@ -183,37 +185,38 @@ export type TuffPermissionLevel =
183
185
  * 定义项目的语义类型,系统据此决定默认图标、行为、分组等。
184
186
  * 支持自定义扩展,可通过字符串字面量类型添加新的类型。
185
187
  */
186
- export type TuffItemKind =
188
+ export type TuffItemKind
187
189
  // 应用与程序
188
- | 'app' // 应用程序,可启动的软件
189
- | 'command' // 系统命令,终端或系统级指令
190
- | 'script' // 脚本文件,可执行的代码文件
191
- | 'workflow' // 工作流,一系列自动化步骤
190
+ = | 'app' // 应用程序,可启动的软件
191
+ | 'command' // 系统命令,终端或系统级指令
192
+ | 'script' // 脚本文件,可执行的代码文件
193
+ | 'workflow' // 工作流,一系列自动化步骤
194
+ | 'preview' // 直接预览卡片
192
195
 
193
196
  // 文件与资源
194
- | 'file' // 普通文件,未指定具体类型的文件
195
- | 'folder' // 文件夹,包含其他文件的目录
196
- | 'document' // 文档类文件,如文本、表格、演示文稿等
197
- | 'image' // 图片文件,各种图像格式
198
- | 'video' // 视频文件,影片和动态图像
199
- | 'audio' // 音频文件,声音和音乐
197
+ | 'file' // 普通文件,未指定具体类型的文件
198
+ | 'folder' // 文件夹,包含其他文件的目录
199
+ | 'document' // 文档类文件,如文本、表格、演示文稿等
200
+ | 'image' // 图片文件,各种图像格式
201
+ | 'video' // 视频文件,影片和动态图像
202
+ | 'audio' // 音频文件,声音和音乐
200
203
 
201
204
  // 网络与链接
202
- | 'url' // 网页链接,可访问的网络地址
203
- | 'bookmark' // 书签,保存的网页引用
204
- | 'search-result' // 搜索结果,来自搜索引擎
205
+ | 'url' // 网页链接,可访问的网络地址
206
+ | 'bookmark' // 书签,保存的网页引用
207
+ | 'search-result' // 搜索结果,来自搜索引擎
205
208
 
206
209
  // 交互与功能
207
- | 'action' // 功能操作,触发特定行为
208
- | 'setting' // 设置项,配置选项
209
- | 'feature' // 系统功能,内置能力
210
+ | 'action' // 功能操作,触发特定行为
211
+ | 'setting' // 设置项,配置选项
212
+ | 'feature' // 系统功能,内置能力
210
213
 
211
214
  // 通信与人员
212
- | 'contact' // 联系人,人员信息
213
- | 'notification' // 通知消息,系统或应用通知
215
+ | 'contact' // 联系人,人员信息
216
+ | 'notification' // 通知消息,系统或应用通知
214
217
 
215
218
  // 扩展支持
216
- | (string & {}); // 允许自定义扩展类型
219
+ | (string & {}) // 允许自定义扩展类型
217
220
 
218
221
  // ==================== 渲染系统 ====================
219
222
 
@@ -230,49 +233,49 @@ export interface TuffRender {
230
233
  * @description 决定使用哪种渲染策略
231
234
  * @required
232
235
  */
233
- mode: TuffRenderMode;
236
+ mode: TuffRenderMode
234
237
 
235
238
  /**
236
239
  * 基础渲染信息
237
240
  * @description mode='default' 时使用的基本渲染数据
238
241
  */
239
- basic?: TuffBasicRender;
242
+ basic?: TuffBasicRender
240
243
 
241
244
  /**
242
245
  * 自定义渲染内容
243
246
  * @description mode='custom' 时使用的自定义渲染配置
244
247
  */
245
- custom?: TuffCustomRender;
248
+ custom?: TuffCustomRender
246
249
 
247
250
  /**
248
251
  * 布局配置
249
252
  * @description 控制项目的布局方式和尺寸
250
253
  */
251
- layout?: TuffLayout;
254
+ layout?: TuffLayout
252
255
 
253
256
  /**
254
257
  * 预览配置
255
258
  * @description 定义悬停或点击时的预览内容
256
259
  */
257
- preview?: TuffPreview;
260
+ preview?: TuffPreview
258
261
 
259
262
  /**
260
263
  * 样式类名
261
264
  * @description 应用于渲染容器的 CSS 类名
262
265
  */
263
- className?: string;
266
+ className?: string
264
267
 
265
268
  /**
266
269
  * 内联样式
267
270
  * @description 应用于渲染容器的内联样式对象
268
271
  */
269
- style?: Record<string, string>;
272
+ style?: Record<string, string>
270
273
 
271
274
  /**
272
275
  * 补全
273
276
  * @description 用于补全的文本
274
277
  */
275
- completion?: string;
278
+ completion?: string
276
279
  }
277
280
 
278
281
  /**
@@ -281,11 +284,11 @@ export interface TuffRender {
281
284
  * @description
282
285
  * 定义项目的基本渲染策略,从简单到复杂
283
286
  */
284
- export type TuffRenderMode =
285
- | 'default' // 默认渲染(title + desc + icon)
286
- | 'rich' // 富文本渲染,支持格式化文本
287
- | 'card' // 卡片式渲染,适合图文混排
288
- | 'custom'; // 完全自定义,最大灵活性
287
+ export type TuffRenderMode
288
+ = | 'default' // 默认渲染(title + desc + icon)
289
+ | 'rich' // 富文本渲染,支持格式化文本
290
+ | 'card' // 卡片式渲染,适合图文混排
291
+ | 'custom' // 完全自定义,最大灵活性
289
292
 
290
293
  /**
291
294
  * 基础渲染信息
@@ -300,37 +303,37 @@ export interface TuffBasicRender {
300
303
  * @description 项目的主要标识文本
301
304
  * @required
302
305
  */
303
- title: string;
306
+ title: string
304
307
 
305
308
  /**
306
309
  * 副标题/描述
307
310
  * @description 对主标题的补充说明,通常显示在主标题下方
308
311
  */
309
- subtitle?: string;
312
+ subtitle?: string
310
313
 
311
314
  /**
312
315
  * 详细描述
313
316
  * @description 更详细的项目说明,可能在悬停或展开时显示
314
317
  */
315
- description?: string;
318
+ description?: string
316
319
 
317
320
  /**
318
321
  * 图标定义
319
322
  * @description 项目的视觉标识
320
323
  */
321
- icon?: TuffIcon;
324
+ icon?: TuffIcon
322
325
 
323
326
  /**
324
327
  * 标签列表
325
328
  * @description 附加在项目上的标签,用于分类和筛选
326
329
  */
327
- tags?: TuffTag[];
330
+ tags?: TuffTag[]
328
331
 
329
332
  /**
330
333
  * 右侧信息
331
334
  * @description 显示在项目右侧的辅助信息,如快捷键、时间等
332
335
  */
333
- accessory?: string;
336
+ accessory?: string
334
337
 
335
338
  }
336
339
 
@@ -347,36 +350,34 @@ export interface TuffCustomRender {
347
350
  * @description 指定使用哪种技术进行渲染
348
351
  * @required
349
352
  */
350
- type: 'html' | 'vue' | 'react' | 'markdown';
353
+ type: 'html' | 'vue' | 'react' | 'markdown'
351
354
 
352
355
  /**
353
356
  * 渲染内容
354
357
  * @description 根据type不同,可能是HTML字符串、组件名或Markdown文本
355
358
  * @required
356
359
  */
357
- content: string;
360
+ content: string
358
361
 
359
362
  /**
360
363
  * 渲染数据
361
364
  * @description 传递给渲染器的数据对象
362
365
  */
363
- data?: Record<string, any>;
366
+ data?: Record<string, any>
364
367
 
365
368
  /**
366
369
  * 样式资源
367
370
  * @description 需要加载的CSS资源URL列表
368
371
  */
369
- styles?: string[];
372
+ styles?: string[]
370
373
 
371
374
  /**
372
375
  * 脚本资源
373
376
  * @description 需要加载的JavaScript资源URL列表
374
377
  */
375
- scripts?: string[];
378
+ scripts?: string[]
376
379
  }
377
380
 
378
- import type { ITuffIcon } from '../../types/icon'
379
-
380
381
  /**
381
382
  * Icon definition
382
383
  *
@@ -397,19 +398,19 @@ export interface TuffTag {
397
398
  * @description 标签显示的文本内容
398
399
  * @required
399
400
  */
400
- text: string;
401
+ text: string
401
402
 
402
403
  /**
403
404
  * 标签颜色
404
405
  * @description 标签的背景或边框颜色,可使用预设值或自定义色值
405
406
  */
406
- color?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | string;
407
+ color?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | string
407
408
 
408
409
  /**
409
410
  * 标签样式
410
411
  * @description 标签的视觉风格
411
412
  */
412
- variant?: 'filled' | 'outlined' | 'ghost';
413
+ variant?: 'filled' | 'outlined' | 'ghost'
413
414
  }
414
415
 
415
416
  /**
@@ -424,7 +425,7 @@ export interface TuffLayout {
424
425
  * @description 决定项目的基本布局模式
425
426
  * @required
426
427
  */
427
- display: 'list' | 'card' | 'grid' | 'compact' | 'detailed';
428
+ display: 'list' | 'card' | 'grid' | 'compact' | 'detailed'
428
429
 
429
430
  /**
430
431
  * 网格配置
@@ -432,22 +433,22 @@ export interface TuffLayout {
432
433
  */
433
434
  grid?: {
434
435
  /** 列数 */
435
- columns?: number;
436
+ columns?: number
436
437
  /** 间距 */
437
- gap?: number;
438
- };
438
+ gap?: number
439
+ }
439
440
 
440
441
  /**
441
442
  * 尺寸配置
442
443
  * @description 控制项目的整体大小
443
444
  */
444
- size?: 'small' | 'medium' | 'large';
445
+ size?: 'small' | 'medium' | 'large'
445
446
 
446
447
  /**
447
448
  * 对齐方式
448
449
  * @description 控制内容的水平对齐方式
449
450
  */
450
- align?: 'left' | 'center' | 'right';
451
+ align?: 'left' | 'center' | 'right'
451
452
  }
452
453
 
453
454
  /**
@@ -463,43 +464,43 @@ export interface TuffPreview {
463
464
  * @description 决定预览的展示方式
464
465
  * @required
465
466
  */
466
- type: 'tooltip' | 'panel' | 'modal';
467
+ type: 'tooltip' | 'panel' | 'modal'
467
468
 
468
469
  /**
469
470
  * 预览标题
470
471
  * @description 预览内容的标题
471
472
  */
472
- title?: string;
473
+ title?: string
473
474
 
474
475
  /**
475
476
  * 预览内容
476
477
  * @description 预览的主体内容,通常是文本
477
478
  */
478
- content?: string;
479
+ content?: string
479
480
 
480
481
  /**
481
482
  * 预览图片
482
483
  * @description 预览中显示的图片URL
483
484
  */
484
- image?: string;
485
+ image?: string
485
486
 
486
487
  /**
487
488
  * 自定义预览组件
488
489
  * @description 用于复杂预览内容的自定义渲染配置
489
490
  */
490
- component?: TuffCustomRender;
491
+ component?: TuffCustomRender
491
492
 
492
493
  /**
493
494
  * 懒加载配置
494
495
  * @description 是否延迟加载预览内容,直到需要显示时
495
496
  */
496
- lazy?: boolean;
497
+ lazy?: boolean
497
498
 
498
499
  /**
499
500
  * 加载函数
500
501
  * @description 用于异步加载预览内容的函数
501
502
  */
502
- loader?: () => Promise<TuffPreview>;
503
+ loader?: () => Promise<TuffPreview>
503
504
  }
504
505
 
505
506
  // ==================== 交互行为系统 ====================
@@ -517,56 +518,56 @@ export interface TuffAction {
517
518
  * @description 用于识别和调用特定行为
518
519
  * @required
519
520
  */
520
- id: string;
521
+ id: string
521
522
 
522
523
  /**
523
524
  * 行为类型
524
525
  * @description 指定行为的基本类别,影响默认图标和处理逻辑
525
526
  * @required
526
527
  */
527
- type: TuffActionType;
528
+ type: TuffActionType
528
529
 
529
530
  /**
530
531
  * 行为标签
531
532
  * @description 用于在界面中展示的行为名称
532
533
  */
533
- label?: string;
534
+ label?: string
534
535
 
535
536
  /**
536
537
  * 行为描述
537
538
  * @description 对行为的详细说明,可能在悬停时显示
538
539
  */
539
- description?: string;
540
+ description?: string
540
541
 
541
542
  /**
542
543
  * 行为图标
543
544
  * @description 表示该行为的图标
544
545
  */
545
- icon?: TuffIcon;
546
+ icon?: TuffIcon
546
547
 
547
548
  /**
548
549
  * 快捷键
549
550
  * @description 触发该行为的键盘快捷键
550
551
  */
551
- shortcut?: string;
552
+ shortcut?: string
552
553
 
553
554
  /**
554
555
  * 行为参数
555
556
  * @description 执行行为时需要的附加数据
556
557
  */
557
- payload?: any;
558
+ payload?: any
558
559
 
559
560
  /**
560
561
  * 是否为主要行为
561
562
  * @description 标记为主要行为时,可能会获得视觉强调或作为默认操作
562
563
  */
563
- primary?: boolean;
564
+ primary?: boolean
564
565
 
565
566
  /**
566
567
  * 行为条件
567
568
  * @description 定义该行为何时可用的条件
568
569
  */
569
- condition?: TuffCondition;
570
+ condition?: TuffCondition
570
571
 
571
572
  /**
572
573
  * 确认配置
@@ -574,12 +575,12 @@ export interface TuffAction {
574
575
  */
575
576
  confirm?: {
576
577
  /** 确认对话框标题 */
577
- title: string;
578
+ title: string
578
579
  /** 确认对话框内容 */
579
- message: string;
580
+ message: string
580
581
  /** 是否为危险操作,可能会有特殊样式 */
581
- danger?: boolean;
582
- };
582
+ danger?: boolean
583
+ }
583
584
  }
584
585
 
585
586
  /**
@@ -588,16 +589,16 @@ export interface TuffAction {
588
589
  * @description
589
590
  * 定义行为的基本类别,系统会根据类型提供默认图标和处理逻辑
590
591
  */
591
- export type TuffActionType =
592
- | 'execute' // 执行命令/程序,运行应用或脚本
593
- | 'open' // 打开文件/链接,访问资源
594
- | 'navigate' // 导航跳转,切换视图或页面
595
- | 'copy' // 复制内容,将信息复制到剪贴板
596
- | 'preview' // 预览内容,查看详情但不完全打开
597
- | 'edit' // 编辑,修改内容
598
- | 'delete' // 删除,移除项目
599
- | 'share' // 分享,发送给他人
600
- | 'custom'; // 自定义行为,需要特殊处理
592
+ export type TuffActionType
593
+ = | 'execute' // 执行命令/程序,运行应用或脚本
594
+ | 'open' // 打开文件/链接,访问资源
595
+ | 'navigate' // 导航跳转,切换视图或页面
596
+ | 'copy' // 复制内容,将信息复制到剪贴板
597
+ | 'preview' // 预览内容,查看详情但不完全打开
598
+ | 'edit' // 编辑,修改内容
599
+ | 'delete' // 删除,移除项目
600
+ | 'share' // 分享,发送给他人
601
+ | 'custom' // 自定义行为,需要特殊处理
601
602
 
602
603
  /**
603
604
  * 行为执行条件
@@ -611,25 +612,25 @@ export interface TuffCondition {
611
612
  * 平台限制
612
613
  * @description 指定行为支持的操作系统平台
613
614
  */
614
- platform?: ('win32' | 'darwin' | 'linux')[];
615
+ platform?: ('win32' | 'darwin' | 'linux')[]
615
616
 
616
617
  /**
617
618
  * 权限要求
618
619
  * @description 执行行为所需的最低权限级别
619
620
  */
620
- permission?: TuffPermissionLevel;
621
+ permission?: TuffPermissionLevel
621
622
 
622
623
  /**
623
624
  * 依赖检查
624
625
  * @description 行为依赖的外部组件或服务
625
626
  */
626
- dependencies?: string[];
627
+ dependencies?: string[]
627
628
 
628
629
  /**
629
630
  * 自定义条件函数
630
631
  * @description 用于复杂条件判断的自定义函数
631
632
  */
632
- check?: () => boolean | Promise<boolean>;
633
+ check?: () => boolean | Promise<boolean>
633
634
  }
634
635
 
635
636
  // ==================== 评分与排序系统 ====================
@@ -646,43 +647,43 @@ export interface TuffScoring {
646
647
  * 基础得分 (0-1)
647
648
  * @description 项目的基础重要性分数
648
649
  */
649
- base?: number;
650
+ base?: number
650
651
 
651
652
  /**
652
653
  * 匹配得分 (0-1)
653
654
  * @description 与搜索查询的匹配程度
654
655
  */
655
- match?: number;
656
+ match?: number
656
657
 
657
658
  /**
658
659
  * 使用频率得分 (0-1)
659
660
  * @description 基于用户使用频率的分数
660
661
  */
661
- frequency?: number;
662
+ frequency?: number
662
663
 
663
664
  /**
664
665
  * 时间相关性得分 (0-1)
665
666
  * @description 基于时间因素的相关性分数
666
667
  */
667
- recency?: number;
668
+ recency?: number
668
669
 
669
670
  /**
670
671
  * AI 推荐得分 (0-1)
671
672
  * @description 基于AI分析的推荐强度
672
673
  */
673
- ai?: number;
674
+ ai?: number
674
675
 
675
676
  /**
676
677
  * 最终综合得分
677
678
  * @description 综合各项因素计算的最终分数
678
679
  */
679
- final?: number;
680
+ final?: number
680
681
 
681
682
  /**
682
683
  * 排序权重
683
684
  * @description 直接影响排序的权重值,越小越靠前
684
685
  */
685
- priority?: number;
686
+ priority?: number
686
687
 
687
688
  /**
688
689
  * 匹配详情
@@ -690,14 +691,14 @@ export interface TuffScoring {
690
691
  */
691
692
  match_details?: {
692
693
  /** 匹配类型 */
693
- type: 'exact' | 'fuzzy' | 'semantic' | 'ai';
694
+ type: 'exact' | 'fuzzy' | 'semantic' | 'ai'
694
695
  /** 匹配的查询文本 */
695
- query: string;
696
+ query: string
696
697
  /** 高亮显示的文本片段 */
697
- highlights?: string[];
698
+ highlights?: string[]
698
699
  /** 匹配置信度 */
699
- confidence?: number;
700
- };
700
+ confidence?: number
701
+ }
701
702
 
702
703
  /**
703
704
  * 使用统计
@@ -705,12 +706,12 @@ export interface TuffScoring {
705
706
  */
706
707
  usage_stats?: {
707
708
  /** 使用次数 */
708
- count: number;
709
+ count: number
709
710
  /** 最后使用时间 */
710
- last_used?: Date;
711
+ last_used?: Date
711
712
  /** 平均评分 */
712
- avg_rating?: number;
713
- };
713
+ avg_rating?: number
714
+ }
714
715
  }
715
716
 
716
717
  // ==================== 上下文信息 ====================
@@ -727,7 +728,7 @@ export interface TuffContext {
727
728
  * 会话ID
728
729
  * @description 标识当前用户会话
729
730
  */
730
- session?: string;
731
+ session?: string
731
732
 
732
733
  /**
733
734
  * 用户当前状态
@@ -735,14 +736,14 @@ export interface TuffContext {
735
736
  */
736
737
  user_state?: {
737
738
  /** 当前活动的应用 */
738
- active_app?: string;
739
+ active_app?: string
739
740
  /** 当前打开的文件夹 */
740
- current_folder?: string;
741
+ current_folder?: string
741
742
  /** 最近访问的文件列表 */
742
- recent_files?: string[];
743
+ recent_files?: string[]
743
744
  /** 当前工作的项目 */
744
- current_project?: string;
745
- };
745
+ current_project?: string
746
+ }
746
747
 
747
748
  /**
748
749
  * 时间上下文
@@ -750,16 +751,16 @@ export interface TuffContext {
750
751
  */
751
752
  temporal?: {
752
753
  /** 创建时间 */
753
- created_at?: Date;
754
+ created_at?: Date
754
755
  /** 修改时间 */
755
- modified_at?: Date;
756
+ modified_at?: Date
756
757
  /** 访问时间 */
757
- accessed_at?: Date;
758
+ accessed_at?: Date
758
759
  /** 一天中的时段 */
759
- time_of_day?: 'morning' | 'afternoon' | 'evening' | 'night';
760
+ time_of_day?: 'morning' | 'afternoon' | 'evening' | 'night'
760
761
  /** 星期几 */
761
- day_of_week?: string;
762
- };
762
+ day_of_week?: string
763
+ }
763
764
 
764
765
  /**
765
766
  * 地理位置上下文
@@ -767,12 +768,12 @@ export interface TuffContext {
767
768
  */
768
769
  location?: {
769
770
  /** 国家 */
770
- country?: string;
771
+ country?: string
771
772
  /** 城市 */
772
- city?: string;
773
+ city?: string
773
774
  /** 时区 */
774
- timezone?: string;
775
- };
775
+ timezone?: string
776
+ }
776
777
 
777
778
  /**
778
779
  * 工作上下文
@@ -780,26 +781,26 @@ export interface TuffContext {
780
781
  */
781
782
  work_context?: {
782
783
  /** 当前任务 */
783
- current_task?: string;
784
+ current_task?: string
784
785
  /** 所属项目 */
785
- project?: string;
786
+ project?: string
786
787
  /** 所属团队 */
787
- team?: string;
788
+ team?: string
788
789
  /** 截止日期 */
789
- deadline?: Date;
790
- };
790
+ deadline?: Date
791
+ }
791
792
 
792
793
  /**
793
794
  * 关联项目
794
795
  * @description 与当前项目相关的其他项目ID列表
795
796
  */
796
- related_items?: string[];
797
+ related_items?: string[]
797
798
 
798
799
  /**
799
800
  * 标签
800
801
  * @description 用于分类和组织的标签列表
801
802
  */
802
- tags?: string[];
803
+ tags?: string[]
803
804
  }
804
805
 
805
806
  // ==================== 扩展元数据 ====================
@@ -812,6 +813,11 @@ export interface TuffContext {
812
813
  * 可以包含文件信息、网络信息、应用信息等。
813
814
  */
814
815
  export interface TuffMeta {
816
+ /**
817
+ * Legacy icon identifier used by renderer fallbacks.
818
+ * @description Allows providers to pass through icon class names without building a full TuffIcon.
819
+ */
820
+ icon?: string
815
821
  /**
816
822
  * For plugin items, this holds the name of the plugin that generated the item.
817
823
  * @description The name of the plugin.
@@ -838,19 +844,19 @@ export interface TuffMeta {
838
844
  * This is used to distinguish simple actions (like 'copy') from feature activations.
839
845
  * @description The default action type.
840
846
  */
841
- defaultAction?: string;
847
+ defaultAction?: string
842
848
 
843
849
  /**
844
850
  * Priority of the item for sorting in search results
845
851
  * Higher numbers have higher priority (displayed first)
846
852
  * @description Priority value for search result ordering
847
853
  */
848
- priority?: number;
854
+ priority?: number
849
855
  /**
850
856
  * 原始数据
851
857
  * @description 项目的原始数据对象,用于特殊处理
852
858
  */
853
- raw?: any;
859
+ raw?: any
854
860
 
855
861
  /**
856
862
  * 文件信息
@@ -858,20 +864,20 @@ export interface TuffMeta {
858
864
  */
859
865
  file?: {
860
866
  /** 文件路径 */
861
- path: string;
867
+ path: string
862
868
  /** 文件大小(字节) */
863
- size?: number;
869
+ size?: number
864
870
  /** MIME类型 */
865
- mime_type?: string;
871
+ mime_type?: string
866
872
  /** 文件权限 */
867
- permissions?: string;
873
+ permissions?: string
868
874
  /** 创建时间 */
869
- created_at?: string;
875
+ created_at?: string
870
876
  /** 修改时间 */
871
- modified_at?: string;
877
+ modified_at?: string
872
878
  /** 文件扩展名(不带点) */
873
- extension?: string;
874
- };
879
+ extension?: string
880
+ }
875
881
 
876
882
  /**
877
883
  * 网络信息
@@ -879,18 +885,18 @@ export interface TuffMeta {
879
885
  */
880
886
  web?: {
881
887
  /** 完整URL */
882
- url: string;
888
+ url: string
883
889
  /** 域名 */
884
- domain?: string;
890
+ domain?: string
885
891
  /** 页面标题 */
886
- title?: string;
892
+ title?: string
887
893
  /** 页面描述 */
888
- description?: string;
894
+ description?: string
889
895
  /** 网站图标 */
890
- favicon?: string;
896
+ favicon?: string
891
897
  /** 页面截图 */
892
- screenshot?: string;
893
- };
898
+ screenshot?: string
899
+ }
894
900
 
895
901
  /**
896
902
  * 应用信息
@@ -898,16 +904,16 @@ export interface TuffMeta {
898
904
  */
899
905
  app?: {
900
906
  /** 应用包标识符 */
901
- bundle_id?: string;
907
+ bundle_id?: string
902
908
  /** 应用版本 */
903
- version?: string;
909
+ version?: string
904
910
  /** 应用路径 */
905
- path?: string;
911
+ path?: string
906
912
  /** 应用图标 */
907
- icon?: string;
913
+ icon?: string
908
914
  /** 应用类别 */
909
- category?: string;
910
- };
915
+ category?: string
916
+ }
911
917
 
912
918
  /**
913
919
  * 使用统计信息
@@ -915,16 +921,63 @@ export interface TuffMeta {
915
921
  */
916
922
  usage?: {
917
923
  /** 被触发的次数 */
918
- clickCount?: number;
924
+ clickCount?: number
919
925
  /** 最近一次使用时间(ISO 字符串) */
920
- lastUsed?: string;
921
- };
926
+ lastUsed?: string
927
+ }
928
+
929
+ /**
930
+ * 组合键使用统计信息(基于 source + id)
931
+ * @description 用于智能排序的详细统计数据,包含搜索/执行/取消等多维度统计
932
+ */
933
+ usageStats?: {
934
+ /** 执行次数 */
935
+ executeCount: number
936
+ /** 搜索次数 */
937
+ searchCount: number
938
+ /** 取消/失败次数 */
939
+ cancelCount?: number
940
+ /** 最后执行时间(ISO 字符串) */
941
+ lastExecuted: string | null
942
+ /** 最后搜索时间(ISO 字符串) */
943
+ lastSearched: string | null
944
+ /** 最后取消时间(ISO 字符串) */
945
+ lastCancelled?: string | null
946
+ }
947
+
948
+ /**
949
+ * 查询完成统计信息
950
+ * @description 基于查询前缀的自动完成统计
951
+ */
952
+ completion?: {
953
+ /** 完成次数 */
954
+ count: number
955
+ /** 最后完成时间(ISO 字符串) */
956
+ lastCompleted: string
957
+ /** 完成得分 */
958
+ score: number
959
+ }
960
+
961
+ /**
962
+ * 预览相关元数据
963
+ * @description 用于预览类型项目的额外信息
964
+ */
965
+ preview?: {
966
+ /** 能力ID */
967
+ abilityId?: string
968
+ /** 置信度 */
969
+ confidence?: number
970
+ /** 表达式 */
971
+ expression?: string
972
+ /** 预览负载数据 */
973
+ payload?: any
974
+ }
922
975
 
923
976
  /**
924
977
  * 插件扩展字段
925
978
  * @description 供插件存储自定义数据的字段
926
979
  */
927
- extension?: Record<string, any>;
980
+ extension?: Record<string, any>
928
981
 
929
982
  /**
930
983
  * 缓存配置
@@ -932,12 +985,12 @@ export interface TuffMeta {
932
985
  */
933
986
  cache?: {
934
987
  /** 缓存生存时间(秒) */
935
- ttl?: number;
988
+ ttl?: number
936
989
  /** 缓存键 */
937
- key?: string;
990
+ key?: string
938
991
  /** 缓存策略 */
939
- strategy?: 'memory' | 'disk' | 'remote';
940
- };
992
+ strategy?: 'memory' | 'disk' | 'remote'
993
+ }
941
994
 
942
995
  /**
943
996
  * 安全信息
@@ -945,12 +998,22 @@ export interface TuffMeta {
945
998
  */
946
999
  security?: {
947
1000
  /** 是否可信 */
948
- trusted?: boolean;
1001
+ trusted?: boolean
949
1002
  /** 数字签名 */
950
- signature?: string;
1003
+ signature?: string
951
1004
  /** 所需权限列表 */
952
- permissions?: string[];
953
- };
1005
+ permissions?: string[]
1006
+ }
1007
+
1008
+ /**
1009
+ * TuffIntelligence
1010
+ */
1011
+ intelligence?: any
1012
+
1013
+ /**
1014
+ * Keep CoreBox open after action execution
1015
+ */
1016
+ keepCoreBoxOpen?: boolean
954
1017
  }
955
1018
 
956
1019
  // ==================== 前端展示结构 ====================
@@ -968,34 +1031,34 @@ export interface TuffDisplayItem {
968
1031
  * @description 项目的唯一标识符
969
1032
  * @required
970
1033
  */
971
- id: string;
1034
+ id: string
972
1035
 
973
1036
  /**
974
1037
  * 渲染信息
975
1038
  * @description 控制项目的视觉呈现
976
1039
  * @required
977
1040
  */
978
- render: TuffRender;
1041
+ render: TuffRender
979
1042
 
980
1043
  /**
981
1044
  * 可用操作
982
1045
  * @description 项目支持的交互操作列表
983
1046
  * @required
984
1047
  */
985
- actions: TuffDisplayAction[];
1048
+ actions: TuffDisplayAction[]
986
1049
 
987
1050
  /**
988
1051
  * 评分信息
989
1052
  * @description 用于排序和推荐的评分数据
990
1053
  */
991
- scoring?: TuffScoring;
1054
+ scoring?: TuffScoring
992
1055
 
993
1056
  /**
994
1057
  * 原始数据引用
995
1058
  * @description 对原始TuffItem的引用
996
1059
  * @required
997
1060
  */
998
- raw: TuffItem;
1061
+ raw: TuffItem
999
1062
 
1000
1063
  /**
1001
1064
  * 执行主要操作
@@ -1003,14 +1066,14 @@ export interface TuffDisplayItem {
1003
1066
  * @returns 操作执行的Promise
1004
1067
  * @required
1005
1068
  */
1006
- execute(): Promise<void>;
1069
+ execute: () => Promise<void>
1007
1070
 
1008
1071
  /**
1009
1072
  * 获取预览内容
1010
1073
  * @description 获取项目的预览内容
1011
1074
  * @returns 预览内容的Promise
1012
1075
  */
1013
- getPreview?(): Promise<TuffPreview>;
1076
+ getPreview?: () => Promise<TuffPreview>
1014
1077
  }
1015
1078
 
1016
1079
  /**
@@ -1028,7 +1091,7 @@ export interface TuffDisplayAction extends Omit<TuffAction, 'payload'> {
1028
1091
  * @returns 操作执行结果
1029
1092
  * @required
1030
1093
  */
1031
- execute(context?: any): Promise<any>;
1094
+ execute: (context?: any) => Promise<any>
1032
1095
 
1033
1096
  /**
1034
1097
  * 检查是否可用
@@ -1036,7 +1099,7 @@ export interface TuffDisplayAction extends Omit<TuffAction, 'payload'> {
1036
1099
  * @returns 是否可用的Promise
1037
1100
  * @required
1038
1101
  */
1039
- isAvailable(): Promise<boolean>;
1102
+ isAvailable: () => Promise<boolean>
1040
1103
  }
1041
1104
 
1042
1105
  // ==================== 工具类型 ====================
@@ -1056,7 +1119,7 @@ export enum TuffInputType {
1056
1119
  /** 文件输入(文件路径数组) */
1057
1120
  Files = 'files',
1058
1121
  /** 富文本输入(HTML 格式) */
1059
- Html = 'html'
1122
+ Html = 'html',
1060
1123
  }
1061
1124
 
1062
1125
  /**
@@ -1072,7 +1135,7 @@ export interface TuffQueryInput {
1072
1135
  * @description 定义输入数据的类型
1073
1136
  * @required
1074
1137
  */
1075
- type: TuffInputType;
1138
+ type: TuffInputType
1076
1139
 
1077
1140
  /**
1078
1141
  * 输入内容
@@ -1083,25 +1146,25 @@ export interface TuffQueryInput {
1083
1146
  * - html: HTML 格式的富文本
1084
1147
  * @required
1085
1148
  */
1086
- content: string;
1149
+ content: string
1087
1150
 
1088
1151
  /**
1089
1152
  * 原始内容
1090
1153
  * @description 可选的原始格式内容,如富文本的 HTML 源码
1091
1154
  */
1092
- rawContent?: string;
1155
+ rawContent?: string
1093
1156
 
1094
1157
  /**
1095
1158
  * 缩略图
1096
1159
  * @description 图像的缩略图 data URL(用于预览)
1097
1160
  */
1098
- thumbnail?: string;
1161
+ thumbnail?: string
1099
1162
 
1100
1163
  /**
1101
1164
  * 元数据
1102
1165
  * @description 附加的元数据信息
1103
1166
  */
1104
- metadata?: Record<string, any>;
1167
+ metadata?: Record<string, any>
1105
1168
  }
1106
1169
 
1107
1170
  /**
@@ -1110,7 +1173,7 @@ export interface TuffQueryInput {
1110
1173
  * @description
1111
1174
  * 定义搜索请求的参数和过滤条件。
1112
1175
  * 系统根据这些参数执行搜索并返回匹配结果。
1113
- *
1176
+ *
1114
1177
  * **重要区分**:
1115
1178
  * - `text`: 用户在输入框中主动输入的查询文本
1116
1179
  * - `inputs`: 来自剪贴板或其他来源的附加输入数据(图像、文件、富文本等)
@@ -1120,42 +1183,42 @@ export interface TuffQuery {
1120
1183
  * 用户输入的查询文本
1121
1184
  * @description 这是用户在搜索框中主动输入的文本,不包括剪贴板内容
1122
1185
  * @required
1123
- *
1186
+ *
1124
1187
  * @example
1125
1188
  * 用户输入 "translate" → text = "translate"
1126
1189
  */
1127
- text: string;
1190
+ text: string
1128
1191
 
1129
1192
  /**
1130
1193
  * 查询类型
1131
1194
  * @description 指定查询的输入方式
1132
1195
  */
1133
- type?: 'text' | 'voice' | 'image';
1196
+ type?: 'text' | 'voice' | 'image'
1134
1197
 
1135
1198
  /**
1136
1199
  * 多类型输入(附加数据)
1137
1200
  * @description 除了用户输入的文本外的其他输入数据(如剪贴板中的图像、文件、富文本等)
1138
- *
1201
+ *
1139
1202
  * **与 text 的区别**:
1140
1203
  * - `text`: 用户主动输入,总是存在
1141
1204
  * - `inputs`: 系统自动检测的附加数据,可能为空
1142
- *
1205
+ *
1143
1206
  * 当用户触发 feature 时,系统会自动检测剪贴板并填充此字段。
1144
- *
1207
+ *
1145
1208
  * @example
1146
1209
  * 场景 1: 用户输入 "translate" + 剪贴板有图片
1147
1210
  * text: "translate"
1148
1211
  * inputs: [{ type: 'image', content: 'data:image/png;base64,...' }]
1149
- *
1212
+ *
1150
1213
  * 场景 2: 用户输入 "compress" + 剪贴板有文件
1151
- * text: "compress"
1214
+ * text: "compress"
1152
1215
  * inputs: [{ type: 'files', content: '["/path/to/file"]' }]
1153
- *
1216
+ *
1154
1217
  * 场景 3: 用户输入 "format" + 剪贴板有富文本
1155
1218
  * text: "format"
1156
1219
  * inputs: [{ type: 'html', content: 'plain text', rawContent: '<p>html</p>' }]
1157
1220
  */
1158
- inputs?: TuffQueryInput[];
1221
+ inputs?: TuffQueryInput[]
1159
1222
 
1160
1223
  /**
1161
1224
  * 过滤条件
@@ -1163,18 +1226,18 @@ export interface TuffQuery {
1163
1226
  */
1164
1227
  filters?: {
1165
1228
  /** 限制结果类型 */
1166
- kinds?: TuffItemKind[];
1229
+ kinds?: TuffItemKind[]
1167
1230
  /** 限制结果来源 */
1168
- sources?: string[];
1231
+ sources?: string[]
1169
1232
  /** 限制结果时间范围 */
1170
- date_range?: [Date, Date];
1171
- };
1233
+ date_range?: [Date, Date]
1234
+ }
1172
1235
 
1173
1236
  /**
1174
1237
  * 排序方式
1175
1238
  * @description 结果的排序策略
1176
1239
  */
1177
- sort?: 'relevance' | 'date' | 'frequency' | 'name';
1240
+ sort?: 'relevance' | 'date' | 'frequency' | 'name'
1178
1241
 
1179
1242
  /**
1180
1243
  * 分页信息
@@ -1182,16 +1245,16 @@ export interface TuffQuery {
1182
1245
  */
1183
1246
  pagination?: {
1184
1247
  /** 起始偏移量 */
1185
- offset: number;
1248
+ offset: number
1186
1249
  /** 每页数量限制 */
1187
- limit: number;
1188
- };
1250
+ limit: number
1251
+ }
1189
1252
 
1190
1253
  /**
1191
1254
  * 上下文信息
1192
1255
  * @description 提供搜索的上下文数据
1193
1256
  */
1194
- context?: TuffContext;
1257
+ context?: TuffContext
1195
1258
  }
1196
1259
 
1197
1260
  /**
@@ -1216,28 +1279,28 @@ export interface TuffSearchResult {
1216
1279
  * A unique identifier for this specific search operation.
1217
1280
  * This is crucial for the streaming model to associate updates with the correct search instance.
1218
1281
  */
1219
- sessionId?: string;
1282
+ sessionId?: string
1220
1283
 
1221
1284
  /**
1222
1285
  * 结果项目
1223
1286
  * @description 匹配的TuffItem列表
1224
1287
  * @required
1225
1288
  */
1226
- items: TuffItem[];
1289
+ items: TuffItem[]
1227
1290
 
1228
1291
  /**
1229
1292
  * 查询信息
1230
1293
  * @description 原始查询参数
1231
1294
  * @required
1232
1295
  */
1233
- query: TuffQuery;
1296
+ query: TuffQuery
1234
1297
 
1235
1298
  /**
1236
1299
  * 搜索耗时
1237
1300
  * @description 搜索执行的毫秒数
1238
1301
  * @required
1239
1302
  */
1240
- duration: number;
1303
+ duration: number
1241
1304
 
1242
1305
  /**
1243
1306
  * 来源统计
@@ -1246,27 +1309,27 @@ export interface TuffSearchResult {
1246
1309
  */
1247
1310
  sources: Array<{
1248
1311
  /** Provider's unique ID. */
1249
- providerId: string;
1312
+ providerId: string
1250
1313
  /** Provider's display name. */
1251
- providerName: string;
1314
+ providerName: string
1252
1315
  /** Search duration in milliseconds. */
1253
- duration: number;
1316
+ duration: number
1254
1317
  /** Number of results returned. */
1255
- resultCount: number;
1318
+ resultCount: number
1256
1319
  /** Status of the search operation. */
1257
- status: 'success' | 'timeout' | 'error';
1258
- }>;
1320
+ status: 'success' | 'timeout' | 'error'
1321
+ }>
1259
1322
 
1260
1323
  /**
1261
1324
  * AI 推荐
1262
1325
  * @description AI生成的搜索建议
1263
1326
  */
1264
- suggestions?: string[];
1327
+ suggestions?: string[]
1265
1328
 
1266
1329
  /**
1267
1330
  * The provider(s) to activate after this search result.
1268
1331
  */
1269
- activate?: IProviderActivate[];
1332
+ activate?: IProviderActivate[]
1270
1333
 
1271
1334
  /** Optional statistics about the sorting process. */
1272
1335
  sort_stats?: SortStat[]
@@ -1280,7 +1343,6 @@ export interface IProviderActivate {
1280
1343
  meta?: Record<string, any>
1281
1344
  }
1282
1345
 
1283
-
1284
1346
  /**
1285
1347
  * Defines the interface for a sort middleware.
1286
1348
  * Each middleware receives an array of items and should return a sorted array.
@@ -1295,7 +1357,7 @@ export interface ISortMiddleware {
1295
1357
  * @param signal - An AbortSignal to cancel the sorting operation.
1296
1358
  * @returns A sorted array of TuffItems.
1297
1359
  */
1298
- sort(items: TuffItem[], query: TuffQuery, signal: AbortSignal): TuffItem[]
1360
+ sort: (items: TuffItem[], query: TuffQuery, signal: AbortSignal) => TuffItem[]
1299
1361
  }
1300
1362
 
1301
1363
  /**
@@ -1350,18 +1412,18 @@ export interface ISearchProvider<C> {
1350
1412
  * @returns A promise that resolves to a full TuffSearchResult object, allowing the provider
1351
1413
  * to influence the final result, including the next activation state.
1352
1414
  */
1353
- onSearch(query: TuffQuery, signal: AbortSignal): Promise<TuffSearchResult>
1415
+ onSearch: (query: TuffQuery, signal: AbortSignal) => Promise<TuffSearchResult>
1354
1416
 
1355
1417
  /**
1356
1418
  * Optional method to handle activation.
1357
1419
  * Called when the provider is prioritized, e.g., via an activation keyword.
1358
1420
  */
1359
- onActivate?(): void
1421
+ onActivate?: () => void
1360
1422
 
1361
1423
  /**
1362
1424
  * Optional method to handle deactivation.
1363
1425
  */
1364
- onDeactivate?(): void
1426
+ onDeactivate?: () => void
1365
1427
 
1366
1428
  /**
1367
1429
  * Optional method to execute an item.
@@ -1369,13 +1431,13 @@ export interface ISearchProvider<C> {
1369
1431
  * @returns A promise that resolves to an activation object if the provider should be
1370
1432
  * activated, or `null` otherwise.
1371
1433
  */
1372
- onExecute?(args: IExecuteArgs): Promise<IProviderActivate | null>
1434
+ onExecute?: (args: IExecuteArgs) => Promise<IProviderActivate | null>
1373
1435
 
1374
1436
  /**
1375
1437
  * Optional method to load provider.
1376
1438
  * @param context The context of the provider.
1377
1439
  */
1378
- onLoad?(context: C): Promise<void>
1440
+ onLoad?: (context: C) => Promise<void>
1379
1441
  }
1380
1442
 
1381
1443
  // ==================== 插件接口预览 ====================
@@ -1395,18 +1457,18 @@ export interface TuffSearchProvider {
1395
1457
  */
1396
1458
  info: {
1397
1459
  /** 插件唯一标识 */
1398
- id: string;
1460
+ id: string
1399
1461
  /** 插件名称 */
1400
- name: string;
1462
+ name: string
1401
1463
  /** 插件版本 */
1402
- version: string;
1464
+ version: string
1403
1465
  /** 插件描述 */
1404
- description: string;
1466
+ description: string
1405
1467
  /** 插件作者 */
1406
- author: string;
1468
+ author: string
1407
1469
  /** 插件图标 */
1408
- icon?: TuffIcon;
1409
- };
1470
+ icon?: TuffIcon
1471
+ }
1410
1472
 
1411
1473
  /**
1412
1474
  * 搜索能力配置
@@ -1419,36 +1481,36 @@ export interface TuffSearchProvider {
1419
1481
  * @description 插件能处理的输入类型
1420
1482
  * @required
1421
1483
  */
1422
- query_types: ('text' | 'voice' | 'image')[];
1484
+ query_types: ('text' | 'voice' | 'image')[]
1423
1485
 
1424
1486
  /**
1425
1487
  * 支持的项目类型
1426
1488
  * @description 插件能提供的结果类型
1427
1489
  * @required
1428
1490
  */
1429
- item_kinds: TuffItemKind[];
1491
+ item_kinds: TuffItemKind[]
1430
1492
 
1431
1493
  /**
1432
1494
  * 是否支持实时搜索
1433
1495
  * @description 是否支持输入时实时返回结果
1434
1496
  * @required
1435
1497
  */
1436
- realtime: boolean;
1498
+ realtime: boolean
1437
1499
 
1438
1500
  /**
1439
1501
  * 是否支持 AI 增强
1440
1502
  * @description 是否使用AI技术增强搜索结果
1441
1503
  * @required
1442
1504
  */
1443
- ai_enhanced: boolean;
1505
+ ai_enhanced: boolean
1444
1506
 
1445
1507
  /**
1446
1508
  * 权限要求
1447
1509
  * @description 插件需要的权限级别
1448
1510
  * @required
1449
1511
  */
1450
- permissions: TuffPermissionLevel;
1451
- };
1512
+ permissions: TuffPermissionLevel
1513
+ }
1452
1514
 
1453
1515
  /**
1454
1516
  * 搜索方法
@@ -1457,7 +1519,7 @@ export interface TuffSearchProvider {
1457
1519
  * @returns 搜索结果Promise
1458
1520
  * @required
1459
1521
  */
1460
- search(query: TuffQuery): Promise<TuffItem[]>;
1522
+ search: (query: TuffQuery) => Promise<TuffItem[]>
1461
1523
 
1462
1524
  /**
1463
1525
  * 获取推荐项
@@ -1465,7 +1527,7 @@ export interface TuffSearchProvider {
1465
1527
  * @param context 上下文信息
1466
1528
  * @returns 推荐项目Promise
1467
1529
  */
1468
- getRecommendations?(context: TuffContext): Promise<TuffItem[]>;
1530
+ getRecommendations?: (context: TuffContext) => Promise<TuffItem[]>
1469
1531
 
1470
1532
  /**
1471
1533
  * 执行操作
@@ -1475,19 +1537,19 @@ export interface TuffSearchProvider {
1475
1537
  * @returns 操作结果Promise
1476
1538
  * @required
1477
1539
  */
1478
- executeAction(action_id: string, payload: any): Promise<any>;
1540
+ executeAction: (action_id: string, payload: any) => Promise<any>
1479
1541
 
1480
1542
  /**
1481
1543
  * 激活钩子
1482
1544
  * @description 插件被激活时调用
1483
1545
  * @returns 完成Promise
1484
1546
  */
1485
- onActivate?(): Promise<void>;
1547
+ onActivate?: () => Promise<void>
1486
1548
 
1487
1549
  /**
1488
1550
  * 停用钩子
1489
1551
  * @description 插件被停用时调用
1490
1552
  * @returns 完成Promise
1491
1553
  */
1492
- onDeactivate?(): Promise<void>;
1554
+ onDeactivate?: () => Promise<void>
1493
1555
  }