sa2kit 3.3.0 → 3.6.0

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 (143) hide show
  1. package/dist/{chunk-LGVPFYPR.mjs → chunk-4H3SGG3T.mjs} +27 -3
  2. package/dist/chunk-4H3SGG3T.mjs.map +1 -0
  3. package/dist/{chunk-KVYHCGRY.js → chunk-7Z3XR2Y4.js} +552 -263
  4. package/dist/chunk-7Z3XR2Y4.js.map +1 -0
  5. package/dist/{chunk-5H2FICSO.js → chunk-LBMUIWJR.js} +27 -3
  6. package/dist/chunk-LBMUIWJR.js.map +1 -0
  7. package/dist/chunk-XPY45Y75.js +1143 -0
  8. package/dist/chunk-XPY45Y75.js.map +1 -0
  9. package/dist/{chunk-YIRPPMCN.mjs → chunk-XSTMLLJV.mjs} +474 -198
  10. package/dist/chunk-XSTMLLJV.mjs.map +1 -0
  11. package/dist/chunk-ZJLS5JU5.mjs +1090 -0
  12. package/dist/chunk-ZJLS5JU5.mjs.map +1 -0
  13. package/dist/common/aiApi/client/index.d.mts +71 -0
  14. package/dist/common/aiApi/client/index.d.ts +71 -0
  15. package/dist/common/aiApi/client/index.js +165 -0
  16. package/dist/common/aiApi/client/index.js.map +1 -0
  17. package/dist/common/aiApi/client/index.mjs +151 -0
  18. package/dist/common/aiApi/client/index.mjs.map +1 -0
  19. package/dist/common/aiApi/index.d.mts +184 -0
  20. package/dist/common/aiApi/index.d.ts +184 -0
  21. package/dist/common/aiApi/index.js +217 -0
  22. package/dist/common/aiApi/index.mjs +4 -0
  23. package/dist/common/aiApi/server/index.d.mts +3 -0
  24. package/dist/common/aiApi/server/index.d.ts +3 -0
  25. package/dist/common/aiApi/server/index.js +217 -0
  26. package/dist/common/aiApi/server/index.mjs +4 -0
  27. package/dist/common/auth/server/index.js +8 -8
  28. package/dist/common/auth/server/index.mjs +2 -2
  29. package/dist/common/components/index.js +176 -177
  30. package/dist/common/components/index.mjs +1 -2
  31. package/dist/common/config/bootstrap/index.d.mts +24 -0
  32. package/dist/common/config/bootstrap/index.d.ts +24 -0
  33. package/dist/common/config/bootstrap/index.js +15 -15
  34. package/dist/common/config/bootstrap/index.mjs +1 -1
  35. package/dist/common/config/server/index.js +14 -14
  36. package/dist/common/config/server/index.mjs +1 -1
  37. package/dist/common/index.js +2 -3
  38. package/dist/common/index.mjs +1 -2
  39. package/dist/index.d.mts +314 -154
  40. package/dist/index.d.ts +314 -154
  41. package/dist/index.js +1055 -369
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +1005 -360
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types-CiqMQ-uu.d.mts +166 -0
  46. package/dist/types-CiqMQ-uu.d.ts +166 -0
  47. package/package.json +15 -50
  48. package/dist/chunk-3R6JHA6D.js +0 -120
  49. package/dist/chunk-3R6JHA6D.js.map +0 -1
  50. package/dist/chunk-4PJM4752.js +0 -4
  51. package/dist/chunk-4PJM4752.js.map +0 -1
  52. package/dist/chunk-5H2FICSO.js.map +0 -1
  53. package/dist/chunk-7PMT4L4I.js +0 -324
  54. package/dist/chunk-7PMT4L4I.js.map +0 -1
  55. package/dist/chunk-FY2X3LYR.mjs +0 -3
  56. package/dist/chunk-FY2X3LYR.mjs.map +0 -1
  57. package/dist/chunk-GS4SAW25.mjs +0 -116
  58. package/dist/chunk-GS4SAW25.mjs.map +0 -1
  59. package/dist/chunk-HL4H2HF6.js +0 -279
  60. package/dist/chunk-HL4H2HF6.js.map +0 -1
  61. package/dist/chunk-IJIQUMAK.mjs +0 -272
  62. package/dist/chunk-IJIQUMAK.mjs.map +0 -1
  63. package/dist/chunk-KVYHCGRY.js.map +0 -1
  64. package/dist/chunk-LGVPFYPR.mjs.map +0 -1
  65. package/dist/chunk-MMDSZIXD.mjs +0 -286
  66. package/dist/chunk-MMDSZIXD.mjs.map +0 -1
  67. package/dist/chunk-N2O3OX5Y.mjs +0 -243
  68. package/dist/chunk-N2O3OX5Y.mjs.map +0 -1
  69. package/dist/chunk-RRQ2X26Z.js +0 -106
  70. package/dist/chunk-RRQ2X26Z.js.map +0 -1
  71. package/dist/chunk-RVNQI6BI.js +0 -249
  72. package/dist/chunk-RVNQI6BI.js.map +0 -1
  73. package/dist/chunk-UJUWDF7M.mjs +0 -336
  74. package/dist/chunk-UJUWDF7M.mjs.map +0 -1
  75. package/dist/chunk-VCKXK6V5.js +0 -345
  76. package/dist/chunk-VCKXK6V5.js.map +0 -1
  77. package/dist/chunk-VIEXDTNF.mjs +0 -100
  78. package/dist/chunk-VIEXDTNF.mjs.map +0 -1
  79. package/dist/chunk-YIRPPMCN.mjs.map +0 -1
  80. package/dist/common/ai/llm/core/index.d.mts +0 -70
  81. package/dist/common/ai/llm/core/index.d.ts +0 -70
  82. package/dist/common/ai/llm/core/index.js +0 -54
  83. package/dist/common/ai/llm/core/index.mjs +0 -5
  84. package/dist/common/ai/llm/electron/index.d.mts +0 -6
  85. package/dist/common/ai/llm/electron/index.d.ts +0 -6
  86. package/dist/common/ai/llm/electron/index.js +0 -67
  87. package/dist/common/ai/llm/electron/index.mjs +0 -10
  88. package/dist/common/ai/llm/index.d.mts +0 -3
  89. package/dist/common/ai/llm/index.d.ts +0 -3
  90. package/dist/common/ai/llm/index.js +0 -54
  91. package/dist/common/ai/llm/index.js.map +0 -1
  92. package/dist/common/ai/llm/index.mjs +0 -5
  93. package/dist/common/ai/llm/index.mjs.map +0 -1
  94. package/dist/common/ai/llm/miniapp/index.d.mts +0 -6
  95. package/dist/common/ai/llm/miniapp/index.d.ts +0 -6
  96. package/dist/common/ai/llm/miniapp/index.js +0 -59
  97. package/dist/common/ai/llm/miniapp/index.js.map +0 -1
  98. package/dist/common/ai/llm/miniapp/index.mjs +0 -6
  99. package/dist/common/ai/llm/miniapp/index.mjs.map +0 -1
  100. package/dist/common/ai/llm/rn/index.d.mts +0 -6
  101. package/dist/common/ai/llm/rn/index.d.ts +0 -6
  102. package/dist/common/ai/llm/rn/index.js +0 -59
  103. package/dist/common/ai/llm/rn/index.js.map +0 -1
  104. package/dist/common/ai/llm/rn/index.mjs +0 -6
  105. package/dist/common/ai/llm/rn/index.mjs.map +0 -1
  106. package/dist/common/ai/llm/ui/electron/index.d.mts +0 -5
  107. package/dist/common/ai/llm/ui/electron/index.d.ts +0 -5
  108. package/dist/common/ai/llm/ui/electron/index.js +0 -22
  109. package/dist/common/ai/llm/ui/electron/index.js.map +0 -1
  110. package/dist/common/ai/llm/ui/electron/index.mjs +0 -9
  111. package/dist/common/ai/llm/ui/electron/index.mjs.map +0 -1
  112. package/dist/common/ai/llm/ui/miniapp/index.d.mts +0 -9
  113. package/dist/common/ai/llm/ui/miniapp/index.d.ts +0 -9
  114. package/dist/common/ai/llm/ui/miniapp/index.js +0 -14
  115. package/dist/common/ai/llm/ui/miniapp/index.js.map +0 -1
  116. package/dist/common/ai/llm/ui/miniapp/index.mjs +0 -5
  117. package/dist/common/ai/llm/ui/miniapp/index.mjs.map +0 -1
  118. package/dist/common/ai/llm/ui/rn/index.d.mts +0 -9
  119. package/dist/common/ai/llm/ui/rn/index.d.ts +0 -9
  120. package/dist/common/ai/llm/ui/rn/index.js +0 -14
  121. package/dist/common/ai/llm/ui/rn/index.js.map +0 -1
  122. package/dist/common/ai/llm/ui/rn/index.mjs +0 -5
  123. package/dist/common/ai/llm/ui/rn/index.mjs.map +0 -1
  124. package/dist/common/ai/llm/ui/web/index.d.mts +0 -15
  125. package/dist/common/ai/llm/ui/web/index.d.ts +0 -15
  126. package/dist/common/ai/llm/ui/web/index.js +0 -21
  127. package/dist/common/ai/llm/ui/web/index.js.map +0 -1
  128. package/dist/common/ai/llm/ui/web/index.mjs +0 -8
  129. package/dist/common/ai/llm/ui/web/index.mjs.map +0 -1
  130. package/dist/common/ai/llm/web/index.d.mts +0 -6
  131. package/dist/common/ai/llm/web/index.d.ts +0 -6
  132. package/dist/common/ai/llm/web/index.js +0 -66
  133. package/dist/common/ai/llm/web/index.js.map +0 -1
  134. package/dist/common/ai/llm/web/index.mjs +0 -9
  135. package/dist/common/ai/llm/web/index.mjs.map +0 -1
  136. package/dist/types-B2rs_jq1.d.mts +0 -38
  137. package/dist/types-DgACCUpT.d.ts +0 -122
  138. package/dist/types-DwS2Eg0q.d.ts +0 -38
  139. package/dist/types-LU_BGSzk.d.mts +0 -122
  140. /package/dist/common/{ai/llm/core → aiApi}/index.js.map +0 -0
  141. /package/dist/common/{ai/llm/core → aiApi}/index.mjs.map +0 -0
  142. /package/dist/common/{ai/llm/electron → aiApi/server}/index.js.map +0 -0
  143. /package/dist/common/{ai/llm/electron → aiApi/server}/index.mjs.map +0 -0
