@talex-touch/utils 1.0.40 → 1.0.44

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 (235) hide show
  1. package/.eslintcache +1 -0
  2. package/__tests__/cloud-sync-sdk.test.ts +442 -0
  3. package/__tests__/icons/icons.test.ts +84 -0
  4. package/__tests__/plugin-sdk-lifecycle.test.ts +130 -0
  5. package/__tests__/power-sdk.test.ts +143 -0
  6. package/__tests__/preset-export-types.test.ts +108 -0
  7. package/__tests__/search/fuzzy-match.test.ts +137 -0
  8. package/__tests__/transport/port-policy.test.ts +44 -0
  9. package/__tests__/transport-domain-sdks.test.ts +152 -0
  10. package/__tests__/types/update.test.ts +67 -0
  11. package/account/account-sdk.ts +915 -0
  12. package/account/index.ts +2 -0
  13. package/account/types.ts +321 -0
  14. package/analytics/client.ts +136 -0
  15. package/analytics/index.ts +2 -0
  16. package/analytics/types.ts +156 -0
  17. package/animation/auto-resize.ts +322 -0
  18. package/animation/window-node.ts +26 -19
  19. package/auth/clerk-types.ts +12 -30
  20. package/auth/index.ts +0 -2
  21. package/auth/useAuthState.ts +6 -14
  22. package/base/index.ts +2 -0
  23. package/base/log-level.ts +105 -0
  24. package/channel/index.ts +170 -69
  25. package/cloud-sync/cloud-sync-sdk.ts +450 -0
  26. package/cloud-sync/index.ts +1 -0
  27. package/common/file-scan-utils.ts +17 -9
  28. package/common/index.ts +4 -0
  29. package/common/logger/index.ts +46 -0
  30. package/common/logger/logger-manager.ts +303 -0
  31. package/common/logger/module-logger.ts +270 -0
  32. package/common/logger/transport-logger.ts +234 -0
  33. package/common/logger/types.ts +93 -0
  34. package/common/search/gather.ts +48 -6
  35. package/common/search/index.ts +8 -0
  36. package/common/storage/constants.ts +13 -0
  37. package/common/storage/entity/app-settings.ts +245 -0
  38. package/common/storage/entity/index.ts +3 -0
  39. package/common/storage/entity/layout-atom-types.ts +147 -0
  40. package/common/storage/entity/openers.ts +1 -0
  41. package/common/storage/entity/preset-cloud-api.ts +132 -0
  42. package/common/storage/entity/preset-export-types.ts +256 -0
  43. package/common/storage/entity/shortcut-settings.ts +1 -0
  44. package/common/storage/shortcut-storage.ts +11 -0
  45. package/common/utils/clone-diagnostics.ts +105 -0
  46. package/common/utils/file.ts +16 -8
  47. package/common/utils/index.ts +6 -2
  48. package/common/utils/payload-preview.ts +173 -0
  49. package/common/utils/polling.ts +167 -13
  50. package/common/utils/safe-path.ts +103 -0
  51. package/common/utils/safe-shell.ts +115 -0
  52. package/common/utils/task-queue.ts +4 -1
  53. package/core-box/builder/tuff-builder.ts +0 -1
  54. package/core-box/index.ts +1 -1
  55. package/core-box/recommendation.ts +38 -1
  56. package/core-box/tuff/tuff-dsl.ts +97 -0
  57. package/electron/download-manager.ts +10 -7
  58. package/electron/env-tool.ts +42 -40
  59. package/electron/index.ts +0 -1
  60. package/env/index.ts +156 -0
  61. package/eslint.config.js +55 -0
  62. package/i18n/index.ts +62 -0
  63. package/i18n/locales/en.json +226 -0
  64. package/i18n/locales/zh.json +226 -0
  65. package/i18n/message-keys.ts +236 -0
  66. package/i18n/resolver.ts +181 -0
  67. package/icons/index.ts +257 -0
  68. package/icons/svg.ts +69 -0
  69. package/index.ts +9 -1
  70. package/intelligence/client.ts +72 -42
  71. package/market/constants.ts +21 -3
  72. package/market/index.ts +1 -1
  73. package/market/types.ts +20 -5
  74. package/package.json +15 -5
  75. package/permission/index.ts +143 -46
  76. package/permission/legacy.ts +26 -0
  77. package/permission/registry.ts +304 -0
  78. package/permission/types.ts +164 -0
  79. package/plugin/channel.ts +68 -39
  80. package/plugin/index.ts +82 -8
  81. package/plugin/install.ts +3 -0
  82. package/plugin/log/types.ts +22 -5
  83. package/plugin/node/logger-manager.ts +11 -3
  84. package/plugin/node/logger.ts +24 -17
  85. package/plugin/preload.ts +25 -2
  86. package/plugin/providers/index.ts +4 -0
  87. package/plugin/providers/market-client.ts +218 -0
  88. package/plugin/providers/npm-provider.ts +228 -0
  89. package/plugin/providers/tpex-provider.ts +297 -0
  90. package/plugin/providers/tpex-types.ts +34 -0
  91. package/plugin/sdk/box-items.ts +14 -0
  92. package/plugin/sdk/box-sdk.ts +64 -0
  93. package/plugin/sdk/channel.ts +119 -4
  94. package/plugin/sdk/clipboard.ts +26 -12
  95. package/plugin/sdk/cloud-sync.ts +113 -0
  96. package/plugin/sdk/common.ts +19 -11
  97. package/plugin/sdk/core-box.ts +6 -15
  98. package/plugin/sdk/division-box.ts +160 -65
  99. package/plugin/sdk/examples/storage-onDidChange-example.js +5 -2
  100. package/plugin/sdk/feature-sdk.ts +111 -76
  101. package/plugin/sdk/flow.ts +146 -45
  102. package/plugin/sdk/hooks/bridge.ts +113 -49
  103. package/plugin/sdk/hooks/life-cycle.ts +35 -16
  104. package/plugin/sdk/index.ts +14 -3
  105. package/plugin/sdk/intelligence.ts +87 -0
  106. package/plugin/sdk/meta/README.md +179 -0
  107. package/plugin/sdk/meta-sdk.ts +244 -0
  108. package/plugin/sdk/notification.ts +9 -0
  109. package/plugin/sdk/performance.ts +1 -16
  110. package/plugin/sdk/plugin-info.ts +64 -0
  111. package/plugin/sdk/power.ts +155 -0
  112. package/plugin/sdk/recommend.ts +21 -0
  113. package/plugin/sdk/service/index.ts +12 -8
  114. package/plugin/sdk/sqlite.ts +141 -0
  115. package/plugin/sdk/storage.ts +2 -6
  116. package/plugin/sdk/system.ts +2 -9
  117. package/plugin/sdk/temp-files.ts +41 -0
  118. package/plugin/sdk/touch-sdk.ts +18 -0
  119. package/plugin/sdk/types.ts +44 -4
  120. package/plugin/sdk/window/index.ts +12 -9
  121. package/plugin/sdk-version.ts +231 -0
  122. package/preload/renderer.ts +3 -2
  123. package/renderer/hooks/arg-mapper.ts +34 -6
  124. package/renderer/hooks/index.ts +13 -0
  125. package/renderer/hooks/initialize.ts +2 -1
  126. package/renderer/hooks/use-agent-market-sdk.ts +7 -0
  127. package/renderer/hooks/use-agent-market.ts +106 -0
  128. package/renderer/hooks/use-agents-sdk.ts +7 -0
  129. package/renderer/hooks/use-app-sdk.ts +7 -0
  130. package/renderer/hooks/use-channel.ts +33 -4
  131. package/renderer/hooks/use-download-sdk.ts +21 -0
  132. package/renderer/hooks/use-intelligence-sdk.ts +7 -0
  133. package/renderer/hooks/use-intelligence-stats.ts +290 -0
  134. package/renderer/hooks/use-intelligence.ts +202 -104
  135. package/renderer/hooks/use-market-sdk.ts +16 -0
  136. package/renderer/hooks/use-notification-sdk.ts +7 -0
  137. package/renderer/hooks/use-permission-sdk.ts +7 -0
  138. package/renderer/hooks/use-permission.ts +325 -0
  139. package/renderer/hooks/use-platform-sdk.ts +7 -0
  140. package/renderer/hooks/use-plugin-sdk.ts +16 -0
  141. package/renderer/hooks/use-settings-sdk.ts +7 -0
  142. package/renderer/hooks/use-update-sdk.ts +21 -0
  143. package/renderer/index.ts +1 -0
  144. package/renderer/ref.ts +19 -10
  145. package/renderer/shared/components/SharedPluginDetailContent.vue +84 -0
  146. package/renderer/shared/components/SharedPluginDetailHeader.vue +116 -0
  147. package/renderer/shared/components/SharedPluginDetailMetaList.vue +39 -0
  148. package/renderer/shared/components/SharedPluginDetailReadme.vue +45 -0
  149. package/renderer/shared/components/SharedPluginDetailVersions.vue +98 -0
  150. package/renderer/shared/components/index.ts +5 -0
  151. package/renderer/shared/components/shims-vue.d.ts +5 -0
  152. package/renderer/shared/index.ts +2 -0
  153. package/renderer/shared/plugin-detail.ts +62 -0
  154. package/renderer/storage/app-settings.ts +3 -1
  155. package/renderer/storage/base-storage.ts +508 -82
  156. package/renderer/storage/intelligence-storage.ts +37 -46
  157. package/renderer/storage/openers.ts +3 -1
  158. package/renderer/storage/storage-subscription.ts +126 -42
  159. package/renderer/touch-sdk/env.ts +10 -10
  160. package/renderer/touch-sdk/index.ts +114 -18
  161. package/renderer/touch-sdk/terminal.ts +24 -13
  162. package/search/feature-matcher.ts +279 -0
  163. package/search/fuzzy-match.ts +64 -34
  164. package/search/index.ts +10 -0
  165. package/search/levenshtein-utils.ts +17 -11
  166. package/transport/errors.ts +310 -0
  167. package/transport/event/builder.ts +378 -0
  168. package/transport/event/index.ts +7 -0
  169. package/transport/event/types.ts +292 -0
  170. package/transport/events/index.ts +2670 -0
  171. package/transport/events/meta-overlay.ts +79 -0
  172. package/transport/events/types/agents.ts +177 -0
  173. package/transport/events/types/app-index.ts +9 -0
  174. package/transport/events/types/app.ts +475 -0
  175. package/transport/events/types/box-item.ts +222 -0
  176. package/transport/events/types/clipboard.ts +80 -0
  177. package/transport/events/types/core-box.ts +534 -0
  178. package/transport/events/types/device-idle.ts +7 -0
  179. package/transport/events/types/division-box.ts +99 -0
  180. package/transport/events/types/download.ts +115 -0
  181. package/transport/events/types/file-index.ts +73 -0
  182. package/transport/events/types/flow.ts +149 -0
  183. package/transport/events/types/index.ts +70 -0
  184. package/transport/events/types/market.ts +39 -0
  185. package/transport/events/types/meta-overlay.ts +184 -0
  186. package/transport/events/types/notification.ts +140 -0
  187. package/transport/events/types/permission.ts +90 -0
  188. package/transport/events/types/platform.ts +8 -0
  189. package/transport/events/types/plugin.ts +620 -0
  190. package/transport/events/types/sentry.ts +20 -0
  191. package/transport/events/types/storage.ts +208 -0
  192. package/transport/events/types/transport.ts +60 -0
  193. package/transport/events/types/tray.ts +16 -0
  194. package/transport/events/types/update.ts +78 -0
  195. package/transport/index.ts +139 -0
  196. package/transport/main.ts +2 -0
  197. package/transport/sdk/constants.ts +29 -0
  198. package/transport/sdk/domains/agents-market.ts +47 -0
  199. package/transport/sdk/domains/agents.ts +62 -0
  200. package/transport/sdk/domains/app.ts +48 -0
  201. package/transport/sdk/domains/disposable.ts +35 -0
  202. package/transport/sdk/domains/download.ts +139 -0
  203. package/transport/sdk/domains/index.ts +13 -0
  204. package/transport/sdk/domains/intelligence.ts +616 -0
  205. package/transport/sdk/domains/market.ts +35 -0
  206. package/transport/sdk/domains/notification.ts +62 -0
  207. package/transport/sdk/domains/permission.ts +85 -0
  208. package/transport/sdk/domains/platform.ts +19 -0
  209. package/transport/sdk/domains/plugin.ts +144 -0
  210. package/transport/sdk/domains/settings.ts +92 -0
  211. package/transport/sdk/domains/update.ts +64 -0
  212. package/transport/sdk/index.ts +60 -0
  213. package/transport/sdk/main-transport.ts +710 -0
  214. package/transport/sdk/main.ts +9 -0
  215. package/transport/sdk/plugin-transport.ts +654 -0
  216. package/transport/sdk/port-policy.ts +38 -0
  217. package/transport/sdk/renderer-transport.ts +1165 -0
  218. package/transport/types.ts +605 -0
  219. package/types/agent.ts +399 -0
  220. package/types/cloud-sync.ts +157 -0
  221. package/types/division-box.ts +47 -27
  222. package/types/download.ts +1 -0
  223. package/types/flow.ts +63 -12
  224. package/types/icon.ts +2 -1
  225. package/types/index.ts +5 -0
  226. package/types/intelligence.ts +1492 -81
  227. package/types/modules/base.ts +2 -0
  228. package/types/path-browserify.d.ts +5 -0
  229. package/types/platform.ts +12 -0
  230. package/types/startup-info.ts +32 -0
  231. package/types/touch-app-core.ts +8 -8
  232. package/types/update.ts +94 -1
  233. package/vitest.config.ts +25 -0
  234. package/auth/useClerkConfig.ts +0 -40
  235. package/auth/useClerkProvider.ts +0 -52
@@ -1,4 +1,9 @@
1
- export enum AiProviderType {
1
+ import { NEXUS_BASE_URL } from '../env'
2
+
3
+ /**
4
+ * Supported intelligence provider types.
5
+ */
6
+ export enum IntelligenceProviderType {
2
7
  OPENAI = 'openai',
3
8
  ANTHROPIC = 'anthropic',
4
9
  DEEPSEEK = 'deepseek',
@@ -7,295 +12,1672 @@ export enum AiProviderType {
7
12
  CUSTOM = 'custom',
8
13
  }
9
14
 
10
- export enum AiCapabilityType {
15
+ /**
16
+ * Intelligence capability types for various AI operations.
17
+ */
18
+ export enum IntelligenceCapabilityType {
19
+ // Text capabilities
11
20
  CHAT = 'chat',
12
21
  COMPLETION = 'completion',
13
22
  EMBEDDING = 'embedding',
14
23
  SUMMARIZE = 'summarize',
15
24
  TRANSLATE = 'translate',
25
+ REWRITE = 'rewrite',
26
+ GRAMMAR_CHECK = 'grammar-check',
27
+ // Code capabilities
28
+ CODE_GENERATE = 'code-generate',
29
+ CODE_EXPLAIN = 'code-explain',
30
+ CODE_REVIEW = 'code-review',
31
+ CODE_REFACTOR = 'code-refactor',
32
+ CODE_DEBUG = 'code-debug',
33
+ // Analysis capabilities
34
+ INTENT_DETECT = 'intent-detect',
35
+ SENTIMENT_ANALYZE = 'sentiment-analyze',
36
+ CONTENT_EXTRACT = 'content-extract',
37
+ KEYWORDS_EXTRACT = 'keywords-extract',
38
+ CLASSIFICATION = 'classification',
39
+ // Audio capabilities
16
40
  TTS = 'tts',
17
41
  STT = 'stt',
42
+ AUDIO_TRANSCRIBE = 'audio-transcribe',
43
+ // Vision capabilities
18
44
  VISION = 'vision',
45
+ VISION_OCR = 'vision-ocr',
46
+ IMAGE_CAPTION = 'image-caption',
47
+ IMAGE_ANALYZE = 'image-analyze',
48
+ IMAGE_GENERATE = 'image-generate',
49
+ IMAGE_EDIT = 'image-edit',
50
+ // RAG & Search capabilities
51
+ RAG_QUERY = 'rag-query',
52
+ SEMANTIC_SEARCH = 'semantic-search',
53
+ RERANK = 'rerank',
54
+ // Workflow capabilities
55
+ WORKFLOW = 'workflow',
56
+ AGENT = 'agent',
19
57
  }
20
58
 
21
- export interface AiProviderRateLimit {
59
+ /**
60
+ * Rate limit configuration for an intelligence provider.
61
+ */
62
+ export interface IntelligenceProviderRateLimit {
63
+ /** Maximum requests allowed per minute. */
22
64
  requestsPerMinute?: number
65
+ /** Maximum requests allowed per day. */
23
66
  requestsPerDay?: number
67
+ /** Maximum tokens allowed per minute. */
24
68
  tokensPerMinute?: number
69
+ /** Maximum tokens allowed per day. */
25
70
  tokensPerDay?: number
26
71
  }
27
72
 
28
- export interface AiVisionImageSource {
73
+ /**
74
+ * Image source configuration for vision capabilities.
75
+ */
76
+ export interface IntelligenceVisionImageSource {
77
+ /** Source type: data URL, file path, or base64 encoded. */
29
78
  type: 'data-url' | 'file' | 'base64'
79
+ /** Data URL of the image. */
30
80
  dataUrl?: string
81
+ /** File path to the image. */
31
82
  filePath?: string
83
+ /** Base64 encoded image data. */
32
84
  base64?: string
33
85
  }
34
86
 
35
- export interface AiVisionOcrBlock {
87
+ /**
88
+ * OCR text block detected in an image.
89
+ */
90
+ export interface IntelligenceVisionOcrBlock {
91
+ /** Unique identifier for the block. */
36
92
  id?: string
93
+ /** Detected text content. */
37
94
  text: string
95
+ /** Detected language of the text. */
38
96
  language?: string
97
+ /** Confidence score (0-1). */
39
98
  confidence?: number
99
+ /** Bounding box coordinates [x, y, width, height]. */
40
100
  boundingBox?: [number, number, number, number]
101
+ /** Polygon points for non-rectangular regions. */
41
102
  polygon?: Array<[number, number]>
103
+ /** Block type classification. */
42
104
  type?: 'word' | 'line' | 'paragraph' | 'region'
43
- children?: AiVisionOcrBlock[]
105
+ /** Nested child blocks. */
106
+ children?: IntelligenceVisionOcrBlock[]
44
107
  }
45
108
 
46
- export interface AiVisionOcrResult {
109
+ /**
110
+ * Result from OCR vision capability.
111
+ */
112
+ export interface IntelligenceVisionOcrResult {
113
+ /** Full extracted text. */
47
114
  text: string
115
+ /** Overall confidence score. */
48
116
  confidence?: number
117
+ /** Detected primary language. */
49
118
  language?: string
119
+ /** Extracted keywords for search. */
50
120
  keywords?: string[]
121
+ /** Suggested search terms. */
51
122
  suggestions?: string[]
52
- blocks?: AiVisionOcrBlock[]
123
+ /** Structured text blocks. */
124
+ blocks?: IntelligenceVisionOcrBlock[]
125
+ /** OCR engine identifier. */
126
+ engine?: 'apple-vision' | 'windows-ocr' | 'cloud'
127
+ /** OCR execution latency in milliseconds. */
128
+ durationMs?: number
129
+ /** Raw provider response. */
53
130
  raw?: any
54
131
  }
55
132
 
56
- export interface AiVisionOcrPayload {
57
- source: AiVisionImageSource
133
+ /**
134
+ * Payload for OCR vision capability.
135
+ */
136
+ export interface IntelligenceVisionOcrPayload {
137
+ /** Image source configuration. */
138
+ source: IntelligenceVisionImageSource
139
+ /** Expected language hint. */
58
140
  language?: string
141
+ /** Custom prompt for OCR. */
59
142
  prompt?: string
143
+ /** Additional metadata. */
60
144
  metadata?: Record<string, any>
145
+ /** Include layout information. */
61
146
  includeLayout?: boolean
147
+ /** Extract keywords from text. */
62
148
  includeKeywords?: boolean
63
149
  }
64
150
 
65
- export interface AiProviderConfig {
151
+ /**
152
+ * Configuration for an intelligence provider.
153
+ */
154
+ export interface IntelligenceProviderConfig {
155
+ /** Unique provider identifier. */
66
156
  id: string
67
- type: AiProviderType
157
+ /** Provider type. */
158
+ type: IntelligenceProviderType
159
+ /** Display name. */
68
160
  name: string
161
+ /** Whether the provider is enabled. */
69
162
  enabled: boolean
163
+ /** API key for authentication. */
70
164
  apiKey?: string
165
+ /** Base URL for API requests. */
71
166
  baseUrl?: string
72
- rateLimit?: AiProviderRateLimit
167
+ /** Rate limit configuration. */
168
+ rateLimit?: IntelligenceProviderRateLimit
169
+ /** Available models. */
73
170
  models?: string[]
171
+ /** Default model to use. */
74
172
  defaultModel?: string
173
+ /** System instructions. */
75
174
  instructions?: string
175
+ /** Request timeout in milliseconds. */
76
176
  timeout?: number
177
+ /** Provider priority for selection. */
77
178
  priority?: number
179
+ /** Supported capability IDs. */
78
180
  capabilities?: string[]
181
+ /** Additional metadata. */
79
182
  metadata?: Record<string, any>
80
183
  }
81
184
 
82
- export interface AiMessage {
185
+ /**
186
+ * Chat message structure.
187
+ */
188
+ export interface IntelligenceMessage {
189
+ /** Message role. */
83
190
  role: 'system' | 'user' | 'assistant'
191
+ /** Message content. */
84
192
  content: string
193
+ /** Optional sender name. */
85
194
  name?: string
86
195
  }
87
196
 
88
- export interface AiInvokeOptions {
197
+ /**
198
+ * Options for invoking an intelligence capability.
199
+ */
200
+ export interface IntelligenceInvokeOptions {
201
+ /** Strategy ID for provider selection. */
89
202
  strategy?: string
203
+ /** Preferred models in order. */
90
204
  modelPreference?: string[]
205
+ /** Maximum cost ceiling. */
91
206
  costCeiling?: number
207
+ /** Target latency in milliseconds. */
92
208
  latencyTarget?: number
209
+ /** Request timeout in milliseconds. */
93
210
  timeout?: number
211
+ /** Enable streaming response. */
94
212
  stream?: boolean
213
+ /** Preferred provider ID. */
95
214
  preferredProviderId?: string
215
+ /** Allowed provider IDs. */
96
216
  allowedProviderIds?: string[]
217
+ /** Additional metadata. */
97
218
  metadata?: Record<string, any>
219
+ /** Mark as test run. */
98
220
  testRun?: boolean
99
221
  }
100
222
 
101
- export interface AiInvokeContext {
223
+ /**
224
+ * Context information for an invocation.
225
+ */
226
+ export interface IntelligenceInvokeContext {
227
+ /** Request source identifier. */
102
228
  source?: string
229
+ /** User locale. */
103
230
  locale?: string
231
+ /** User identifier. */
104
232
  userId?: string
233
+ /** Session identifier. */
105
234
  sessionId?: string
106
235
  }
107
236
 
108
- export interface AiUsageInfo {
237
+ /**
238
+ * Token usage information.
239
+ */
240
+ export interface IntelligenceUsageInfo {
241
+ /** Tokens used in prompt. */
109
242
  promptTokens: number
243
+ /** Tokens used in completion. */
110
244
  completionTokens: number
245
+ /** Total tokens used. */
111
246
  totalTokens: number
247
+ /** Estimated cost. */
112
248
  cost?: number
113
249
  }
114
250
 
115
- export interface AiInvokeResult<T = any> {
251
+ /**
252
+ * Result from an intelligence invocation.
253
+ * @template T - Result data type.
254
+ */
255
+ export interface IntelligenceInvokeResult<T = any> {
256
+ /** The result data. */
116
257
  result: T
117
- usage: AiUsageInfo
258
+ /** Token usage information. */
259
+ usage: IntelligenceUsageInfo
260
+ /** Model used for the request. */
118
261
  model: string
262
+ /** Request latency in milliseconds. */
119
263
  latency: number
264
+ /** Unique trace identifier. */
120
265
  traceId: string
266
+ /** Provider that handled the request. */
121
267
  provider: string
122
268
  }
123
269
 
124
- export interface AiStreamChunk {
270
+ /**
271
+ * Streaming response chunk.
272
+ */
273
+ export interface IntelligenceStreamChunk {
274
+ /** Content delta. */
125
275
  delta: string
276
+ /** Whether streaming is complete. */
126
277
  done: boolean
127
- usage?: AiUsageInfo
278
+ /** Final usage info (when done). */
279
+ usage?: IntelligenceUsageInfo
128
280
  }
129
281
 
130
- export interface AiCapabilityDescriptor {
282
+ /**
283
+ * Descriptor for a registered capability.
284
+ */
285
+ export interface IntelligenceCapabilityDescriptor {
286
+ /** Unique capability identifier. */
131
287
  id: string
132
- type: AiCapabilityType
288
+ /** Capability type. */
289
+ type: IntelligenceCapabilityType
290
+ /** Display name. */
133
291
  name: string
292
+ /** Description of the capability. */
134
293
  description: string
294
+ /** JSON schema for input validation. */
135
295
  inputSchema?: any
296
+ /** JSON schema for output validation. */
136
297
  outputSchema?: any
298
+ /** Default strategy for provider selection. */
137
299
  defaultStrategy?: string
138
- supportedProviders: AiProviderType[]
300
+ /** Providers that support this capability. */
301
+ supportedProviders: IntelligenceProviderType[]
302
+ /** Additional metadata. */
139
303
  metadata?: Record<string, any>
140
304
  }
141
305
 
142
- export interface AiChatPayload {
143
- messages: AiMessage[]
144
- context?: AiInvokeContext
306
+ /**
307
+ * Payload for chat capability.
308
+ */
309
+ export interface IntelligenceChatPayload {
310
+ /** Conversation messages. */
311
+ messages: IntelligenceMessage[]
312
+ /** Invocation context. */
313
+ context?: IntelligenceInvokeContext
314
+ /** Sampling temperature (0-2). */
145
315
  temperature?: number
316
+ /** Maximum tokens to generate. */
146
317
  maxTokens?: number
318
+ /** Top-p sampling parameter. */
147
319
  topP?: number
320
+ /** Frequency penalty (-2 to 2). */
148
321
  frequencyPenalty?: number
322
+ /** Presence penalty (-2 to 2). */
149
323
  presencePenalty?: number
324
+ /** Stop sequences. */
150
325
  stop?: string[]
151
326
  }
152
327
 
153
- export interface AiEmbeddingPayload {
328
+ /**
329
+ * Payload for embedding generation.
330
+ */
331
+ export interface IntelligenceEmbeddingPayload {
332
+ /** Text to embed (single or batch). */
154
333
  text: string | string[]
334
+ /** Specific model to use. */
155
335
  model?: string
156
336
  }
157
337
 
158
- export interface AiTranslatePayload {
338
+ /**
339
+ * Payload for translation capability.
340
+ */
341
+ export interface IntelligenceTranslatePayload {
342
+ /** Text to translate. */
159
343
  text: string
344
+ /** Source language (auto-detect if omitted). */
160
345
  sourceLang?: string
346
+ /** Target language. */
161
347
  targetLang: string
162
348
  }
163
349
 
164
- export interface AiSummarizePayload {
350
+ /**
351
+ * Payload for summarization capability.
352
+ */
353
+ export interface IntelligenceSummarizePayload {
354
+ /** Text to summarize. */
165
355
  text: string
356
+ /** Maximum summary length. */
166
357
  maxLength?: number
358
+ /** Summary style. */
167
359
  style?: 'concise' | 'detailed' | 'bullet-points'
168
360
  }
169
361
 
170
- export interface AiSDKConfig {
171
- providers: AiProviderConfig[]
362
+ // ============================================================================
363
+ // Extended Payload Types
364
+ // ============================================================================
365
+
366
+ /**
367
+ * Payload for text rewriting capability.
368
+ */
369
+ export interface IntelligenceRewritePayload {
370
+ /** Text to rewrite. */
371
+ text: string
372
+ /** Writing style. */
373
+ style?: 'formal' | 'casual' | 'professional' | 'creative' | 'simplified'
374
+ /** Tone of voice. */
375
+ tone?: 'neutral' | 'friendly' | 'authoritative' | 'humorous'
376
+ /** Target audience description. */
377
+ targetAudience?: string
378
+ /** Keywords to preserve. */
379
+ preserveKeywords?: string[]
380
+ }
381
+
382
+ /**
383
+ * Payload for grammar checking capability.
384
+ */
385
+ export interface IntelligenceGrammarCheckPayload {
386
+ /** Text to check. */
387
+ text: string
388
+ /** Language of the text. */
389
+ language?: string
390
+ /** Types of issues to check. */
391
+ checkTypes?: ('spelling' | 'grammar' | 'punctuation' | 'style')[]
392
+ /** Strictness level. */
393
+ strictness?: 'lenient' | 'standard' | 'strict'
394
+ }
395
+
396
+ /**
397
+ * Result from grammar checking capability.
398
+ */
399
+ export interface IntelligenceGrammarCheckResult {
400
+ /** Corrected text. */
401
+ correctedText: string
402
+ /** List of issues found. */
403
+ issues: Array<{
404
+ type: 'spelling' | 'grammar' | 'punctuation' | 'style'
405
+ original: string
406
+ suggestion: string
407
+ position: { start: number, end: number }
408
+ explanation?: string
409
+ }>
410
+ /** Overall score (0-100). */
411
+ score: number
412
+ }
413
+
414
+ /**
415
+ * Payload for code generation capability.
416
+ */
417
+ export interface IntelligenceCodeGeneratePayload {
418
+ /** Description of code to generate. */
419
+ description: string
420
+ /** Target programming language. */
421
+ language: string
422
+ /** Framework to use. */
423
+ framework?: string
424
+ /** Additional context. */
425
+ context?: string
426
+ /** Include unit tests. */
427
+ includeTests?: boolean
428
+ /** Include code comments. */
429
+ includeComments?: boolean
430
+ /** Code style preference. */
431
+ style?: 'minimal' | 'verbose' | 'production'
432
+ }
433
+
434
+ /**
435
+ * Result from code generation capability.
436
+ */
437
+ export interface IntelligenceCodeGenerateResult {
438
+ /** Generated code. */
439
+ code: string
440
+ /** Programming language. */
441
+ language: string
442
+ /** Explanation of the code. */
443
+ explanation?: string
444
+ /** Required dependencies. */
445
+ dependencies?: string[]
446
+ /** Generated tests. */
447
+ tests?: string
448
+ }
449
+
450
+ /**
451
+ * Payload for code explanation capability.
452
+ */
453
+ export interface IntelligenceCodeExplainPayload {
454
+ /** Code to explain. */
455
+ code: string
456
+ /** Programming language. */
457
+ language?: string
458
+ /** Explanation depth. */
459
+ depth?: 'brief' | 'detailed' | 'comprehensive'
460
+ /** Target audience level. */
461
+ targetAudience?: 'beginner' | 'intermediate' | 'expert'
462
+ }
463
+
464
+ /**
465
+ * Result from code explanation capability.
466
+ */
467
+ export interface IntelligenceCodeExplainResult {
468
+ /** Detailed explanation. */
469
+ explanation: string
470
+ /** Brief summary. */
471
+ summary: string
472
+ /** Key points. */
473
+ keyPoints: string[]
474
+ /** Complexity assessment. */
475
+ complexity?: 'simple' | 'moderate' | 'complex'
476
+ /** Programming concepts used. */
477
+ concepts?: string[]
478
+ }
479
+
480
+ /**
481
+ * Payload for code review capability.
482
+ */
483
+ export interface IntelligenceCodeReviewPayload {
484
+ /** Code to review. */
485
+ code: string
486
+ /** Programming language. */
487
+ language?: string
488
+ /** Additional context. */
489
+ context?: string
490
+ /** Areas to focus on. */
491
+ focusAreas?: ('security' | 'performance' | 'style' | 'bugs' | 'best-practices')[]
492
+ }
493
+
494
+ /**
495
+ * Result from code review capability.
496
+ */
497
+ export interface IntelligenceCodeReviewResult {
498
+ /** Review summary. */
499
+ summary: string
500
+ /** Overall score (0-100). */
501
+ score: number
502
+ /** Issues found. */
503
+ issues: Array<{
504
+ severity: 'critical' | 'warning' | 'info' | 'suggestion'
505
+ type: string
506
+ line?: number
507
+ message: string
508
+ suggestion?: string
509
+ }>
510
+ /** Suggested improvements. */
511
+ improvements: string[]
512
+ }
513
+
514
+ /**
515
+ * Payload for code refactoring capability.
516
+ */
517
+ export interface IntelligenceCodeRefactorPayload {
518
+ /** Code to refactor. */
519
+ code: string
520
+ /** Programming language. */
521
+ language?: string
522
+ /** Refactoring goals. */
523
+ goals?: ('readability' | 'performance' | 'maintainability' | 'modularity')[]
524
+ /** Preserve public interface. */
525
+ preserveInterface?: boolean
526
+ }
527
+
528
+ /**
529
+ * Result from code refactoring capability.
530
+ */
531
+ export interface IntelligenceCodeRefactorResult {
532
+ /** Refactored code. */
533
+ refactoredCode: string
534
+ /** List of changes made. */
535
+ changes: Array<{
536
+ type: string
537
+ description: string
538
+ before?: string
539
+ after?: string
540
+ }>
541
+ /** Explanation of changes. */
542
+ explanation: string
543
+ }
544
+
545
+ /**
546
+ * Payload for code debugging capability.
547
+ */
548
+ export interface IntelligenceCodeDebugPayload {
549
+ /** Code with bug. */
550
+ code: string
551
+ /** Error message. */
552
+ error?: string
553
+ /** Programming language. */
554
+ language?: string
555
+ /** Additional context. */
556
+ context?: string
557
+ /** Stack trace. */
558
+ stackTrace?: string
559
+ }
560
+
561
+ /**
562
+ * Result from code debugging capability.
563
+ */
564
+ export interface IntelligenceCodeDebugResult {
565
+ /** Bug diagnosis. */
566
+ diagnosis: string
567
+ /** Root cause analysis. */
568
+ rootCause: string
569
+ /** Fixed code. */
570
+ fixedCode: string
571
+ /** Explanation of the fix. */
572
+ explanation: string
573
+ /** Tips to prevent similar bugs. */
574
+ preventionTips?: string[]
575
+ }
576
+
577
+ /**
578
+ * Payload for intent detection capability.
579
+ */
580
+ export interface IntelligenceIntentDetectPayload {
581
+ /** Text to analyze. */
582
+ text: string
583
+ /** Additional context. */
584
+ context?: string
585
+ /** Possible intents to consider. */
586
+ possibleIntents?: string[]
587
+ /** Language of the text. */
588
+ language?: string
589
+ }
590
+
591
+ /**
592
+ * Result from intent detection capability.
593
+ */
594
+ export interface IntelligenceIntentDetectResult {
595
+ /** Detected intent. */
596
+ intent: string
597
+ /** Confidence score (0-1). */
598
+ confidence: number
599
+ /** Extracted entities. */
600
+ entities: Array<{
601
+ type: string
602
+ value: string
603
+ position?: { start: number, end: number }
604
+ }>
605
+ /** Secondary intents. */
606
+ subIntents?: Array<{ intent: string, confidence: number }>
607
+ }
608
+
609
+ /**
610
+ * Payload for sentiment analysis capability.
611
+ */
612
+ export interface IntelligenceSentimentAnalyzePayload {
613
+ /** Text to analyze. */
614
+ text: string
615
+ /** Language of the text. */
616
+ language?: string
617
+ /** Analysis granularity. */
618
+ granularity?: 'document' | 'sentence' | 'aspect'
619
+ /** Aspects to analyze. */
620
+ aspects?: string[]
621
+ }
622
+
623
+ /**
624
+ * Result from sentiment analysis capability.
625
+ */
626
+ export interface IntelligenceSentimentAnalyzeResult {
627
+ /** Overall sentiment. */
628
+ sentiment: 'positive' | 'negative' | 'neutral' | 'mixed'
629
+ /** Sentiment score (-1 to 1). */
630
+ score: number
631
+ /** Confidence score (0-1). */
632
+ confidence: number
633
+ /** Detected emotions. */
634
+ emotions?: Array<{ emotion: string, score: number }>
635
+ /** Aspect-based sentiments. */
636
+ aspects?: Array<{ aspect: string, sentiment: string, score: number }>
637
+ /** Sentiment keywords. */
638
+ keywords?: string[]
639
+ }
640
+
641
+ /**
642
+ * Payload for content extraction capability.
643
+ */
644
+ export interface IntelligenceContentExtractPayload {
645
+ /** Text to extract from. */
646
+ text: string
647
+ /** Types of entities to extract. */
648
+ extractTypes?: ('dates' | 'people' | 'locations' | 'organizations' | 'events' | 'products' | 'urls' | 'emails' | 'phones')[]
649
+ /** Language of the text. */
650
+ language?: string
651
+ /** Include surrounding context. */
652
+ includeContext?: boolean
653
+ }
654
+
655
+ /**
656
+ * Result from content extraction capability.
657
+ */
658
+ export interface IntelligenceContentExtractResult {
659
+ /** Extracted entities by type. */
660
+ entities: Record<string, Array<{
661
+ value: string
662
+ confidence: number
663
+ context?: string
664
+ position?: { start: number, end: number }
665
+ }>>
666
+ /** Content summary. */
667
+ summary?: string
668
+ }
669
+
670
+ /**
671
+ * Payload for keyword extraction capability.
672
+ */
673
+ export interface IntelligenceKeywordsExtractPayload {
674
+ /** Text to extract keywords from. */
675
+ text: string
676
+ /** Maximum keywords to return. */
677
+ maxKeywords?: number
678
+ /** Language of the text. */
679
+ language?: string
680
+ /** Include relevance scores. */
681
+ includeScores?: boolean
682
+ /** Types of keywords to extract. */
683
+ keywordTypes?: ('noun' | 'verb' | 'phrase' | 'entity')[]
684
+ }
685
+
686
+ /**
687
+ * Result from keyword extraction capability.
688
+ */
689
+ export interface IntelligenceKeywordsExtractResult {
690
+ /** Extracted keywords. */
691
+ keywords: Array<{
692
+ term: string
693
+ relevance: number
694
+ frequency?: number
695
+ type?: string
696
+ }>
697
+ }
698
+
699
+ /**
700
+ * Payload for text classification capability.
701
+ */
702
+ export interface IntelligenceClassificationPayload {
703
+ /** Text to classify. */
704
+ text: string
705
+ /** Available categories. */
706
+ categories: string[]
707
+ /** Allow multiple labels. */
708
+ multiLabel?: boolean
709
+ /** Confidence threshold. */
710
+ threshold?: number
711
+ }
712
+
713
+ /**
714
+ * Result from text classification capability.
715
+ */
716
+ export interface IntelligenceClassificationResult {
717
+ /** Classification predictions. */
718
+ predictions: Array<{
719
+ category: string
720
+ confidence: number
721
+ }>
722
+ /** Classification explanation. */
723
+ explanation?: string
724
+ }
725
+
726
+ // ============================================================================
727
+ // Audio Payload Types
728
+ // ============================================================================
729
+
730
+ /**
731
+ * Payload for text-to-speech capability.
732
+ */
733
+ export interface IntelligenceTTSPayload {
734
+ /** Text to convert to speech. */
735
+ text: string
736
+ /** Voice identifier. */
737
+ voice?: string
738
+ /** Language code. */
739
+ language?: string
740
+ /** Speech speed multiplier. */
741
+ speed?: number
742
+ /** Voice pitch adjustment. */
743
+ pitch?: number
744
+ /** Output audio format. */
745
+ format?: 'mp3' | 'wav' | 'ogg' | 'flac'
746
+ /** Audio quality. */
747
+ quality?: 'standard' | 'hd'
748
+ }
749
+
750
+ /**
751
+ * Result from text-to-speech capability.
752
+ */
753
+ export interface IntelligenceTTSResult {
754
+ /** Audio data. */
755
+ audio: ArrayBuffer | string
756
+ /** Audio format. */
757
+ format: string
758
+ /** Duration in seconds. */
759
+ duration?: number
760
+ /** Sample rate in Hz. */
761
+ sampleRate?: number
762
+ }
763
+
764
+ /**
765
+ * Payload for speech-to-text capability.
766
+ */
767
+ export interface IntelligenceSTTPayload {
768
+ /** Audio data. */
769
+ audio: ArrayBuffer | string
770
+ /** Expected language. */
771
+ language?: string
772
+ /** Audio format. */
773
+ format?: string
774
+ /** Include word timestamps. */
775
+ enableTimestamps?: boolean
776
+ /** Enable speaker diarization. */
777
+ enableSpeakerDiarization?: boolean
778
+ }
779
+
780
+ /**
781
+ * Result from speech-to-text capability.
782
+ */
783
+ export interface IntelligenceSTTResult {
784
+ /** Transcribed text. */
785
+ text: string
786
+ /** Confidence score (0-1). */
787
+ confidence: number
788
+ /** Detected language. */
789
+ language?: string
790
+ /** Transcription segments. */
791
+ segments?: Array<{
792
+ text: string
793
+ start: number
794
+ end: number
795
+ speaker?: string
796
+ confidence?: number
797
+ }>
798
+ }
799
+
800
+ /**
801
+ * Payload for audio transcription capability.
802
+ */
803
+ export interface IntelligenceAudioTranscribePayload {
804
+ /** Audio data. */
805
+ audio: ArrayBuffer | string
806
+ /** Expected language. */
807
+ language?: string
808
+ /** Audio format. */
809
+ format?: string
810
+ /** Task type. */
811
+ task?: 'transcribe' | 'translate'
812
+ /** Include timestamps. */
813
+ enableTimestamps?: boolean
814
+ /** Context prompt. */
815
+ prompt?: string
816
+ }
817
+
818
+ /**
819
+ * Result from audio transcription capability.
820
+ */
821
+ export interface IntelligenceAudioTranscribeResult {
822
+ /** Transcribed text. */
823
+ text: string
824
+ /** Detected language. */
825
+ language: string
826
+ /** Audio duration in seconds. */
827
+ duration: number
828
+ /** Transcription segments. */
829
+ segments?: Array<{
830
+ id: number
831
+ text: string
832
+ start: number
833
+ end: number
834
+ confidence?: number
835
+ }>
836
+ }
837
+
838
+ // ============================================================================
839
+ // Vision Extended Payload Types
840
+ // ============================================================================
841
+
842
+ /**
843
+ * Payload for image captioning capability.
844
+ */
845
+ export interface IntelligenceImageCaptionPayload {
846
+ /** Image source. */
847
+ source: IntelligenceVisionImageSource
848
+ /** Caption style. */
849
+ style?: 'brief' | 'detailed' | 'creative'
850
+ /** Output language. */
851
+ language?: string
852
+ /** Maximum caption length. */
853
+ maxLength?: number
854
+ }
855
+
856
+ /**
857
+ * Result from image captioning capability.
858
+ */
859
+ export interface IntelligenceImageCaptionResult {
860
+ /** Generated caption. */
861
+ caption: string
862
+ /** Alternative captions. */
863
+ alternativeCaptions?: string[]
864
+ /** Image tags. */
865
+ tags?: string[]
866
+ /** Confidence score (0-1). */
867
+ confidence?: number
868
+ }
869
+
870
+ /**
871
+ * Payload for image analysis capability.
872
+ */
873
+ export interface IntelligenceImageAnalyzePayload {
874
+ /** Image source. */
875
+ source: IntelligenceVisionImageSource
876
+ /** Types of analysis to perform. */
877
+ analysisTypes?: ('objects' | 'faces' | 'text' | 'colors' | 'composition' | 'scene' | 'emotions')[]
878
+ /** Output language. */
879
+ language?: string
880
+ /** Include detailed analysis. */
881
+ detailed?: boolean
882
+ }
883
+
884
+ /**
885
+ * Result from image analysis capability.
886
+ */
887
+ export interface IntelligenceImageAnalyzeResult {
888
+ /** Overall description. */
889
+ description: string
890
+ /** Detected objects. */
891
+ objects?: Array<{
892
+ name: string
893
+ confidence: number
894
+ boundingBox?: [number, number, number, number]
895
+ }>
896
+ /** Detected faces. */
897
+ faces?: Array<{
898
+ age?: number
899
+ gender?: string
900
+ emotion?: string
901
+ boundingBox?: [number, number, number, number]
902
+ }>
903
+ /** Dominant colors. */
904
+ colors?: Array<{
905
+ color: string
906
+ percentage: number
907
+ hex?: string
908
+ }>
909
+ /** Scene classification. */
910
+ scene?: {
911
+ type: string
912
+ confidence: number
913
+ attributes?: Record<string, any>
914
+ }
915
+ /** Detected text. */
916
+ text?: string[]
917
+ /** Image tags. */
918
+ tags?: string[]
919
+ }
920
+
921
+ /**
922
+ * Payload for image generation capability.
923
+ */
924
+ export interface IntelligenceImageGeneratePayload {
925
+ /** Generation prompt. */
926
+ prompt: string
927
+ /** Negative prompt. */
928
+ negativePrompt?: string
929
+ /** Image width in pixels. */
930
+ width?: number
931
+ /** Image height in pixels. */
932
+ height?: number
933
+ /** Style preset. */
934
+ style?: string
935
+ /** Image quality. */
936
+ quality?: 'standard' | 'hd'
937
+ /** Number of images to generate. */
938
+ count?: number
939
+ /** Random seed for reproducibility. */
940
+ seed?: number
941
+ }
942
+
943
+ /**
944
+ * Result from image generation capability.
945
+ */
946
+ export interface IntelligenceImageGenerateResult {
947
+ /** Generated images. */
948
+ images: Array<{
949
+ url?: string
950
+ base64?: string
951
+ revisedPrompt?: string
952
+ }>
953
+ /** Seed used for generation. */
954
+ seed?: number
955
+ }
956
+
957
+ /**
958
+ * Payload for image editing capability.
959
+ */
960
+ export interface IntelligenceImageEditPayload {
961
+ /** Source image. */
962
+ source: IntelligenceVisionImageSource
963
+ /** Mask for inpainting. */
964
+ mask?: IntelligenceVisionImageSource
965
+ /** Edit prompt. */
966
+ prompt: string
967
+ /** Type of edit. */
968
+ editType?: 'inpaint' | 'outpaint' | 'variation' | 'upscale'
969
+ }
970
+
971
+ /**
972
+ * Result from image editing capability.
973
+ */
974
+ export interface IntelligenceImageEditResult {
975
+ /** Edited image. */
976
+ image: {
977
+ url?: string
978
+ base64?: string
979
+ }
980
+ /** Revised prompt. */
981
+ revisedPrompt?: string
982
+ }
983
+
984
+ // ============================================================================
985
+ // RAG & Search Payload Types
986
+ // ============================================================================
987
+
988
+ /**
989
+ * Payload for RAG query capability.
990
+ */
991
+ export interface IntelligenceRAGQueryPayload {
992
+ /** Query text. */
993
+ query: string
994
+ /** Documents to search. */
995
+ documents?: Array<{
996
+ id: string
997
+ content: string
998
+ metadata?: Record<string, any>
999
+ }>
1000
+ /** Number of top results. */
1001
+ topK?: number
1002
+ /** Relevance threshold. */
1003
+ threshold?: number
1004
+ /** Enable reranking. */
1005
+ rerank?: boolean
1006
+ /** Include context in response. */
1007
+ includeContext?: boolean
1008
+ }
1009
+
1010
+ /**
1011
+ * Result from RAG query capability.
1012
+ */
1013
+ export interface IntelligenceRAGQueryResult {
1014
+ /** Generated answer. */
1015
+ answer: string
1016
+ /** Source documents. */
1017
+ sources: Array<{
1018
+ id: string
1019
+ content: string
1020
+ relevance: number
1021
+ metadata?: Record<string, any>
1022
+ }>
1023
+ /** Confidence score (0-1). */
1024
+ confidence: number
1025
+ }
1026
+
1027
+ /**
1028
+ * Payload for semantic search capability.
1029
+ */
1030
+ export interface IntelligenceSemanticSearchPayload {
1031
+ /** Search query. */
1032
+ query: string
1033
+ /** Documents to search. */
1034
+ documents: Array<{
1035
+ id: string
1036
+ content: string
1037
+ embedding?: number[]
1038
+ metadata?: Record<string, any>
1039
+ }>
1040
+ /** Number of top results. */
1041
+ topK?: number
1042
+ /** Similarity threshold. */
1043
+ threshold?: number
1044
+ }
1045
+
1046
+ /**
1047
+ * Result from semantic search capability.
1048
+ */
1049
+ export interface IntelligenceSemanticSearchResult {
1050
+ /** Search results. */
1051
+ results: Array<{
1052
+ id: string
1053
+ content: string
1054
+ score: number
1055
+ metadata?: Record<string, any>
1056
+ }>
1057
+ }
1058
+
1059
+ /**
1060
+ * Payload for document reranking capability.
1061
+ */
1062
+ export interface IntelligenceRerankPayload {
1063
+ /** Query for relevance scoring. */
1064
+ query: string
1065
+ /** Documents to rerank. */
1066
+ documents: Array<{
1067
+ id: string
1068
+ content: string
1069
+ metadata?: Record<string, any>
1070
+ }>
1071
+ /** Number of top results. */
1072
+ topK?: number
1073
+ }
1074
+
1075
+ /**
1076
+ * Result from document reranking capability.
1077
+ */
1078
+ export interface IntelligenceRerankResult {
1079
+ /** Reranked results. */
1080
+ results: Array<{
1081
+ id: string
1082
+ content: string
1083
+ score: number
1084
+ originalRank: number
1085
+ metadata?: Record<string, any>
1086
+ }>
1087
+ }
1088
+
1089
+ // ============================================================================
1090
+ // Prompt Workflow System
1091
+ // ============================================================================
1092
+
1093
+ export type PromptVariableType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'file' | 'image'
1094
+
1095
+ export interface PromptVariable {
1096
+ name: string
1097
+ type: PromptVariableType
1098
+ description?: string
1099
+ required?: boolean
1100
+ default?: any
1101
+ validation?: {
1102
+ minLength?: number
1103
+ maxLength?: number
1104
+ pattern?: string
1105
+ enum?: any[]
1106
+ min?: number
1107
+ max?: number
1108
+ }
1109
+ }
1110
+
1111
+ export interface PromptTemplate {
1112
+ id: string
1113
+ name: string
1114
+ description?: string
1115
+ template: string
1116
+ variables: PromptVariable[]
1117
+ category?: string
1118
+ tags?: string[]
1119
+ version?: string
1120
+ author?: string
1121
+ createdAt?: number
1122
+ updatedAt?: number
1123
+ }
1124
+
1125
+ export interface PromptStep {
1126
+ id: string
1127
+ name: string
1128
+ type: 'prompt' | 'condition' | 'loop' | 'parallel' | 'transform' | 'api-call'
1129
+ config: PromptStepConfig
1130
+ next?: string | PromptStepCondition[]
1131
+ onError?: 'fail' | 'skip' | 'retry' | string
1132
+ retryConfig?: {
1133
+ maxRetries: number
1134
+ delay: number
1135
+ backoff?: 'linear' | 'exponential'
1136
+ }
1137
+ }
1138
+
1139
+ export interface PromptStepConfig {
1140
+ // For prompt type
1141
+ templateId?: string
1142
+ template?: string
1143
+ variables?: Record<string, any>
1144
+ capabilityId?: string
1145
+ modelPreference?: string[]
1146
+ // For condition type
1147
+ condition?: string
1148
+ // For loop type
1149
+ items?: string
1150
+ maxIterations?: number
1151
+ // For parallel type
1152
+ branches?: string[]
1153
+ // For transform type
1154
+ transform?: string
1155
+ // For api-call type
1156
+ url?: string
1157
+ method?: string
1158
+ headers?: Record<string, string>
1159
+ body?: any
1160
+ }
1161
+
1162
+ export interface PromptStepCondition {
1163
+ condition: string
1164
+ next: string
1165
+ }
1166
+
1167
+ export interface PromptWorkflow {
1168
+ id: string
1169
+ name: string
1170
+ description?: string
1171
+ version?: string
1172
+ steps: PromptStep[]
1173
+ entryPoint: string
1174
+ variables: PromptVariable[]
1175
+ outputs?: string[]
1176
+ metadata?: Record<string, any>
1177
+ createdAt?: number
1178
+ updatedAt?: number
1179
+ }
1180
+
1181
+ export interface PromptWorkflowExecution {
1182
+ id: string
1183
+ workflowId: string
1184
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
1185
+ startedAt: number
1186
+ completedAt?: number
1187
+ inputs: Record<string, any>
1188
+ outputs?: Record<string, any>
1189
+ steps: Array<{
1190
+ stepId: string
1191
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped'
1192
+ startedAt?: number
1193
+ completedAt?: number
1194
+ input?: any
1195
+ output?: any
1196
+ error?: string
1197
+ }>
1198
+ error?: string
1199
+ }
1200
+
1201
+ export interface PromptWorkflowContext {
1202
+ execution: PromptWorkflowExecution
1203
+ variables: Record<string, any>
1204
+ stepResults: Record<string, any>
1205
+ currentStep?: string
1206
+ }
1207
+
1208
+ // ============================================================================
1209
+ // TuffIntelligence Orchestration
1210
+ // ============================================================================
1211
+
1212
+ export type TuffIntelligenceSessionStatus
1213
+ = | 'idle'
1214
+ | 'planning'
1215
+ | 'planned'
1216
+ | 'executing'
1217
+ | 'reflecting'
1218
+ | 'waiting_approval'
1219
+ | 'paused_disconnect'
1220
+ | 'resuming'
1221
+ | 'completed'
1222
+ | 'failed'
1223
+ | 'cancelled'
1224
+
1225
+ export type TuffIntelligenceActionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
1226
+
1227
+ export interface TuffIntelligenceActionNode {
1228
+ id: string
1229
+ type: 'intent' | 'plan' | 'tool' | 'agent' | 'capability' | 'reflect' | 'result'
1230
+ title: string
1231
+ status: TuffIntelligenceActionStatus
1232
+ capabilityId?: string
1233
+ toolId?: string
1234
+ input?: unknown
1235
+ output?: unknown
1236
+ error?: string
1237
+ parentId?: string
1238
+ metadata?: Record<string, any>
1239
+ createdAt: number
1240
+ updatedAt?: number
1241
+ }
1242
+
1243
+ export interface TuffIntelligenceActionGraph {
1244
+ sessionId: string
1245
+ nodes: TuffIntelligenceActionNode[]
1246
+ edges: Array<{ from: string, to: string, kind?: 'sequence' | 'dependency' | 'reflection' }>
1247
+ version: number
1248
+ updatedAt: number
1249
+ }
1250
+
1251
+ export interface TuffIntelligenceTurn {
1252
+ id: string
1253
+ sessionId: string
1254
+ status: TuffIntelligenceSessionStatus
1255
+ objective?: string
1256
+ userInput?: string
1257
+ plannerModel?: string
1258
+ executionModel?: string
1259
+ actionIds: string[]
1260
+ reflection?: string
1261
+ error?: string
1262
+ metadata?: Record<string, any>
1263
+ startedAt: number
1264
+ completedAt?: number
1265
+ }
1266
+
1267
+ export interface TuffIntelligenceSession {
1268
+ id: string
1269
+ status: TuffIntelligenceSessionStatus
1270
+ pauseReason?: 'client_disconnect' | 'heartbeat_timeout' | 'manual_pause' | 'system_preempted'
1271
+ lastEventSeq?: number
1272
+ lastCheckpointAt?: number
1273
+ resumeHint?: string
1274
+ objective?: string
1275
+ context?: Record<string, any>
1276
+ metadata?: Record<string, any>
1277
+ currentTurnId?: string
1278
+ createdAt: number
1279
+ updatedAt: number
1280
+ }
1281
+
1282
+ export interface TuffIntelligenceTraceEvent {
1283
+ id: string
1284
+ sessionId: string
1285
+ turnId?: string
1286
+ type:
1287
+ | 'session.started'
1288
+ | 'session.resumed'
1289
+ | 'session.paused'
1290
+ | 'session.cancelled'
1291
+ | 'plan.created'
1292
+ | 'plan.updated'
1293
+ | 'execution.started'
1294
+ | 'execution.completed'
1295
+ | 'execution.failed'
1296
+ | 'tool.called'
1297
+ | 'tool.completed'
1298
+ | 'tool.approval_required'
1299
+ | 'tool.approved'
1300
+ | 'tool.rejected'
1301
+ | 'reflection.completed'
1302
+ | 'state.snapshot'
1303
+ level: 'debug' | 'info' | 'warn' | 'error'
1304
+ message: string
1305
+ payload?: Record<string, any>
1306
+ timestamp: number
1307
+ }
1308
+
1309
+ export interface TuffIntelligenceApprovalTicket {
1310
+ id: string
1311
+ sessionId: string
1312
+ turnId?: string
1313
+ actionId?: string
1314
+ toolId: string
1315
+ riskLevel: 'low' | 'medium' | 'high' | 'critical'
1316
+ reason: string
1317
+ status: 'pending' | 'approved' | 'rejected'
1318
+ requestedAt: number
1319
+ resolvedAt?: number
1320
+ resolvedBy?: string
1321
+ metadata?: Record<string, any>
1322
+ }
1323
+
1324
+ export interface TuffIntelligenceStateSnapshot {
1325
+ sessionId: string
1326
+ status: TuffIntelligenceSessionStatus
1327
+ currentTurn?: TuffIntelligenceTurn
1328
+ actionGraph: TuffIntelligenceActionGraph
1329
+ pendingApprovals: TuffIntelligenceApprovalTicket[]
1330
+ lastTraceEvent?: TuffIntelligenceTraceEvent
1331
+ updatedAt: number
1332
+ }
1333
+
1334
+ // ============================================================================
1335
+ // Agent System
1336
+ // ============================================================================
1337
+
1338
+ /**
1339
+ * Tool definition for an AI agent.
1340
+ */
1341
+ export interface IntelligenceAgentTool {
1342
+ /** Tool name. */
1343
+ name: string
1344
+ /** Tool description. */
1345
+ description: string
1346
+ /** Parameter schema. */
1347
+ parameters: {
1348
+ type: 'object'
1349
+ properties: Record<string, {
1350
+ type: string
1351
+ description?: string
1352
+ enum?: any[]
1353
+ required?: boolean
1354
+ }>
1355
+ required?: string[]
1356
+ }
1357
+ /** Handler function name. */
1358
+ handler?: string
1359
+ }
1360
+
1361
+ /**
1362
+ * Payload for agent capability.
1363
+ */
1364
+ export interface IntelligenceAgentPayload {
1365
+ /** Task description. */
1366
+ task: string
1367
+ /** Available tools. */
1368
+ tools?: IntelligenceAgentTool[]
1369
+ /** Additional context. */
1370
+ context?: string
1371
+ /** Maximum iterations. */
1372
+ maxIterations?: number
1373
+ /** Conversation memory. */
1374
+ memory?: Array<{ role: string, content: string }>
1375
+ /** Constraints for the agent. */
1376
+ constraints?: string[]
1377
+ }
1378
+
1379
+ /**
1380
+ * Result from agent capability.
1381
+ */
1382
+ export interface IntelligenceAgentResult {
1383
+ /** Final result. */
1384
+ result: string
1385
+ /** Reasoning steps. */
1386
+ steps: Array<{
1387
+ thought: string
1388
+ action?: string
1389
+ actionInput?: any
1390
+ observation?: string
1391
+ }>
1392
+ /** Tool call history. */
1393
+ toolCalls: Array<{
1394
+ tool: string
1395
+ input: any
1396
+ output: any
1397
+ }>
1398
+ /** Number of iterations. */
1399
+ iterations: number
1400
+ }
1401
+
1402
+ /**
1403
+ * SDK configuration.
1404
+ */
1405
+ export interface IntelligenceSDKConfig {
1406
+ /** Provider configurations. */
1407
+ providers: IntelligenceProviderConfig[]
1408
+ /** Default strategy ID. */
172
1409
  defaultStrategy: string
1410
+ /** Enable audit logging. */
173
1411
  enableAudit: boolean
1412
+ /** Enable result caching. */
174
1413
  enableCache: boolean
1414
+ /** Enable quota management. */
1415
+ enableQuota?: boolean
1416
+ /** Cache expiration in seconds. */
175
1417
  cacheExpiration?: number
176
- capabilities?: Record<string, AiCapabilityRoutingConfig>
1418
+ /** Capability routing configurations. */
1419
+ capabilities?: Record<string, IntelligenceCapabilityRoutingConfig>
177
1420
  }
178
1421
 
179
- export interface AiStrategyConfig {
1422
+ /**
1423
+ * Strategy configuration.
1424
+ */
1425
+ export interface IntelligenceStrategyConfig {
1426
+ /** Strategy ID. */
180
1427
  id: string
1428
+ /** Strategy name. */
181
1429
  name: string
1430
+ /** Strategy type. */
182
1431
  type: 'rule-based' | 'adaptive' | 'custom'
1432
+ /** Strategy rules. */
183
1433
  rules?: any
1434
+ /** Strategy priority. */
184
1435
  priority?: number
185
1436
  }
186
1437
 
187
- export interface AiAuditLog {
1438
+ /**
1439
+ * Audit log entry.
1440
+ */
1441
+ export interface IntelligenceAuditLog {
1442
+ /** Trace ID. */
188
1443
  traceId: string
1444
+ /** Timestamp. */
189
1445
  timestamp: number
1446
+ /** Capability ID. */
190
1447
  capabilityId: string
1448
+ /** Provider ID. */
191
1449
  provider: string
1450
+ /** Model used. */
192
1451
  model: string
1452
+ /** Prompt hash. */
193
1453
  promptHash?: string
1454
+ /** Caller identifier. */
194
1455
  caller?: string
195
- usage: AiUsageInfo
1456
+ /** Usage information. */
1457
+ usage: IntelligenceUsageInfo
1458
+ /** Latency in milliseconds. */
196
1459
  latency: number
1460
+ /** Success status. */
197
1461
  success: boolean
1462
+ /** Error message. */
198
1463
  error?: string
199
1464
  }
200
1465
 
201
- export interface AiCapabilityProviderBinding {
1466
+ /**
1467
+ * Provider binding for a capability.
1468
+ */
1469
+ export interface IntelligenceCapabilityProviderBinding {
1470
+ /** Provider ID. */
202
1471
  providerId: string
1472
+ /** Specific models to use. */
203
1473
  models?: string[]
1474
+ /** Priority for selection. */
204
1475
  priority?: number
1476
+ /** Whether binding is enabled. */
205
1477
  enabled?: boolean
1478
+ /** Additional metadata. */
206
1479
  metadata?: Record<string, any>
207
1480
  }
208
1481
 
209
- export interface AiCapabilityRoutingConfig {
1482
+ /**
1483
+ * Routing configuration for a capability.
1484
+ */
1485
+ export interface IntelligenceCapabilityRoutingConfig {
1486
+ /** Display label. */
210
1487
  label?: string
1488
+ /** Description. */
211
1489
  description?: string
212
- providers: AiCapabilityProviderBinding[]
1490
+ /** Provider bindings. */
1491
+ providers: IntelligenceCapabilityProviderBinding[]
1492
+ /** Prompt template. */
213
1493
  promptTemplate?: string
1494
+ /** Test resource directory. */
214
1495
  testResourceDir?: string
1496
+ /** Additional metadata. */
215
1497
  metadata?: Record<string, any>
216
1498
  }
217
1499
 
218
- export interface AiSDKPersistedConfig {
219
- providers: AiProviderConfig[]
1500
+ /**
1501
+ * Persisted SDK configuration.
1502
+ */
1503
+ export interface IntelligenceSDKPersistedConfig {
1504
+ /** Provider configurations. */
1505
+ providers: IntelligenceProviderConfig[]
1506
+ /** Global configuration. */
220
1507
  globalConfig: {
221
1508
  defaultStrategy: string
222
1509
  enableAudit: boolean
223
1510
  enableCache: boolean
224
1511
  cacheExpiration?: number
225
1512
  }
226
- capabilities?: Record<string, AiCapabilityRoutingConfig>
1513
+ /** Capability configurations. */
1514
+ capabilities?: Record<string, IntelligenceCapabilityRoutingConfig>
1515
+ /** Configuration version. */
227
1516
  version: number
228
1517
  }
229
1518
 
230
- export interface AiProviderAdapter {
231
- readonly type: AiProviderType
232
- getConfig: () => AiProviderConfig
233
- updateConfig: (config: Partial<AiProviderConfig>) => void
1519
+ /**
1520
+ * Provider adapter interface.
1521
+ */
1522
+ export interface IntelligenceProviderAdapter {
1523
+ /** Provider type. */
1524
+ readonly type: IntelligenceProviderType
1525
+ /** Get provider configuration. */
1526
+ getConfig: () => IntelligenceProviderConfig
1527
+ /** Update provider configuration. */
1528
+ updateConfig: (config: Partial<IntelligenceProviderConfig>) => void
1529
+ /** Check if provider is enabled. */
234
1530
  isEnabled: () => boolean
235
- chat: (payload: AiChatPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
236
- chatStream: (
237
- payload: AiChatPayload,
238
- options: AiInvokeOptions,
239
- ) => AsyncGenerator<AiStreamChunk>
240
- embedding: (payload: AiEmbeddingPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<number[]>>
241
- translate: (payload: AiTranslatePayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
242
- visionOcr: (
243
- payload: AiVisionOcrPayload,
244
- options: AiInvokeOptions,
245
- ) => Promise<AiInvokeResult<AiVisionOcrResult>>
246
- }
247
-
248
- export interface ProviderManagerAdapter {
1531
+
1532
+ // Core text capabilities
1533
+ chat: (payload: IntelligenceChatPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
1534
+ chatStream: (payload: IntelligenceChatPayload, options: IntelligenceInvokeOptions) => AsyncGenerator<IntelligenceStreamChunk>
1535
+ embedding: (payload: IntelligenceEmbeddingPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<number[]>>
1536
+ translate: (payload: IntelligenceTranslatePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
1537
+ summarize?: (payload: IntelligenceSummarizePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
1538
+ rewrite?: (payload: IntelligenceRewritePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<string>>
1539
+ grammarCheck?: (payload: IntelligenceGrammarCheckPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceGrammarCheckResult>>
1540
+
1541
+ // Code capabilities
1542
+ codeGenerate?: (payload: IntelligenceCodeGeneratePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeGenerateResult>>
1543
+ codeExplain?: (payload: IntelligenceCodeExplainPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeExplainResult>>
1544
+ codeReview?: (payload: IntelligenceCodeReviewPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeReviewResult>>
1545
+ codeRefactor?: (payload: IntelligenceCodeRefactorPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeRefactorResult>>
1546
+ codeDebug?: (payload: IntelligenceCodeDebugPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceCodeDebugResult>>
1547
+
1548
+ // Analysis capabilities
1549
+ intentDetect?: (payload: IntelligenceIntentDetectPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceIntentDetectResult>>
1550
+ sentimentAnalyze?: (payload: IntelligenceSentimentAnalyzePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceSentimentAnalyzeResult>>
1551
+ contentExtract?: (payload: IntelligenceContentExtractPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceContentExtractResult>>
1552
+ keywordsExtract?: (payload: IntelligenceKeywordsExtractPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceKeywordsExtractResult>>
1553
+ classification?: (payload: IntelligenceClassificationPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceClassificationResult>>
1554
+
1555
+ // Vision capabilities
1556
+ visionOcr: (payload: IntelligenceVisionOcrPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceVisionOcrResult>>
1557
+ imageCaption?: (payload: IntelligenceImageCaptionPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageCaptionResult>>
1558
+ imageAnalyze?: (payload: IntelligenceImageAnalyzePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageAnalyzeResult>>
1559
+ imageGenerate?: (payload: IntelligenceImageGeneratePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageGenerateResult>>
1560
+ imageEdit?: (payload: IntelligenceImageEditPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceImageEditResult>>
1561
+
1562
+ // Audio capabilities
1563
+ tts?: (payload: IntelligenceTTSPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceTTSResult>>
1564
+ stt?: (payload: IntelligenceSTTPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceSTTResult>>
1565
+ audioTranscribe?: (payload: IntelligenceAudioTranscribePayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceAudioTranscribeResult>>
1566
+
1567
+ // RAG & Search capabilities
1568
+ ragQuery?: (payload: IntelligenceRAGQueryPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceRAGQueryResult>>
1569
+ semanticSearch?: (payload: IntelligenceSemanticSearchPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceSemanticSearchResult>>
1570
+ rerank?: (payload: IntelligenceRerankPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceRerankResult>>
1571
+
1572
+ // Agent capabilities
1573
+ agent?: (payload: IntelligenceAgentPayload, options: IntelligenceInvokeOptions) => Promise<IntelligenceInvokeResult<IntelligenceAgentResult>>
1574
+ }
1575
+
1576
+ /**
1577
+ * Provider manager adapter interface.
1578
+ */
1579
+ export interface IntelligenceProviderManagerAdapter {
1580
+ /** Clear all providers. */
249
1581
  clear: () => void
250
- registerFromConfig: (config: AiProviderConfig) => AiProviderAdapter
251
- getEnabled: () => AiProviderAdapter[]
252
- get: (providerId: string) => AiProviderAdapter | undefined
253
- createProviderInstance: (config: AiProviderConfig) => AiProviderAdapter
1582
+ /** Register provider from configuration. */
1583
+ registerFromConfig: (config: IntelligenceProviderConfig) => IntelligenceProviderAdapter
1584
+ /** Get all enabled providers. */
1585
+ getEnabled: () => IntelligenceProviderAdapter[]
1586
+ /** Get provider by ID. */
1587
+ get: (providerId: string) => IntelligenceProviderAdapter | undefined
1588
+ /** Create provider instance. */
1589
+ createProviderInstance: (config: IntelligenceProviderConfig) => IntelligenceProviderAdapter
254
1590
  }
255
1591
 
256
- export interface AISDKGlobalConfig {
1592
+ export type ProviderManagerAdapter = IntelligenceProviderManagerAdapter
1593
+
1594
+ /**
1595
+ * Global SDK configuration.
1596
+ */
1597
+ export interface IntelligenceGlobalConfig {
1598
+ /** Default strategy ID. */
257
1599
  defaultStrategy: string
1600
+ /** Enable audit logging. */
258
1601
  enableAudit: boolean
1602
+ /** Enable result caching. */
259
1603
  enableCache: boolean
1604
+ /** Cache expiration in seconds. */
260
1605
  cacheExpiration?: number
1606
+ /** Maximum retry attempts. */
261
1607
  maxRetries?: number
1608
+ /** Default timeout in milliseconds. */
262
1609
  defaultTimeout?: number
1610
+ /** Enable logging. */
263
1611
  enableLogging?: boolean
1612
+ /** Log level. */
264
1613
  logLevel?: 'debug' | 'info' | 'warn' | 'error'
1614
+ /** Enable caching. */
265
1615
  enableCaching?: boolean
1616
+ /** Cache size limit. */
266
1617
  cacheSize?: number
1618
+ /** Fallback strategy. */
267
1619
  fallbackStrategy?: 'next-available' | 'fail-fast' | 'round-robin'
1620
+ /** Allow parallel requests. */
268
1621
  parallelRequests?: boolean
269
1622
  }
270
1623
 
271
- export interface TestResult {
1624
+ /**
1625
+ * Test result structure.
1626
+ */
1627
+ export interface IntelligenceTestResult {
1628
+ /** Whether test succeeded. */
272
1629
  success: boolean
1630
+ /** Result message. */
273
1631
  message?: string
1632
+ /** Latency in milliseconds. */
274
1633
  latency?: number
1634
+ /** Test timestamp. */
275
1635
  timestamp: number
276
1636
  }
277
1637
 
278
- export interface AISDKCapabilityConfig {
1638
+ export type TestResult = IntelligenceTestResult
1639
+
1640
+ /**
1641
+ * Capability configuration for SDK.
1642
+ */
1643
+ export interface IntelligenceCapabilityConfig {
1644
+ /** Capability ID. */
279
1645
  id: string
1646
+ /** Display label. */
280
1647
  label: string
1648
+ /** Description. */
281
1649
  description?: string
282
- providers: AiCapabilityProviderBinding[]
1650
+ /** Provider bindings. */
1651
+ providers: IntelligenceCapabilityProviderBinding[]
1652
+ /** Prompt template. */
283
1653
  promptTemplate?: string
1654
+ /** Test resource directory. */
284
1655
  testResourceDir?: string
1656
+ /** Additional metadata. */
285
1657
  metadata?: Record<string, any>
286
1658
  }
287
1659
 
288
- export interface AISDKStorageData {
289
- providers: AiProviderConfig[]
290
- globalConfig: AISDKGlobalConfig
291
- capabilities: Record<string, AISDKCapabilityConfig>
1660
+ /**
1661
+ * Storage data structure for SDK.
1662
+ */
1663
+ export interface IntelligenceStorageData {
1664
+ /** Provider configurations. */
1665
+ providers: IntelligenceProviderConfig[]
1666
+ /** Global configuration. */
1667
+ globalConfig: IntelligenceGlobalConfig
1668
+ /** Capability configurations. */
1669
+ capabilities: Record<string, IntelligenceCapabilityConfig>
1670
+ /** Data version. */
292
1671
  version: number
293
1672
  }
294
1673
 
295
- export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
1674
+ /**
1675
+ * Default provider configurations.
1676
+ */
1677
+ export const DEFAULT_PROVIDERS: IntelligenceProviderConfig[] = [
296
1678
  {
297
1679
  id: 'openai-default',
298
- type: AiProviderType.OPENAI,
1680
+ type: IntelligenceProviderType.OPENAI,
299
1681
  name: 'OpenAI',
300
1682
  enabled: false,
301
1683
  priority: 1,
@@ -306,7 +1688,7 @@ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
306
1688
  },
307
1689
  {
308
1690
  id: 'anthropic-default',
309
- type: AiProviderType.ANTHROPIC,
1691
+ type: IntelligenceProviderType.ANTHROPIC,
310
1692
  name: 'Anthropic',
311
1693
  enabled: false,
312
1694
  priority: 2,
@@ -317,7 +1699,7 @@ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
317
1699
  },
318
1700
  {
319
1701
  id: 'deepseek-default',
320
- type: AiProviderType.DEEPSEEK,
1702
+ type: IntelligenceProviderType.DEEPSEEK,
321
1703
  name: 'DeepSeek',
322
1704
  enabled: false,
323
1705
  priority: 2,
@@ -328,7 +1710,7 @@ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
328
1710
  },
329
1711
  {
330
1712
  id: 'siliconflow-default',
331
- type: AiProviderType.SILICONFLOW,
1713
+ type: IntelligenceProviderType.SILICONFLOW,
332
1714
  name: 'SiliconFlow',
333
1715
  enabled: false,
334
1716
  priority: 2,
@@ -348,9 +1730,24 @@ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
348
1730
  timeout: 30000,
349
1731
  rateLimit: {},
350
1732
  },
1733
+ {
1734
+ id: 'tuff-nexus-default',
1735
+ type: IntelligenceProviderType.CUSTOM,
1736
+ name: 'Tuff Nexus',
1737
+ enabled: false,
1738
+ priority: 1,
1739
+ baseUrl: `${NEXUS_BASE_URL}/v1`,
1740
+ models: ['gpt-4o', 'gpt-4o-mini'],
1741
+ defaultModel: 'gpt-4o-mini',
1742
+ timeout: 30000,
1743
+ rateLimit: {},
1744
+ metadata: {
1745
+ origin: 'tuff-nexus',
1746
+ },
1747
+ },
351
1748
  {
352
1749
  id: 'local-default',
353
- type: AiProviderType.LOCAL,
1750
+ type: IntelligenceProviderType.LOCAL,
354
1751
  name: 'Local Model',
355
1752
  enabled: false,
356
1753
  priority: 3,
@@ -361,18 +1758,18 @@ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
361
1758
  },
362
1759
  ]
363
1760
 
364
- export const DEFAULT_GLOBAL_CONFIG: AISDKGlobalConfig = {
1761
+ export const DEFAULT_GLOBAL_CONFIG: IntelligenceGlobalConfig = {
365
1762
  defaultStrategy: 'adaptive-default',
366
1763
  enableAudit: false,
367
1764
  enableCache: true,
368
1765
  cacheExpiration: 3600,
369
1766
  }
370
1767
 
371
- export const DEFAULT_CAPABILITIES: Record<string, AISDKCapabilityConfig> = {
1768
+ export const DEFAULT_CAPABILITIES: Record<string, IntelligenceCapabilityConfig> = {
372
1769
  'text.chat': {
373
1770
  id: 'text.chat',
374
1771
  label: '对话 / Chat',
375
- description: '默认用于系统对话、翻译、总结等文本任务的模型集合',
1772
+ description: '通用对话、问答、助理类能力',
376
1773
  providers: [
377
1774
  { providerId: 'openai-default', priority: 1, enabled: true },
378
1775
  { providerId: 'anthropic-default', priority: 2, enabled: true },
@@ -605,3 +2002,17 @@ export const DEFAULT_CAPABILITIES: Record<string, AISDKCapabilityConfig> = {
605
2002
  ],
606
2003
  },
607
2004
  }
2005
+
2006
+ export interface CapabilityTestResult {
2007
+ success: boolean
2008
+ message?: string
2009
+ latency?: number
2010
+ provider?: string
2011
+ model?: string
2012
+ textPreview?: string
2013
+ timestamp: number
2014
+ }
2015
+
2016
+ export interface CapabilityBinding extends IntelligenceCapabilityProviderBinding {
2017
+ provider?: IntelligenceProviderConfig
2018
+ }