package/dist/index.d.mts CHANGED
@@ -10495,188 +10495,348 @@ interface SmartAssistantProps {
10495
10495
  }
10496
10496
  declare const SmartAssistant: React__default.FC<SmartAssistantProps>;
10497
10497
 
10498
- type PromptVariableValue = string | number | boolean | null | undefined;
10499
- type PromptVariables = Record<string, PromptVariableValue>;
10500
- declare const normalizePromptVariables: (variables?: PromptVariables) => Record<string, string>;
10501
-
10502
- interface AiProvider {
10503
- id?: string;
10504
- sendChat(request: AiChatRequest, config: ResolvedAiClientConfig): Promise<AiChatResponse>;
10505
- streamChat?(request: AiChatRequest, config: ResolvedAiClientConfig): AsyncIterable<AiChatChunk>;
10506
- }
10507
-
10508
- type AiRole = 'system' | 'user' | 'assistant' | 'tool';
10509
- type AiToolChoice = {
10510
- type: 'function';
10511
- function: {
10512
- name: string;
10513
- };
10514
- };
10515
- type AiToolDefinition = {
10516
- type: 'function';
10517
- function: {
10518
- name: string;
10519
- description?: string;
10520
- parameters?: Record<string, any>;
10521
- };
10522
- };
10523
- type AiToolCall = {
10524
- id: string;
10525
- type: 'function';
10526
- function: {
10527
- name: string;
10528
- arguments: string;
10529
- };
10530
- };
10531
- interface AiMessage {
10532
- role: AiRole;
10533
- content: string;
10534
- name?: string;
10535
- toolCallId?: string;
10536
- toolCalls?: AiToolCall[];
10498
+ /** 音频处理策略:native=chat 内嵌音频,stt=先转写再 chat,auto=按模型能力自动选择(失败时 STT 回退) */
10499
+ type AudioStrategy = 'native' | 'stt' | 'auto';
10500
+ /** 连接配置(调用方可显式传入,或与 env 合并) */
10501
+ interface AiConnectionSettings {
10502
+ apiKey: string;
10503
+ baseUrl: string;
10504
+ model?: string;
10505
+ textModel?: string;
10506
+ visionModel?: string;
10507
+ audioModel?: string;
10508
+ audioStrategy?: AudioStrategy;
10509
+ timeoutMs?: number;
10510
+ maxImageBytes?: number;
10511
+ maxAudioBytes?: number;
10512
+ }
10513
+ /** 客户端/请求可携带的 AI 连接配置(字段均可选,用于覆盖环境变量) */
10514
+ type AiClientSettings = Partial<AiConnectionSettings>;
10515
+ /** 解析后的完整连接配置 */
10516
+ interface AiConnectionConfig extends AiConnectionSettings {
10517
+ textModel: string;
10518
+ visionModel: string;
10519
+ audioModel: string;
10520
+ audioStrategy: AudioStrategy;
10521
+ timeoutMs: number;
10522
+ maxImageBytes: number;
10523
+ maxAudioBytes: number;
10537
10524
  }
10538
- interface AiUsage {
10539
- promptTokens?: number;
10540
- completionTokens?: number;
10541
- totalTokens?: number;
10525
+ /** 统一 AI 任务请求 */
10526
+ interface AiApiRunRequest<TInput = unknown> {
10527
+ taskId: string;
10528
+ input: TInput;
10529
+ options?: AiTaskRunOptions;
10530
+ clientSettings?: AiClientSettings;
10542
10531
  }
10543
- interface AiChatRequestOptions {
10532
+ interface AiTaskRunOptions {
10544
10533
  model?: string;
10545
10534
  temperature?: number;
10546
10535
  maxTokens?: number;
10547
- topP?: number;
10548
- stop?: string | string[];
10549
- stream?: boolean;
10550
- tools?: AiToolDefinition[];
10551
- toolChoice?: 'auto' | 'none' | AiToolChoice;
10552
10536
  }
10553
- interface AiChatRequest extends AiChatRequestOptions {
10554
- messages: AiMessage[];
10537
+ /** 统一 AI 任务响应 */
10538
+ interface AiApiResponse<TData = unknown> {
10539
+ success: boolean;
10540
+ taskId: string;
10541
+ data?: TData;
10542
+ error?: AiApiErrorBody;
10543
+ meta?: AiApiResponseMeta;
10544
+ }
10545
+ interface AiApiErrorBody {
10546
+ code: AiApiErrorCode;
10547
+ message: string;
10548
+ details?: unknown;
10549
+ }
10550
+ type AiApiErrorCode = 'UNAUTHORIZED' | 'INVALID_INPUT' | 'TASK_NOT_FOUND' | 'AI_CONFIG_MISSING' | 'AI_REQUEST_FAILED' | 'AI_PARSE_FAILED' | 'PAYLOAD_TOO_LARGE' | 'UNSUPPORTED_MEDIA';
10551
+ interface AiApiResponseMeta {
10552
+ model: string;
10553
+ latencyMs: number;
10554
+ provider?: string;
10555
+ confidence?: number;
10556
+ rawSummary?: string;
10557
+ }
10558
+ /** 多模态图片输入(base64) */
10559
+ interface AiImageInput {
10560
+ base64: string;
10561
+ mimeType: string;
10562
+ }
10563
+ /** 多模态音频输入(base64) */
10564
+ interface AiAudioInput {
10565
+ base64: string;
10566
+ mimeType: string;
10567
+ }
10568
+ type AiMediaKind = 'image' | 'audio';
10569
+ interface AiImageMediaInput extends AiImageInput {
10570
+ kind: 'image';
10571
+ }
10572
+ interface AiAudioMediaInput extends AiAudioInput {
10573
+ kind: 'audio';
10574
+ }
10575
+ type AiMediaInput = AiImageMediaInput | AiAudioMediaInput;
10576
+ /** 通用文本补全任务输入 */
10577
+ interface TextCompletionInput {
10578
+ systemPrompt?: string;
10579
+ userPrompt: string;
10580
+ model?: string;
10581
+ temperature?: number;
10582
+ maxTokens?: number;
10583
+ /** 显式连接配置,优先级高于 clientSettings / 环境变量 */
10584
+ connection?: AiClientSettings;
10555
10585
  }
10556
- interface AiChatResponse {
10557
- id: string;
10586
+ /** 通用文本补全任务输出 */
10587
+ interface TextCompletionOutput {
10558
10588
  content: string;
10559
- message?: AiMessage;
10560
- usage?: AiUsage;
10561
- raw?: unknown;
10562
- toolCalls?: AiToolCall[];
10589
+ rawText: string;
10590
+ }
10591
+ /** 通用结构化多模态任务输入 */
10592
+ interface StructuredMultimodalInput {
10593
+ systemPrompt: string;
10594
+ userPrompt: string;
10595
+ media?: AiMediaInput[];
10596
+ jsonSchemaHint?: string;
10597
+ model?: string;
10598
+ temperature?: number;
10599
+ maxTokens?: number;
10600
+ audioStrategy?: AudioStrategy;
10601
+ connection?: AiClientSettings;
10563
10602
  }
10564
- interface AiChatChunk {
10565
- id: string;
10566
- content?: string;
10567
- delta?: string;
10568
- toolCalls?: AiToolCall[];
10569
- raw?: unknown;
10603
+ /** 通用结构化多模态任务输出 */
10604
+ interface StructuredMultimodalOutput {
10605
+ json: Record<string, unknown>;
10606
+ rawText: string;
10570
10607
  }
10571
- interface AiLogger {
10572
- debug?: (message: string, data?: any) => void;
10573
- info?: (message: string, data?: any) => void;
10574
- warn?: (message: string, data?: any) => void;
10575
- error?: (message: string, error?: any) => void;
10608
+ declare const CORE_LLM_COMPLETION_TASK_ID = "core.llmCompletion";
10609
+ declare const CORE_STRUCTURED_MULTIMODAL_TASK_ID = "core.structuredMultimodal";
10610
+ declare const CORE_CONNECTIVITY_TEST_TASK_ID = "core.connectivityTest";
10611
+ interface ConnectivityTestOutput {
10612
+ ok: boolean;
10613
+ reply: string;
10576
10614
  }
10577
- interface AiClientConfig {
10578
- apiKey?: string;
10579
- getApiKey?: () => Promise<string> | string;
10580
- baseUrl?: string;
10615
+ interface AiModelsListRequest {
10616
+ clientSettings?: AiClientSettings;
10617
+ }
10618
+ interface AiModelsListResponse {
10619
+ success: boolean;
10620
+ models: string[];
10621
+ visionModels: string[];
10622
+ suggestedVisionModel?: string;
10623
+ error?: {
10624
+ code: string;
10625
+ message: string;
10626
+ };
10627
+ }
10628
+ interface AiTaskContext {
10629
+ requestId?: string;
10630
+ userId?: string | number;
10631
+ clientSettings?: AiClientSettings;
10632
+ }
10633
+ interface AiTaskDefinition<TInput = unknown, TOutput = unknown> {
10634
+ id: string;
10635
+ description?: string;
10636
+ validateInput: (input: unknown) => TInput;
10637
+ execute: (input: TInput, ctx: AiTaskContext) => Promise<{
10638
+ data: TOutput;
10639
+ meta?: Partial<AiApiResponseMeta>;
10640
+ }>;
10641
+ }
10642
+ interface MultimodalChatParams {
10643
+ systemPrompt: string;
10644
+ userPrompt: string;
10645
+ media?: AiMediaInput[];
10581
10646
  model?: string;
10647
+ temperature?: number;
10648
+ maxTokens?: number;
10649
+ jsonMode?: boolean;
10650
+ audioStrategy?: AudioStrategy;
10651
+ connection?: AiClientSettings;
10652
+ }
10653
+ interface MultimodalChatResult {
10654
+ content: string;
10655
+ model: string;
10656
+ raw: unknown;
10657
+ /** auto/native/stt 实际采用的音频处理方式 */
10658
+ audioHandling?: 'none' | 'native' | 'stt';
10659
+ /** STT 或 native 失败回退时的转写文本 */
10660
+ transcriptions?: string[];
10661
+ }
10662
+
10663
+ /**
10664
+ * 合并连接配置:显式 connection > clientSettings > 环境变量。
10665
+ * 缺少 apiKey 时返回 null。
10666
+ */
10667
+ declare function resolveAiConnectionConfig(...sources: Array<AiClientSettings | undefined>): AiConnectionConfig | null;
10668
+ declare function requireAiConnectionConfig(...sources: Array<AiClientSettings | undefined>): AiConnectionConfig;
10669
+
10670
+ type JsonRequestOptions = {
10671
+ url: string;
10672
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
10582
10673
  headers?: Record<string, string>;
10674
+ body?: unknown;
10583
10675
  timeoutMs?: number;
10584
10676
  requestAdapter?: RequestAdapter;
10585
- logger?: AiLogger;
10586
- provider?: AiProvider;
10677
+ };
10678
+ declare function requestJson<T>(options: JsonRequestOptions): Promise<T>;
10679
+
10680
+ declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
10681
+ declare const DEFAULT_TEXT_MODEL = "gpt-4o-mini";
10682
+ type ChatRole = 'system' | 'user' | 'assistant';
10683
+ interface ChatMessage {
10684
+ role: ChatRole;
10685
+ content: string;
10587
10686
  }
10588
- interface ResolvedAiClientConfig extends AiClientConfig {
10687
+ interface CallChatOptions {
10688
+ /** OpenAI 兼容 API Base URL */
10589
10689
  baseUrl: string;
10590
- headers: Record<string, string>;
10591
- timeoutMs: number;
10690
+ /** API Key */
10691
+ apiKey: string;
10692
+ model?: string;
10693
+ systemPrompt?: string;
10694
+ userPrompt?: string;
10695
+ messages?: ChatMessage[];
10696
+ temperature?: number;
10697
+ maxTokens?: number;
10698
+ topP?: number;
10699
+ stop?: string | string[];
10700
+ timeoutMs?: number;
10701
+ requestAdapter?: RequestAdapter;
10592
10702
  }
10593
- interface AiClient {
10594
- sendChat(request: AiChatRequest): Promise<AiChatResponse>;
10595
- sendMessage(content: string, options?: AiChatRequestOptions & {
10596
- systemPrompt?: string;
10597
- }): Promise<AiChatResponse>;
10703
+ interface ChatUsage {
10704
+ promptTokens?: number;
10705
+ completionTokens?: number;
10706
+ totalTokens?: number;
10598
10707
  }
10599
- type AiChatStatus = 'idle' | 'loading' | 'success' | 'error';
10600
- interface AiChatInputOptions extends AiChatRequestOptions {
10601
- template?: string;
10602
- variables?: PromptVariables;
10708
+ interface CallChatResult {
10709
+ content: string;
10710
+ model: string;
10711
+ usage?: ChatUsage;
10712
+ raw?: unknown;
10603
10713
  }
10604
- interface AiChatSessionOptions {
10605
- client: AiClient;
10714
+ /**
10715
+ * OpenAI 兼容文本对话:外部传入 URL、Key、提示词,返回模型生成内容。
10716
+ */
10717
+ declare function callChat(options: CallChatOptions): Promise<CallChatResult>;
10718
+
10719
+ interface CallCompletionParams {
10606
10720
  systemPrompt?: string;
10607
- template?: string;
10608
- initialMessages?: AiMessage[];
10721
+ userPrompt: string;
10722
+ model?: string;
10723
+ temperature?: number;
10724
+ maxTokens?: number;
10725
+ connection?: AiClientSettings;
10609
10726
  }
10610
- interface AiChatSession {
10611
- getMessages(): AiMessage[];
10612
- setSystemPrompt(prompt?: string): void;
10613
- reset(): void;
10614
- sendMessage(input: string, options?: AiChatInputOptions): Promise<AiChatResponse>;
10727
+ interface CallCompletionResult {
10728
+ content: string;
10729
+ model: string;
10730
+ raw?: unknown;
10615
10731
  }
10732
+ /**
10733
+ * 文本补全:连接信息与提示词均由调用方传入(或通过 connection 合并 env)。
10734
+ */
10735
+ declare function callCompletion(params: CallCompletionParams, clientSettings?: AiClientSettings): Promise<CallCompletionResult>;
10616
10736
 
10617
- declare const createAiClient: (config: AiClientConfig) => AiClient;
10737
+ /**
10738
+ * OpenAI 兼容多模态对话:文本 + 可选图片/语音。
10739
+ * audioStrategy=auto 时:优先 chat 内嵌音频(native),失败或未支持则 STT 转写后走文本 chat。
10740
+ */
10741
+ declare function callMultimodalChat(params: MultimodalChatParams, clientSettings?: AiClientSettings): Promise<MultimodalChatResult>;
10618
10742
 
10619
- declare const createChatSession: (options: AiChatSessionOptions) => AiChatSession;
10743
+ declare function extractJsonObject(text: string): Record<string, unknown>;
10620
10744
 
10621
- interface PromptTemplateOptions {
10622
- missingValue?: string;
10623
- preserveUnknown?: boolean;
10624
- }
10625
- declare const applyPromptTemplate: (template: string, variables?: PromptVariables, options?: PromptTemplateOptions) => string;
10745
+ declare function assertValidImageInput(image: AiImageInput, maxImageBytes?: number): void;
10746
+ declare function fileToAiImageInput(file: File): Promise<AiImageInput>;
10626
10747
 
10627
- declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
10628
- declare const DEFAULT_OPENAI_MODEL = "gpt-3.5-turbo";
10629
- declare const createOpenAICompatibleProvider: () => AiProvider;
10748
+ declare function mimeToAudioFormat(mimeType: string): string;
10749
+ declare function assertValidAudioInput(audio: AiAudioInput, maxAudioBytes?: number): void;
10750
+ declare function fileToAiAudioInput(file: File): Promise<AiAudioInput>;
10751
+ declare function base64ToBlob(base64: string, mimeType: string): Blob;
10630
10752
 
10631
- interface UseAiChatOptions {
10632
- client: AiClient;
10633
- systemPrompt?: string;
10634
- template?: string;
10635
- initialMessages?: AiMessage[];
10636
- }
10637
- declare const useAiChat: (options: UseAiChatOptions) => {
10638
- status: AiChatStatus;
10639
- isLoading: boolean;
10640
- error: Error | null;
10641
- messages: AiMessage[];
10642
- lastResponse: AiChatResponse | null;
10643
- sendMessage: (input: string, requestOptions?: AiChatInputOptions) => Promise<AiChatResponse>;
10644
- reset: () => void;
10645
- setSystemPrompt: (prompt?: string) => void;
10753
+ declare function splitMediaByKind(media: AiMediaInput[]): {
10754
+ images: AiMediaInput[];
10755
+ audios: AiMediaInput[];
10646
10756
  };
10757
+ declare function assertValidMultimodalMedia(media: AiMediaInput[] | undefined, limits: {
10758
+ maxImageBytes: number;
10759
+ maxAudioBytes: number;
10760
+ maxImages?: number;
10761
+ maxAudios?: number;
10762
+ }): AiMediaInput[];
10763
+
10764
+ type ResolvedAudioHandling = 'none' | 'native' | 'stt';
10765
+ declare function resolveAudioHandling(options: {
10766
+ hasAudio: boolean;
10767
+ strategy: AudioStrategy;
10768
+ model: string;
10769
+ baseUrl: string;
10770
+ }): ResolvedAudioHandling;
10771
+ declare function isAudioInputError(message: string): boolean;
10772
+ declare function appendTranscriptionsToPrompt(userPrompt: string, transcriptions: string[]): string;
10647
10773
 
10648
- type SkillInputSchema = Record<string, any>;
10649
- interface SkillExecutionContext {
10650
- messages?: AiMessage[];
10651
- logger?: AiLogger;
10652
- metadata?: Record<string, any>;
10774
+ interface TranscribeAudioOptions {
10775
+ audio: AiAudioInput;
10776
+ config: AiConnectionConfig;
10777
+ model?: string;
10778
+ language?: string;
10653
10779
  }
10654
- interface SkillDefinition<Input = any, Output = any> {
10655
- name: string;
10656
- description?: string;
10657
- inputSchema?: SkillInputSchema;
10658
- execute: (input: Input, context?: SkillExecutionContext) => Promise<Output> | Output;
10659
- }
10660
- interface SkillRegistry {
10661
- registerSkill(skill: SkillDefinition): void;
10662
- unregisterSkill(name: string): boolean;
10663
- getSkill(name: string): SkillDefinition | undefined;
10664
- listSkills(): SkillDefinition[];
10665
- executeSkill(name: string, input: any, context?: SkillExecutionContext): Promise<any>;
10666
- toToolDefinitions?(): AiToolDefinition[];
10667
- }
10668
-
10669
- declare const skillToToolDefinition: (skill: SkillDefinition) => AiToolDefinition;
10670
- declare class InMemorySkillRegistry implements SkillRegistry {
10671
- private skills;
10672
- constructor(initialSkills?: SkillDefinition[]);
10673
- registerSkill(skill: SkillDefinition): void;
10674
- unregisterSkill(name: string): boolean;
10675
- getSkill(name: string): SkillDefinition | undefined;
10676
- listSkills(): SkillDefinition[];
10677
- executeSkill(name: string, input: any, context?: SkillExecutionContext): Promise<any>;
10678
- toToolDefinitions(): AiToolDefinition[];
10679
- }
10680
- declare const createSkillRegistry: (initialSkills?: SkillDefinition[]) => InMemorySkillRegistry;
10681
-
10682
- export { type AiChatChunk, type AiChatInputOptions, type AiChatRequest, type AiChatRequestOptions, type AiChatResponse, type AiChatSession, type AiChatSessionOptions, type AiChatStatus, type AiClient, type AiClientConfig, type AiLogger, type AiMessage, type AiProvider, type AiRole, type AiToolCall, type AiToolChoice, type AiToolDefinition, type AiUsage, Dialog as AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, DialogDescription as AlertDialogDescription, DialogFooter as AlertDialogFooter, DialogHeader as AlertDialogHeader, DialogOverlay as AlertDialogOverlay, DialogPortal as AlertDialogPortal, DialogTitle as AlertDialogTitle, DialogTrigger as AlertDialogTrigger, Avatar, AvatarFallback, AvatarImage, BackButton, BackButtonProps, type BackgroundRemovalOptions, type BackgroundRemovalState, BackgroundRemover, Badge, BadgeProps, Ball, Button, ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CollisionBalls, CollisionBallsConfig, ConfirmModal, ConfirmModalProps, ConsoleLoggerAdapter, DEFAULT_OPENAI_BASE_URL, DEFAULT_OPENAI_MODEL, Dialog, DialogClose, DialogContent, DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FilterButtonGroup, FilterButtonGroupProps, FilterOption, GenericOrderManager, GenericOrderManagerProps, Grid, GridColumns, GridGap, GridItem, GridProps, ImageMappingItem, ImageMappingPanel, ImageMappingPanelProps, ImageMappingValue, InMemorySkillRegistry, Input, Label, LocalImageMappingPanel, LocalImageMappingPanelProps, type LogEntry, LogLevel, Logger, type LoggerAdapter, type LoggerConfig, Modal, ModalProps, type OCROptions, type OCRResult, OCRScanner, type OCRState, OrderManagerOperations, OrderableItem, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, ProgressProps, type PromptTemplateOptions, type PromptVariableValue, type PromptVariables, type ResolvedAiClientConfig, ScrollArea, ScrollBar, SearchBox, SearchResultHint, SearchResultHintProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SentimentAnalyzer, type SentimentOptions, type SentimentResult, type SentimentState, Separator, SeparatorProps, Dialog as Sheet, DialogClose as SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, DialogOverlay as SheetOverlay, DialogPortal as SheetPortal, SheetTitle, DialogTrigger as SheetTrigger, type SkillDefinition, type SkillExecutionContext, type SkillInputSchema, type SkillRegistry, SmartAssistant, type StorageAdapter, type StorageChangeEvent, Tabs, TabsContent, TabsList, TabsTrigger, type TextGenerationOptions, type TextGenerationState, Textarea, Timeline, TimelineConfig, TimelineItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseAiChatOptions, applyPromptTemplate, arrayUtils, badgeVariants, buttonVariants, cn, index as common, createAiClient, createChatSession, createLogger, createOpenAICompatibleProvider, createSkillRegistry, debugUtils, errorUtils, fileUtils, formatTime, japaneseUtils, logger, normalizePromptVariables, skillToToolDefinition, stringUtils, useAiChat, useAsyncStorage, useBackgroundRemoval, useElectronStorage, useLocalStorage, useOCR, useSentimentAnalysis, useStorage, useTaroStorage, useTextGeneration, validators };
10780
+ declare function transcribeAudio(options: TranscribeAudioOptions): Promise<string>;
10781
+ declare function transcribeAudios(audios: AiAudioInput[], config: AiConnectionConfig, model?: string): Promise<string[]>;
10782
+
10783
+ declare function isLikelyNativeAudioChatModel(id: string): boolean;
10784
+ declare function isLikelySttModel(id: string): boolean;
10785
+ declare function filterSttModels(modelIds: string[]): string[];
10786
+ declare function pickDefaultSttModel(modelIds: string[], current?: string): string | undefined;
10787
+ declare function isLikelyVisionModel(id: string): boolean;
10788
+ declare function isKnownTextOnlyModel(id: string): boolean;
10789
+ declare function filterChatModels(modelIds: string[]): string[];
10790
+ declare function filterVisionModels(modelIds: string[]): string[];
10791
+ /** 从可用模型中挑选默认视觉模型 */
10792
+ declare function pickDefaultVisionModel(modelIds: string[], current?: string): string | undefined;
10793
+
10794
+ type VisionMessageFormat = 'openai' | 'ollama';
10795
+ declare function detectVisionMessageFormat(baseUrl: string): VisionMessageFormat;
10796
+ declare function assertVisionCapableModel(modelId: string, options?: {
10797
+ baseUrl?: string;
10798
+ hasImages?: boolean;
10799
+ }): void;
10800
+ declare function isImageUrlVariantError(message: string): boolean;
10801
+ declare function toVisionApiErrorMessage(rawMessage: string, modelId: string): string;
10802
+
10803
+ declare function buildMultimodalMessages(options: {
10804
+ systemPrompt: string;
10805
+ userPrompt: string;
10806
+ images: AiMediaInput[];
10807
+ nativeAudios: AiMediaInput[];
10808
+ format: VisionMessageFormat;
10809
+ }): Array<Record<string, unknown>>;
10810
+ declare function assertMultimodalCapableModel(modelId: string, options: {
10811
+ baseUrl?: string;
10812
+ hasImages?: boolean;
10813
+ hasNativeAudio?: boolean;
10814
+ }): void;
10815
+
10816
+ interface ListModelsResult {
10817
+ models: string[];
10818
+ visionModels: string[];
10819
+ suggestedVisionModel?: string;
10820
+ }
10821
+ declare function listOpenAiCompatibleModels(clientSettings?: AiClientSettings, currentVisionModel?: string): Promise<ListModelsResult>;
10822
+
10823
+ declare function registerAiTask<TInput, TOutput>(task: AiTaskDefinition<TInput, TOutput>): void;
10824
+ declare function getAiTask(taskId: string): AiTaskDefinition | undefined;
10825
+ declare function listAiTasks(): string[];
10826
+ declare function clearAiTasksForTest(): void;
10827
+
10828
+ declare function runAiTask<TData = unknown>(taskId: string, input: unknown, ctx?: AiTaskContext): Promise<AiApiResponse<TData>>;
10829
+
10830
+ /** 注册内置通用 AI 任务(幂等) */
10831
+ declare function registerCoreAiTasks(): void;
10832
+ /** 别名:确保 core 任务已注册 */
10833
+ declare const ensureCoreAiTasksRegistered: typeof registerCoreAiTasks;
10834
+ declare function resetCoreAiTasksForTest(): void;
10835
+
10836
+ declare const coreLlmCompletionTask: AiTaskDefinition<TextCompletionInput, TextCompletionOutput>;
10837
+
10838
+ declare const coreStructuredMultimodalTask: AiTaskDefinition<StructuredMultimodalInput, StructuredMultimodalOutput>;
10839
+
10840
+ declare const coreConnectivityTestTask: AiTaskDefinition<Record<string, never>, ConnectivityTestOutput>;
10841
+
10842
+ export { type AiApiErrorBody, type AiApiErrorCode, type AiApiResponse, type AiApiResponseMeta, type AiApiRunRequest, type AiAudioInput, type AiAudioMediaInput, type AiClientSettings, type AiConnectionConfig, type AiConnectionSettings, type AiImageInput, type AiImageMediaInput, type AiMediaInput, type AiMediaKind, type AiModelsListRequest, type AiModelsListResponse, type AiTaskContext, type AiTaskDefinition, type AiTaskRunOptions, Dialog as AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, DialogDescription as AlertDialogDescription, DialogFooter as AlertDialogFooter, DialogHeader as AlertDialogHeader, DialogOverlay as AlertDialogOverlay, DialogPortal as AlertDialogPortal, DialogTitle as AlertDialogTitle, DialogTrigger as AlertDialogTrigger, type AudioStrategy, Avatar, AvatarFallback, AvatarImage, BackButton, BackButtonProps, type BackgroundRemovalOptions, type BackgroundRemovalState, BackgroundRemover, Badge, BadgeProps, Ball, Button, ButtonProps, CORE_CONNECTIVITY_TEST_TASK_ID, CORE_LLM_COMPLETION_TASK_ID, CORE_STRUCTURED_MULTIMODAL_TASK_ID, type CallChatOptions, type CallChatResult, type CallCompletionParams, type CallCompletionResult, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, type ChatRole, type ChatUsage, CollisionBalls, CollisionBallsConfig, ConfirmModal, ConfirmModalProps, type ConnectivityTestOutput, ConsoleLoggerAdapter, DEFAULT_OPENAI_BASE_URL, DEFAULT_TEXT_MODEL, Dialog, DialogClose, DialogContent, DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FilterButtonGroup, FilterButtonGroupProps, FilterOption, GenericOrderManager, GenericOrderManagerProps, Grid, GridColumns, GridGap, GridItem, GridProps, ImageMappingItem, ImageMappingPanel, ImageMappingPanelProps, ImageMappingValue, Input, type JsonRequestOptions, Label, type ListModelsResult, LocalImageMappingPanel, LocalImageMappingPanelProps, type LogEntry, LogLevel, Logger, type LoggerAdapter, type LoggerConfig, Modal, ModalProps, type MultimodalChatParams, type MultimodalChatResult, type OCROptions, type OCRResult, OCRScanner, type OCRState, OrderManagerOperations, OrderableItem, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, ProgressProps, type ResolvedAudioHandling, ScrollArea, ScrollBar, SearchBox, SearchResultHint, SearchResultHintProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SentimentAnalyzer, type SentimentOptions, type SentimentResult, type SentimentState, Separator, SeparatorProps, Dialog as Sheet, DialogClose as SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, DialogOverlay as SheetOverlay, DialogPortal as SheetPortal, SheetTitle, DialogTrigger as SheetTrigger, SmartAssistant, type StorageAdapter, type StorageChangeEvent, type StructuredMultimodalInput, type StructuredMultimodalOutput, Tabs, TabsContent, TabsList, TabsTrigger, type TextCompletionInput, type TextCompletionOutput, type TextGenerationOptions, type TextGenerationState, Textarea, Timeline, TimelineConfig, TimelineItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TranscribeAudioOptions, type VisionMessageFormat, appendTranscriptionsToPrompt, arrayUtils, assertMultimodalCapableModel, assertValidAudioInput, assertValidImageInput, assertValidMultimodalMedia, assertVisionCapableModel, badgeVariants, base64ToBlob, buildMultimodalMessages, buttonVariants, callChat, callCompletion, callMultimodalChat, clearAiTasksForTest, cn, index as common, coreConnectivityTestTask, coreLlmCompletionTask, coreStructuredMultimodalTask, createLogger, debugUtils, detectVisionMessageFormat, ensureCoreAiTasksRegistered, errorUtils, extractJsonObject, fileToAiAudioInput, fileToAiImageInput, fileUtils, filterChatModels, filterSttModels, filterVisionModels, formatTime, getAiTask, isAudioInputError, isImageUrlVariantError, isKnownTextOnlyModel, isLikelyNativeAudioChatModel, isLikelySttModel, isLikelyVisionModel, japaneseUtils, listAiTasks, listOpenAiCompatibleModels, logger, mimeToAudioFormat, pickDefaultSttModel, pickDefaultVisionModel, registerAiTask, registerCoreAiTasks, requestJson, requireAiConnectionConfig, resetCoreAiTasksForTest, resolveAiConnectionConfig, resolveAudioHandling, runAiTask, splitMediaByKind, stringUtils, toVisionApiErrorMessage, transcribeAudio, transcribeAudios, useAsyncStorage, useBackgroundRemoval, useElectronStorage, useLocalStorage, useOCR, useSentimentAnalysis, useStorage, useTaroStorage, useTextGeneration, validators };