@aituber-onair/chat 0.42.0 → 0.43.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 (31) hide show
  1. package/README.ja.md +2 -0
  2. package/README.md +2 -0
  3. package/dist/cjs/constants/xai.d.ts +9 -0
  4. package/dist/cjs/constants/xai.d.ts.map +1 -1
  5. package/dist/cjs/constants/xai.js +14 -0
  6. package/dist/cjs/constants/xai.js.map +1 -1
  7. package/dist/cjs/services/providers/ChatServiceProvider.d.ts +6 -2
  8. package/dist/cjs/services/providers/ChatServiceProvider.d.ts.map +1 -1
  9. package/dist/cjs/services/providers/xai/XAIChatService.d.ts +3 -1
  10. package/dist/cjs/services/providers/xai/XAIChatService.d.ts.map +1 -1
  11. package/dist/cjs/services/providers/xai/XAIChatService.js +5 -1
  12. package/dist/cjs/services/providers/xai/XAIChatService.js.map +1 -1
  13. package/dist/cjs/services/providers/xai/XAIChatServiceProvider.d.ts.map +1 -1
  14. package/dist/cjs/services/providers/xai/XAIChatServiceProvider.js +1 -1
  15. package/dist/cjs/services/providers/xai/XAIChatServiceProvider.js.map +1 -1
  16. package/dist/esm/constants/xai.d.ts +9 -0
  17. package/dist/esm/constants/xai.d.ts.map +1 -1
  18. package/dist/esm/constants/xai.js +12 -0
  19. package/dist/esm/constants/xai.js.map +1 -1
  20. package/dist/esm/services/providers/ChatServiceProvider.d.ts +6 -2
  21. package/dist/esm/services/providers/ChatServiceProvider.d.ts.map +1 -1
  22. package/dist/esm/services/providers/xai/XAIChatService.d.ts +3 -1
  23. package/dist/esm/services/providers/xai/XAIChatService.d.ts.map +1 -1
  24. package/dist/esm/services/providers/xai/XAIChatService.js +6 -2
  25. package/dist/esm/services/providers/xai/XAIChatService.js.map +1 -1
  26. package/dist/esm/services/providers/xai/XAIChatServiceProvider.d.ts.map +1 -1
  27. package/dist/esm/services/providers/xai/XAIChatServiceProvider.js +2 -2
  28. package/dist/esm/services/providers/xai/XAIChatServiceProvider.js.map +1 -1
  29. package/dist/umd/aituber-onair-chat.js +15 -2
  30. package/dist/umd/aituber-onair-chat.min.js +7 -7
  31. package/package.json +1 -1
package/README.ja.md CHANGED
@@ -676,6 +676,7 @@ const zaiService = ChatServiceFactory.createChatService('zai', {
676
676
  const xaiService = ChatServiceFactory.createChatService('xai', {
677
677
  apiKey: process.env.XAI_API_KEY,
678
678
  model: 'grok-4.3',
679
+ reasoning_effort: 'none', // 任意(Grok 4.3): none, low, medium, high
679
680
  visionModel: 'grok-4.3', // 任意: xAI の全モデルがビジョン対応
680
681
  });
681
682
  ```
@@ -683,6 +684,7 @@ const xaiService = ChatServiceFactory.createChatService('xai', {
683
684
  注意:
684
685
  - xAIはOpenAI互換のChat Completionsを利用します。
685
686
  - 対応モデル: `grok-4.3`, `grok-4.20-0309-reasoning`, `grok-4.20-0309-non-reasoning`, `grok-4-1-fast-reasoning`, `grok-4-1-fast-non-reasoning`
687
+ - `reasoning_effort` は xAI が `none`, `low`, `medium`, `high` に対応している `grok-4.3` の場合のみ送信されます。高速なチャット応答向けにデフォルトは `none` です。
686
688
  - すべての対応 xAI モデルでビジョンとツール・関数呼び出しを利用できます。
687
689
 
688
690
  #### Kimi(Moonshot)
package/README.md CHANGED
@@ -688,6 +688,7 @@ Notes:
688
688
  const xaiService = ChatServiceFactory.createChatService('xai', {
689
689
  apiKey: process.env.XAI_API_KEY,
690
690
  model: 'grok-4.3',
691
+ reasoning_effort: 'none', // Optional for Grok 4.3: none, low, medium, high
691
692
  visionModel: 'grok-4.3', // Optional: all xAI models support vision
692
693
  });
693
694
  ```
@@ -695,6 +696,7 @@ const xaiService = ChatServiceFactory.createChatService('xai', {
695
696
  Notes:
696
697
  - xAI uses OpenAI-compatible Chat Completions.
697
698
  - Supported models: `grok-4.3`, `grok-4.20-0309-reasoning`, `grok-4.20-0309-non-reasoning`, `grok-4-1-fast-reasoning`, `grok-4-1-fast-non-reasoning`
699
+ - `reasoning_effort` is sent only for `grok-4.3`, where xAI supports `none`, `low`, `medium`, and `high`. The default is `none` for fast chat responses.
698
700
  - All supported xAI models support vision and tool/function calling.
699
701
 
700
702
  #### Kimi (Moonshot)
@@ -4,9 +4,18 @@ export declare const MODEL_GROK_4_20_REASONING = "grok-4.20-0309-reasoning";
4
4
  export declare const MODEL_GROK_4_20_NON_REASONING = "grok-4.20-0309-non-reasoning";
5
5
  export declare const MODEL_GROK_4_1_FAST_REASONING = "grok-4-1-fast-reasoning";
6
6
  export declare const MODEL_GROK_4_1_FAST_NON_REASONING = "grok-4-1-fast-non-reasoning";
7
+ export type XaiReasoningEffort = 'none' | 'low' | 'medium' | 'high';
7
8
  export declare const XAI_VISION_SUPPORTED_MODELS: string[];
8
9
  /**
9
10
  * Check if a model supports vision capabilities
10
11
  */
11
12
  export declare function isXaiVisionModel(model: string): boolean;
13
+ /**
14
+ * Check if a model supports the xAI reasoning_effort parameter
15
+ */
16
+ export declare function isXaiReasoningEffortModel(model: string): boolean;
17
+ /**
18
+ * Get default reasoning effort for xAI models
19
+ */
20
+ export declare function getDefaultXaiReasoningEffort(model: string): XaiReasoningEffort | undefined;
12
21
  //# sourceMappingURL=xai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xai.d.ts","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,yCACN,CAAC;AAGzC,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AACpE,eAAO,MAAM,6BAA6B,iCAAiC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAG/E,eAAO,MAAM,2BAA2B,UAMvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD"}
1
+ {"version":3,"file":"xai.d.ts","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,yCACN,CAAC;AAGzC,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AACpE,eAAO,MAAM,6BAA6B,iCAAiC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAE/E,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGpE,eAAO,MAAM,2BAA2B,UAMvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GACZ,kBAAkB,GAAG,SAAS,CAEhC"}
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.XAI_VISION_SUPPORTED_MODELS = exports.MODEL_GROK_4_1_FAST_NON_REASONING = exports.MODEL_GROK_4_1_FAST_REASONING = exports.MODEL_GROK_4_20_NON_REASONING = exports.MODEL_GROK_4_20_REASONING = exports.MODEL_GROK_4_3 = exports.ENDPOINT_XAI_CHAT_COMPLETIONS_API = void 0;
4
4
  exports.isXaiVisionModel = isXaiVisionModel;
5
+ exports.isXaiReasoningEffortModel = isXaiReasoningEffortModel;
6
+ exports.getDefaultXaiReasoningEffort = getDefaultXaiReasoningEffort;
5
7
  exports.ENDPOINT_XAI_CHAT_COMPLETIONS_API = 'https://api.x.ai/v1/chat/completions';
6
8
  // xAI Grok models
7
9
  exports.MODEL_GROK_4_3 = 'grok-4.3';
@@ -23,4 +25,16 @@ exports.XAI_VISION_SUPPORTED_MODELS = [
23
25
  function isXaiVisionModel(model) {
24
26
  return exports.XAI_VISION_SUPPORTED_MODELS.includes(model);
25
27
  }
28
+ /**
29
+ * Check if a model supports the xAI reasoning_effort parameter
30
+ */
31
+ function isXaiReasoningEffortModel(model) {
32
+ return model === exports.MODEL_GROK_4_3;
33
+ }
34
+ /**
35
+ * Get default reasoning effort for xAI models
36
+ */
37
+ function getDefaultXaiReasoningEffort(model) {
38
+ return isXaiReasoningEffortModel(model) ? 'none' : undefined;
39
+ }
26
40
  //# sourceMappingURL=xai.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xai.js","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":";;;AAsBA,4CAEC;AAxBY,QAAA,iCAAiC,GAC5C,sCAAsC,CAAC;AAEzC,kBAAkB;AACL,QAAA,cAAc,GAAG,UAAU,CAAC;AAC5B,QAAA,yBAAyB,GAAG,0BAA0B,CAAC;AACvD,QAAA,6BAA6B,GAAG,8BAA8B,CAAC;AAC/D,QAAA,6BAA6B,GAAG,yBAAyB,CAAC;AAC1D,QAAA,iCAAiC,GAAG,6BAA6B,CAAC;AAE/E,4BAA4B;AACf,QAAA,2BAA2B,GAAG;IACzC,sBAAc;IACd,iCAAyB;IACzB,qCAA6B;IAC7B,qCAA6B;IAC7B,yCAAiC;CAClC,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,OAAO,mCAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC"}
1
+ {"version":3,"file":"xai.js","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":";;;AAwBA,4CAEC;AAKD,8DAEC;AAKD,oEAIC;AA1CY,QAAA,iCAAiC,GAC5C,sCAAsC,CAAC;AAEzC,kBAAkB;AACL,QAAA,cAAc,GAAG,UAAU,CAAC;AAC5B,QAAA,yBAAyB,GAAG,0BAA0B,CAAC;AACvD,QAAA,6BAA6B,GAAG,8BAA8B,CAAC;AAC/D,QAAA,6BAA6B,GAAG,yBAAyB,CAAC;AAC1D,QAAA,iCAAiC,GAAG,6BAA6B,CAAC;AAI/E,4BAA4B;AACf,QAAA,2BAA2B,GAAG;IACzC,sBAAc;IACd,iCAAyB;IACzB,qCAA6B;IAC7B,qCAA6B;IAC7B,yCAAiC;CAClC,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,OAAO,mCAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,KAAa;IACrD,OAAO,KAAK,KAAK,sBAAc,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAC1C,KAAa;IAEb,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
@@ -2,6 +2,7 @@ import { ChatService } from '../ChatService';
2
2
  import { ChatResponseLength, GPT5PresetKey } from '../../constants/chat';
3
3
  import type { MistralReasoningEffort } from '../../constants/mistral';
4
4
  import type { PlamoReasoningEffort } from '../../constants/plamo';
5
+ import type { XaiReasoningEffort } from '../../constants/xai';
5
6
  import { ToolDefinition, MCPServerConfig } from '../../types';
6
7
  /**
7
8
  * Options for chat service providers
@@ -21,7 +22,7 @@ export interface BaseChatServiceOptions {
21
22
  responseLength?: ChatResponseLength;
22
23
  /** Verbosity level for GPT-5 models (OpenAI only) */
23
24
  verbosity?: 'low' | 'medium' | 'high';
24
- /** Reasoning effort level for GPT-5 models (OpenAI) and gpt-oss models (OpenRouter) */
25
+ /** Reasoning effort level for reasoning-capable providers */
25
26
  reasoning_effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
26
27
  /** GPT-5 usage preset (OpenAI only) - overrides individual reasoning/verbosity settings */
27
28
  gpt5Preset?: GPT5PresetKey;
@@ -81,7 +82,10 @@ export type PlamoChatServiceOptions = Omit<DisallowKeys<BaseChatServiceOptions,
81
82
  reasoning_effort?: PlamoReasoningEffort;
82
83
  };
83
84
  export type ZAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'reasoning_effort' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl'>;
84
- export type XAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'reasoning_effort' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl' | 'thinking' | 'responseFormat'>;
85
+ export type XAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl' | 'thinking' | 'responseFormat'> & {
86
+ /** xAI reasoning effort. Only sent for models that support it. */
87
+ reasoning_effort?: XaiReasoningEffort;
88
+ };
85
89
  export type GeminiNanoChatServiceOptions = {
86
90
  /** API Key is not needed for Gemini Nano (browser built-in AI) */
87
91
  apiKey?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/services/providers/ChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C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AAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,QAAQ,GAAG,sBAAsB;IACpE;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,CAAC;IAElD;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;OAGG;IACH,kBAAkB,IAAI,MAAM,EAAE,CAAC;IAE/B;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,qBAAqB,IAAI,kBAAkB,CAAC;IAE5C;;OAEG;IACH,6BAA6B,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAElE;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC;IAE1B;;;OAGG;IACH,sBAAsB,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACjD"}
1
+ {"version":3,"file":"ChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/services/providers/ChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,Q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AW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,QAAQ,GAAG,sBAAsB;IACpE;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,CAAC;IAElD;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;OAGG;IACH,kBAAkB,IAAI,MAAM,EAAE,CAAC;IAE/B;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,qBAAqB,IAAI,kBAAkB,CAAC;IAE5C;;OAEG;IACH,6BAA6B,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAElE;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC;IAE1B;;;OAGG;IACH,sBAAsB,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACjD"}
@@ -1,6 +1,7 @@
1
1
  import { ChatService } from '../../ChatService';
2
2
  import { Message, MessageWithVision } from '../../../types';
3
3
  import { ToolDefinition, ToolChatCompletion } from '../../../types';
4
+ import type { XaiReasoningEffort } from '../../../constants/xai';
4
5
  import { ChatResponseLength } from '../../../constants/chat';
5
6
  /**
6
7
  * xAI implementation of ChatService (OpenAI-compatible Chat Completions)
@@ -14,13 +15,14 @@ export declare class XAIChatService implements ChatService {
14
15
  private tools;
15
16
  private endpoint;
16
17
  private responseLength?;
18
+ private reasoningEffort?;
17
19
  /**
18
20
  * Constructor
19
21
  * @param apiKey xAI API key
20
22
  * @param model Name of the model to use
21
23
  * @param visionModel Name of the vision model
22
24
  */
23
- constructor(apiKey: string, model?: string, visionModel?: string, tools?: ToolDefinition[], endpoint?: string, responseLength?: ChatResponseLength);
25
+ constructor(apiKey: string, model?: string, visionModel?: string, tools?: ToolDefinition[], endpoint?: string, responseLength?: ChatResponseLength, reasoningEffort?: XaiReasoningEffort);
24
26
  /**
25
27
  * Get the current model name
26
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatService.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMpE,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAUjC;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAS;IAElC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,cAAc,CAAC,CAAqB;IAE5C;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAA0C,EACjD,WAAW,GAAE,MAA0C,EACvD,KAAK,CAAC,EAAE,cAAc,EAAE,EACxB,QAAQ,GAAE,MAA0C,EACpD,cAAc,CAAC,EAAE,kBAAkB;IAUrC;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACG,WAAW,CACf,QAAQ,EAAE,OAAO,EAAE,EACnB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACzC,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAClD,OAAO,CAAC,IAAI,CAAC;IAehB;;OAEG;IACG,iBAAiB,CACrB,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACzC,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAClD,OAAO,CAAC,IAAI,CAAC;IAsBhB;;OAEG;IACG,QAAQ,CACZ,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,GAAE,OAAc,EACtB,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC;IAK9B;;OAEG;IACG,cAAc,CAClB,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,MAAM,GAAE,OAAe,EACvB,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC;YAgBhB,aAAa;YAUb,OAAO;IAerB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA6BxB,OAAO,CAAC,oBAAoB;YAId,YAAY;IAO1B;;OAEG;YACW,WAAW;IAUzB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB"}
1
+ {"version":3,"file":"XAIChatService.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAUjC;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAS;IAElC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACt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AAK,IAAe,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC;YAgBhB,aAAa;YAUb,OAAO;IAerB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiCxB,OAAO,CAAC,oBAAoB;YAId,YAAY;IAO1B;;OAEG;YACW,WAAW;IAUzB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB"}
@@ -15,7 +15,7 @@ class XAIChatService {
15
15
  * @param model Name of the model to use
16
16
  * @param visionModel Name of the vision model
17
17
  */
18
- constructor(apiKey, model = xai_1.MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = xai_1.MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = xai_1.ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength) {
18
+ constructor(apiKey, model = xai_1.MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = xai_1.MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = xai_1.ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength, reasoningEffort) {
19
19
  /** Provider name */
20
20
  this.provider = 'xai';
21
21
  this.apiKey = apiKey;
@@ -24,6 +24,7 @@ class XAIChatService {
24
24
  this.endpoint = endpoint;
25
25
  this.responseLength = responseLength;
26
26
  this.visionModel = visionModel;
27
+ this.reasoningEffort = reasoningEffort;
27
28
  }
28
29
  /**
29
30
  * Get the current model name
@@ -116,6 +117,9 @@ class XAIChatService {
116
117
  if (tokenLimit !== undefined) {
117
118
  body.max_tokens = tokenLimit;
118
119
  }
120
+ if (this.reasoningEffort && (0, xai_1.isXaiReasoningEffortModel)(model)) {
121
+ body.reasoning_effort = this.reasoningEffort;
122
+ }
119
123
  const tools = this.buildToolsDefinition();
120
124
  if (tools.length > 0) {
121
125
  body.tools = tools;
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":";;;AAGA,gDAIgC;AAChC,kD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,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACzD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAC5B,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,oBAAoB;QAC1B,OAAO,IAAA,kCAA0B,EAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACpE,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,GAAa,EAAE,SAA8B;QACtE,OAAO,IAAA,uCAA+B,EAAC,GAAG,EAAE,SAAS,EAAE;YACrD,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,GAAa,EACb,SAA8B;QAE9B,OAAO,IAAA,uCAA+B,EAAC,GAAG,EAAE,SAAS,EAAE;YACrD,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,IAAS;QAC5B,OAAO,IAAA,oCAA4B,EAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AA9ND,wCA8NC"}
1
+ {"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":";;;AAGA,gDAKgC;AAEhC,kDAGiC;AACjC,gFAA6E;AAC7E,0CAMwB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CACF;AArOD,wCAqOC"}
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,qBAAa,sBACX,YAAW,mBAAmB,CAAC,qBAAqB,CAAC;IAErD;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW;IAwB9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAU9B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAI3C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;CAGjE"}
1
+ {"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,qBAAa,sBACX,YAAW,mBAAmB,CAAC,qBAAqB,CAAC;IAErD;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW;IAyB9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAU9B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAI3C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;CAGjE"}
@@ -22,7 +22,7 @@ class XAIChatServiceProvider {
22
22
  validate: 'explicit',
23
23
  });
24
24
  const tools = options.tools;
25
- return new XAIChatService_1.XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || xai_1.ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength);
25
+ return new XAIChatService_1.XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || xai_1.ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength, options.reasoning_effort ?? (0, xai_1.getDefaultXaiReasoningEffort)(model));
26
26
  }
27
27
  /**
28
28
  * Get the provider name
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,gDAQgC;AAEhC,qDAAkD;AAOlD,0CAAoD;AAEpD;;GAEG;AACH,MAAa,sBAAsB;IAGjC;;OAEG;IACH,iBAAiB,CAAC,OAA8B;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACtD,MAAM,WAAW,GAAG,IAAA,0BAAkB,EAAC;YACrC,KAAK;YACL,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,EAAE;YAChD,sBAAsB,EAAE,CAAC,WAAW,EAAE,EAAE,CACtC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC;YAC1C,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAiC,OAAO,CAAC,KAAK,CAAC;QAE1D,OAAO,IAAI,+BAAc,CACvB,OAAO,CAAC,MAAM,EACd,KAAK,EACL,WAAW,EACX,KAAK,EACL,OAAO,CAAC,QAAQ,IAAI,uCAAiC,EACrD,OAAO,CAAC,cAAc,CACvB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO;YACL,oBAAc;YACd,+BAAyB;YACzB,mCAA6B;YAC7B,mCAA6B;YAC7B,uCAAiC;SAClC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,uCAAiC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACK,qBAAqB;QAC3B,OAAO,uCAAiC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,qBAAqB,EAAE,KAAK,aAAa,CAAC;IACxD,CAAC;IAED,qBAAqB;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,KAAa;QAClC,OAAO,IAAA,sBAAgB,EAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,6BAA6B,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1E,CAAC;CACF;AArFD,wDAqFC"}
1
+ {"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,gDASgC;AAEhC,qDAAkD;AAOlD,0CAAoD;AAEpD;;GAEG;AACH,MAAa,sBAAsB;IAGjC;;OAEG;IACH,iBAAiB,CAAC,OAA8B;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAA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BAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1E,CAAC;CACF;AAtFD,wDAsFC"}
@@ -4,9 +4,18 @@ export declare const MODEL_GROK_4_20_REASONING = "grok-4.20-0309-reasoning";
4
4
  export declare const MODEL_GROK_4_20_NON_REASONING = "grok-4.20-0309-non-reasoning";
5
5
  export declare const MODEL_GROK_4_1_FAST_REASONING = "grok-4-1-fast-reasoning";
6
6
  export declare const MODEL_GROK_4_1_FAST_NON_REASONING = "grok-4-1-fast-non-reasoning";
7
+ export type XaiReasoningEffort = 'none' | 'low' | 'medium' | 'high';
7
8
  export declare const XAI_VISION_SUPPORTED_MODELS: string[];
8
9
  /**
9
10
  * Check if a model supports vision capabilities
10
11
  */
11
12
  export declare function isXaiVisionModel(model: string): boolean;
13
+ /**
14
+ * Check if a model supports the xAI reasoning_effort parameter
15
+ */
16
+ export declare function isXaiReasoningEffortModel(model: string): boolean;
17
+ /**
18
+ * Get default reasoning effort for xAI models
19
+ */
20
+ export declare function getDefaultXaiReasoningEffort(model: string): XaiReasoningEffort | undefined;
12
21
  //# sourceMappingURL=xai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xai.d.ts","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,yCACN,CAAC;AAGzC,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AACpE,eAAO,MAAM,6BAA6B,iCAAiC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAG/E,eAAO,MAAM,2BAA2B,UAMvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD"}
1
+ {"version":3,"file":"xai.d.ts","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,yCACN,CAAC;AAGzC,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AACpE,eAAO,MAAM,6BAA6B,iCAAiC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAE/E,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGpE,eAAO,MAAM,2BAA2B,UAMvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GACZ,kBAAkB,GAAG,SAAS,CAEhC"}
@@ -19,4 +19,16 @@ export const XAI_VISION_SUPPORTED_MODELS = [
19
19
  export function isXaiVisionModel(model) {
20
20
  return XAI_VISION_SUPPORTED_MODELS.includes(model);
21
21
  }
22
+ /**
23
+ * Check if a model supports the xAI reasoning_effort parameter
24
+ */
25
+ export function isXaiReasoningEffortModel(model) {
26
+ return model === MODEL_GROK_4_3;
27
+ }
28
+ /**
29
+ * Get default reasoning effort for xAI models
30
+ */
31
+ export function getDefaultXaiReasoningEffort(model) {
32
+ return isXaiReasoningEffortModel(model) ? 'none' : undefined;
33
+ }
22
34
  //# sourceMappingURL=xai.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xai.js","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAC5C,sCAAsC,CAAC;AAEzC,kBAAkB;AAClB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CA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ACH,MAAM,UAAU,4BAA4B,CAC1C,KAAa;IAEb,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
@@ -2,6 +2,7 @@ import { ChatService } from '../ChatService';
2
2
  import { ChatResponseLength, GPT5PresetKey } from '../../constants/chat';
3
3
  import type { MistralReasoningEffort } from '../../constants/mistral';
4
4
  import type { PlamoReasoningEffort } from '../../constants/plamo';
5
+ import type { XaiReasoningEffort } from '../../constants/xai';
5
6
  import { ToolDefinition, MCPServerConfig } from '../../types';
6
7
  /**
7
8
  * Options for chat service providers
@@ -21,7 +22,7 @@ export interface BaseChatServiceOptions {
21
22
  responseLength?: ChatResponseLength;
22
23
  /** Verbosity level for GPT-5 models (OpenAI only) */
23
24
  verbosity?: 'low' | 'medium' | 'high';
24
- /** Reasoning effort level for GPT-5 models (OpenAI) and gpt-oss models (OpenRouter) */
25
+ /** Reasoning effort level for reasoning-capable providers */
25
26
  reasoning_effort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
26
27
  /** GPT-5 usage preset (OpenAI only) - overrides individual reasoning/verbosity settings */
27
28
  gpt5Preset?: GPT5PresetKey;
@@ -81,7 +82,10 @@ export type PlamoChatServiceOptions = Omit<DisallowKeys<BaseChatServiceOptions,
81
82
  reasoning_effort?: PlamoReasoningEffort;
82
83
  };
83
84
  export type ZAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'reasoning_effort' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl'>;
84
- export type XAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'reasoning_effort' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl' | 'thinking' | 'responseFormat'>;
85
+ export type XAIChatServiceOptions = DisallowKeys<BaseChatServiceOptions, 'verbosity' | 'gpt5Preset' | 'gpt5EndpointPreference' | 'enableReasoningSummary' | 'includeReasoning' | 'reasoningMaxTokens' | 'baseUrl' | 'thinking' | 'responseFormat'> & {
86
+ /** xAI reasoning effort. Only sent for models that support it. */
87
+ reasoning_effort?: XaiReasoningEffort;
88
+ };
85
89
  export type GeminiNanoChatServiceOptions = {
86
90
  /** API Key is not needed for Gemini Nano (browser built-in AI) */
87
91
  apiKey?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../src/services/providers/ChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,qDAAqD;IACrD,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;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6BAA6B,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAElE;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC;IAE1B;;;OAGG;IACH,sBAAsB,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACjD"}
@@ -1,6 +1,7 @@
1
1
  import { ChatService } from '../../ChatService';
2
2
  import { Message, MessageWithVision } from '../../../types';
3
3
  import { ToolDefinition, ToolChatCompletion } from '../../../types';
4
+ import type { XaiReasoningEffort } from '../../../constants/xai';
4
5
  import { ChatResponseLength } from '../../../constants/chat';
5
6
  /**
6
7
  * xAI implementation of ChatService (OpenAI-compatible Chat Completions)
@@ -14,13 +15,14 @@ export declare class XAIChatService implements ChatService {
14
15
  private tools;
15
16
  private endpoint;
16
17
  private responseLength?;
18
+ private reasoningEffort?;
17
19
  /**
18
20
  * Constructor
19
21
  * @param apiKey xAI API key
20
22
  * @param model Name of the model to use
21
23
  * @param visionModel Name of the vision model
22
24
  */
23
- constructor(apiKey: string, model?: string, visionModel?: string, tools?: ToolDefinition[], endpoint?: string, responseLength?: ChatResponseLength);
25
+ constructor(apiKey: string, model?: string, visionModel?: string, tools?: ToolDefinition[], endpoint?: string, responseLength?: ChatResponseLength, reasoningEffort?: XaiReasoningEffort);
24
26
  /**
25
27
  * Get the current model name
26
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatService.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMpE,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAUjC;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,oBA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B,iBAAiB,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC;YAgBhB,aAAa;YAUb,OAAO;IAerB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA6BxB,OAAO,CAAC,oBAAoB;YAId,YAAY;IAO1B;;OAEG;YACW,WAAW;IAUzB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB"}
1
+ {"version":3,"file":"XAIChatService.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAUjC;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAS;IAElC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,cAAc,CAAC,CAAqB;IAC5C,OAAO,CAAC,eAAe,CAAC,CAAqB;IAE7C;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAA0C,EACjD,WAAW,GAAE,MAA0C,EACvD,KAAK,CAAC,EAAE,cAAc,EAAE,EACxB,QAAQ,GAAE,MAA0C,EACpD,cAAc,CAAC,EAAE,kBAAkB,EACnC,eAAe,CAAC,EAAE,kBAAkB;I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I_CHAT_COMPLETIONS_API, MODEL_GROK_4_1_FAST_NON_REASONING, isXaiReasoningEffortModel, isXaiVisionModel, } from '../../../constants/xai';
2
2
  import { getMaxTokensForResponseLength, } from '../../../constants/chat';
3
3
  import { ChatServiceHttpClient } from '../../../utils/chatServiceHttpClient';
4
4
  import { buildOpenAICompatibleTools, parseOpenAICompatibleOneShot, parseOpenAICompatibleTextStream, parseOpenAICompatibleToolStream, processChatWithOptionalTools, } from '../../../utils';
@@ -12,7 +12,7 @@ export class XAIChatService {
12
12
  * @param model Name of the model to use
13
13
  * @param visionModel Name of the vision model
14
14
  */
15
- constructor(apiKey, model = MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength) {
15
+ constructor(apiKey, model = MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength, reasoningEffort) {
16
16
  /** Provider name */
17
17
  this.provider = 'xai';
18
18
  this.apiKey = apiKey;
@@ -21,6 +21,7 @@ export class XAIChatService {
21
21
  this.endpoint = endpoint;
22
22
  this.responseLength = responseLength;
23
23
  this.visionModel = visionModel;
24
+ this.reasoningEffort = reasoningEffort;
24
25
  }
25
26
  /**
26
27
  * Get the current model name
@@ -113,6 +114,9 @@ export class XAIChatService {
113
114
  if (tokenLimit !== undefined) {
114
115
  body.max_tokens = tokenLimit;
115
116
  }
117
+ if (this.reasoningEffort && isXaiReasoningEffortModel(model)) {
118
+ body.reasoning_effort = this.reasoningEffort;
119
+ }
116
120
  const tools = this.buildToolsDefinition();
117
121
  if (tools.length > 0) {
118
122
  body.tools = tools;
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iCAAiC,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AC,CAAC;IAC5C,CAAC;CACF"}
1
+ {"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEL,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,OAAO,cAAc;IAYzB;;;;;OAKG;IACH,YACE,MAAc,EACd,QAAgB,iCAAiC,EACjD,cAAsB,iCAAiC,EACvD,KAAwB,EACxB,WAAmB,iCAAiC,EACpD,cAAmC,EACnC,eAAoC;QAxBtC,oBAAoB;QACX,aAAQ,GAAW,KAAK,CAAC;QAyBhC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,QAAmB,EACnB,iBAAyC,EACzC,kBAAmD;QAEnD,MAAM,4BAA4B,CAAC;YAC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2B,EAAE,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,GAAa,EACb,SAA8B;QAE9B,OAAO,+BAA+B,CAAC,GAAG,EAAE,SAAS,EAAE;YACrD,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,IAAS;QAC5B,OAAO,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,qBAAa,sBACX,YAAW,mBAAmB,CAAC,qBAAqB,CAAC;IAErD;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW;IAwB9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAU9B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAI3C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;CAGjE"}
1
+ {"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;GAEG;AACH,qBAAa,sBACX,YAAW,mBAAmB,CAAC,qBAAqB,CAAC;IAErD;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,WAAW;IAyB9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAU9B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAI3C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;CAGjE"}
@@ -1,4 +1,4 @@
1
- import { ENDPOINT_XAI_CHAT_COMPLETIONS_API, MODEL_GROK_4_3, MODEL_GROK_4_20_REASONING, MODEL_GROK_4_20_NON_REASONING, MODEL_GROK_4_1_FAST_REASONING, MODEL_GROK_4_1_FAST_NON_REASONING, isXaiVisionModel, } from '../../../constants/xai';
1
+ import { ENDPOINT_XAI_CHAT_COMPLETIONS_API, MODEL_GROK_4_3, MODEL_GROK_4_20_REASONING, MODEL_GROK_4_20_NON_REASONING, MODEL_GROK_4_1_FAST_REASONING, MODEL_GROK_4_1_FAST_NON_REASONING, getDefaultXaiReasoningEffort, isXaiVisionModel, } from '../../../constants/xai';
2
2
  import { XAIChatService } from './XAIChatService';
3
3
  import { resolveVisionModel } from '../../../utils';
4
4
  /**
@@ -19,7 +19,7 @@ export class XAIChatServiceProvider {
19
19
  validate: 'explicit',
20
20
  });
21
21
  const tools = options.tools;
22
- return new XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength);
22
+ return new XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength, options.reasoning_effort ?? getDefaultXaiReasoningEffort(model));
23
23
  }
24
24
  /**
25
25
  * Get the provider name
@@ -1 +1 @@
1
- {"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAGjC;;OAEG;IACH,iBAAiB,CAAC,OAA8B;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACtD,MAAM,WAAW,GAAG,kBAAkB,CAAC;YACrC,KAAK;YACL,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,EAAE;YAChD,sBAAsB,EAAE,CAAC,WAAW,EAAE,EAAE,CACtC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC;YAC1C,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAiC,OAAO,CAAC,KAAK,CAAC;QAE1D,OAAO,IAAI,cAAc,CACvB,OAAO,CAAC,MAAM,EACd,KAAK,EACL,WAAW,EACX,KAAK,EACL,OAAO,CAAC,QAAQ,IAAI,iCAAiC,EACrD,OAAO,CAAC,cAAc,CACvB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO;YACL,cAAc;YACd,yBAAyB;YACzB,6BAA6B;YAC7B,6BAA6B;YAC7B,iCAAiC;SAClC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACK,qBAAqB;QAC3B,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,qBAAqB,EAAE,KAAK,aAAa,CAAC;IACxD,CAAC;IAED,qBAAqB;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,KAAa;QAClC,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,6BAA6B,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1E,CAAC;CACF"}
1
+ {"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAGjC;;OAEG;IACH,iBAAiB,CAAC,OAA8B;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACtD,MAA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AAC,CAAC,aAAa,CAAC;IAC1E,CAAC;CACF"}
@@ -215,6 +215,7 @@ var AITuberOnAirChat = (() => {
215
215
  allowsReasoningXHigh: () => allowsReasoningXHigh,
216
216
  buildOpenAICompatibleTools: () => buildOpenAICompatibleTools,
217
217
  getDefaultReasoningEffortForGPT5Model: () => getDefaultReasoningEffortForGPT5Model,
218
+ getDefaultXaiReasoningEffort: () => getDefaultXaiReasoningEffort,
218
219
  getMaxTokensForResponseLength: () => getMaxTokensForResponseLength,
219
220
  installGASFetch: () => installGASFetch,
220
221
  isGPT5Model: () => isGPT5Model,
@@ -226,6 +227,7 @@ var AITuberOnAirChat = (() => {
226
227
  isOpenRouterFreeModel: () => isOpenRouterFreeModel,
227
228
  isOpenRouterVisionModel: () => isOpenRouterVisionModel,
228
229
  isResponsesOnlyGPT5Model: () => isResponsesOnlyGPT5Model,
230
+ isXaiReasoningEffortModel: () => isXaiReasoningEffortModel,
229
231
  isXaiVisionModel: () => isXaiVisionModel,
230
232
  isZaiToolStreamModel: () => isZaiToolStreamModel,
231
233
  isZaiVisionModel: () => isZaiVisionModel,
@@ -503,6 +505,12 @@ var AITuberOnAirChat = (() => {
503
505
  function isXaiVisionModel(model) {
504
506
  return XAI_VISION_SUPPORTED_MODELS.includes(model);
505
507
  }
508
+ function isXaiReasoningEffortModel(model) {
509
+ return model === MODEL_GROK_4_3;
510
+ }
511
+ function getDefaultXaiReasoningEffort(model) {
512
+ return isXaiReasoningEffortModel(model) ? "none" : void 0;
513
+ }
506
514
 
507
515
  // src/constants/kimi.ts
508
516
  var ENDPOINT_KIMI_CHAT_COMPLETIONS_API = "https://api.moonshot.ai/v1/chat/completions";
@@ -4645,7 +4653,7 @@ If it's in another language, summarize in that language.
4645
4653
  * @param model Name of the model to use
4646
4654
  * @param visionModel Name of the vision model
4647
4655
  */
4648
- constructor(apiKey, model = MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength) {
4656
+ constructor(apiKey, model = MODEL_GROK_4_1_FAST_NON_REASONING, visionModel = MODEL_GROK_4_1_FAST_NON_REASONING, tools, endpoint = ENDPOINT_XAI_CHAT_COMPLETIONS_API, responseLength, reasoningEffort) {
4649
4657
  /** Provider name */
4650
4658
  this.provider = "xai";
4651
4659
  this.apiKey = apiKey;
@@ -4654,6 +4662,7 @@ If it's in another language, summarize in that language.
4654
4662
  this.endpoint = endpoint;
4655
4663
  this.responseLength = responseLength;
4656
4664
  this.visionModel = visionModel;
4665
+ this.reasoningEffort = reasoningEffort;
4657
4666
  }
4658
4667
  /**
4659
4668
  * Get the current model name
@@ -4751,6 +4760,9 @@ If it's in another language, summarize in that language.
4751
4760
  if (tokenLimit !== void 0) {
4752
4761
  body.max_tokens = tokenLimit;
4753
4762
  }
4763
+ if (this.reasoningEffort && isXaiReasoningEffortModel(model)) {
4764
+ body.reasoning_effort = this.reasoningEffort;
4765
+ }
4754
4766
  const tools = this.buildToolsDefinition();
4755
4767
  if (tools.length > 0) {
4756
4768
  body.tools = tools;
@@ -4804,7 +4816,8 @@ If it's in another language, summarize in that language.
4804
4816
  visionModel,
4805
4817
  tools,
4806
4818
  options.endpoint || ENDPOINT_XAI_CHAT_COMPLETIONS_API,
4807
- options.responseLength
4819
+ options.responseLength,
4820
+ options.reasoning_effort ?? getDefaultXaiReasoningEffort(model)
4808
4821
  );
4809
4822
  }
4810
4823
  /**
@@ -1,4 +1,4 @@
1
- "use strict";var AITuberOnAirChat=(()=>{var ro=Object.defineProperty;var Wr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var $r=Object.prototype.hasOwnProperty;var zr=(r,e)=>{for(var t in e)ro(r,t,{get:e[t],enumerable:!0})},qr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Br(e))!$r.call(r,i)&&i!==t&&ro(r,i,{get:()=>e[i],enumerable:!(o=Wr(e,i))||o.enumerable});return r};var jr=r=>qr(ro({},"__esModule",{value:!0}),r);var bi={};zr(bi,{CHAT_RESPONSE_LENGTH:()=>T,CLAUDE_VISION_SUPPORTED_MODELS:()=>We,ChatServiceFactory:()=>ke,ChatServiceHttpClient:()=>f,ClaudeChatService:()=>me,ClaudeChatServiceProvider:()=>de,DEEPSEEK_API_BASE_URL:()=>sr,DEEPSEEK_DEPRECATED_MODELS:()=>ti,DEEPSEEK_SUPPORTED_MODELS:()=>Po,DEFAULT_MAX_TOKENS:()=>Vo,DEFAULT_SUMMARY_PROMPT_TEMPLATE:()=>ri,DEFAULT_VISION_PROMPT:()=>oi,DeepSeekChatService:()=>ge,DeepSeekChatServiceProvider:()=>_e,EMOTION_TAG_CLEANUP_REGEX:()=>Fo,EMOTION_TAG_REGEX:()=>Mr,ENDPOINT_CLAUDE_API:()=>co,ENDPOINT_DEEPSEEK_CHAT_COMPLETIONS_API:()=>Xe,ENDPOINT_GEMINI_API:()=>po,ENDPOINT_KIMI_CHAT_COMPLETIONS_API:()=>ae,ENDPOINT_MISTRAL_CHAT_COMPLETIONS_API:()=>Ze,ENDPOINT_OPENAI_CHAT_COMPLETIONS_API:()=>U,ENDPOINT_OPENAI_RESPONSES_API:()=>A,ENDPOINT_OPENROUTER_API:()=>Be,ENDPOINT_PLAMO_CHAT_COMPLETIONS_API:()=>et,ENDPOINT_SAKANA_CHAT_COMPLETIONS_API:()=>Qe,ENDPOINT_XAI_CHAT_COMPLETIONS_API:()=>ze,ENDPOINT_ZAI_CHAT_COMPLETIONS_API:()=>$e,EmotionParser:()=>he,GEMINI_DEPRECATED_MODELS:()=>er,GEMINI_NANO_MAX_CONTEXT_MESSAGES:()=>Go,GEMINI_RECOMMENDED_MODELS:()=>lt,GEMINI_VISION_SUPPORTED_MODELS:()=>He,GPT5_PRESETS:()=>ko,GPT_5_MODELS:()=>Wo,GeminiChatService:()=>fe,GeminiChatServiceProvider:()=>Me,GeminiNanoChatService:()=>ve,GeminiNanoChatServiceProvider:()=>Oe,HttpError:()=>F,KIMI_THINKING_REQUIRED_MODELS:()=>nr,KIMI_VISION_SUPPORTED_MODELS:()=>ir,KimiChatService:()=>Ee,KimiChatServiceProvider:()=>Se,MAX_TOKENS_BY_LENGTH:()=>Yt,MISTRAL_API_BASE_URL:()=>cr,MISTRAL_REASONING_EFFORT_SUPPORTED_MODELS:()=>ur,MISTRAL_SUPPORTED_MODELS:()=>Ao,MISTRAL_VISION_SUPPORTED_MODELS:()=>hr,MODEL_ANTHROPIC_CLAUDE_3_5_SONNET:()=>mo,MODEL_ANTHROPIC_CLAUDE_3_7_SONNET:()=>Vt,MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU:()=>kt,MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST:()=>bt,MODEL_ANTHROPIC_CLAUDE_OPUS_4:()=>Nt,MODEL_ANTHROPIC_CLAUDE_SONNET_4:()=>wt,MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST:()=>Rt,MODEL_CLAUDE_3_5_HAIKU:()=>Jr,MODEL_CLAUDE_3_5_SONNET:()=>Xr,MODEL_CLAUDE_3_7_SONNET:()=>Zr,MODEL_CLAUDE_3_HAIKU:()=>pt,MODEL_CLAUDE_4_5_HAIKU:()=>R,MODEL_CLAUDE_4_5_OPUS:()=>mt,MODEL_CLAUDE_4_5_SONNET:()=>ht,MODEL_CLAUDE_4_6_OPUS:()=>gt,MODEL_CLAUDE_4_6_SONNET:()=>dt,MODEL_CLAUDE_4_7_OPUS:()=>_t,MODEL_CLAUDE_4_8_OPUS:()=>ft,MODEL_CLAUDE_4_OPUS:()=>ut,MODEL_CLAUDE_4_SONNET:()=>ct,MODEL_DEEPSEEK_CHAT:()=>lr,MODEL_DEEPSEEK_REASONER:()=>pr,MODEL_DEEPSEEK_V4_FLASH:()=>pe,MODEL_DEEPSEEK_V4_PRO:()=>ar,MODEL_FUGU:()=>ce,MODEL_FUGU_ULTRA:()=>dr,MODEL_FUGU_ULTRA_20260615:()=>gr,MODEL_GEMINI_2_5_FLASH:()=>Zo,MODEL_GEMINI_2_5_FLASH_LITE:()=>Yo,MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17:()=>Qo,MODEL_GEMINI_2_5_PRO:()=>Xo,MODEL_GEMINI_3_1_FLASH_LITE:()=>j,MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW:()=>qo,MODEL_GEMINI_3_1_PRO_PREVIEW:()=>zo,MODEL_GEMINI_3_5_FLASH:()=>at,MODEL_GEMINI_3_FLASH_PREVIEW:()=>Jo,MODEL_GEMINI_3_PRO_PREVIEW:()=>jo,MODEL_GEMINI_NANO:()=>Z,MODEL_GEMMA_4_26B_A4B_IT:()=>$o,MODEL_GEMMA_4_31B_IT:()=>Bo,MODEL_GLM_4_6:()=>To,MODEL_GLM_4_6V:()=>Bt,MODEL_GLM_4_6V_FLASH:()=>X,MODEL_GLM_4_6V_FLASHX:()=>$t,MODEL_GLM_4_7:()=>Eo,MODEL_GLM_4_7_FLASH:()=>Co,MODEL_GLM_4_7_FLASHX:()=>So,MODEL_GLM_5:()=>vo,MODEL_GLM_5_2:()=>ie,MODEL_GLM_5_TURBO:()=>Oo,MODEL_GOOGLE_GEMINI_2_5_FLASH:()=>Kt,MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:()=>Ht,MODEL_GOOGLE_GEMINI_2_5_PRO:()=>Ut,MODEL_GOOGLE_GEMINI_FLASH_LATEST:()=>Ft,MODEL_GOOGLE_GEMINI_PRO_LATEST:()=>Gt,MODEL_GPT_4O:()=>nt,MODEL_GPT_4O_MINI:()=>z,MODEL_GPT_4_1:()=>ot,MODEL_GPT_4_1_MINI:()=>rt,MODEL_GPT_4_1_NANO:()=>it,MODEL_GPT_5:()=>ee,MODEL_GPT_5_1:()=>te,MODEL_GPT_5_4:()=>H,MODEL_GPT_5_4_MINI:()=>B,MODEL_GPT_5_4_NANO:()=>$,MODEL_GPT_5_4_PRO:()=>G,MODEL_GPT_5_5:()=>W,MODEL_GPT_5_MINI:()=>Q,MODEL_GPT_5_NANO:()=>K,MODEL_GPT_OSS_20B_FREE:()=>b,MODEL_GROK_4_1_FAST_NON_REASONING:()=>N,MODEL_GROK_4_1_FAST_REASONING:()=>Jt,MODEL_GROK_4_20_NON_REASONING:()=>jt,MODEL_GROK_4_20_REASONING:()=>qt,MODEL_GROK_4_3:()=>zt,MODEL_KIMI_K2_5:()=>Xt,MODEL_KIMI_K2_6:()=>w,MODEL_KIMI_K2_7_CODE:()=>qe,MODEL_KIMI_K2_7_CODE_HIGHSPEED:()=>je,MODEL_MISTRAL_LARGE_2512:()=>Do,MODEL_MISTRAL_LARGE_LATEST:()=>xo,MODEL_MISTRAL_MEDIUM_2508:()=>Io,MODEL_MISTRAL_MEDIUM_3_5:()=>Zt,MODEL_MISTRAL_SMALL_2603:()=>yo,MODEL_MISTRAL_SMALL_LATEST:()=>V,MODEL_MOONSHOTAI_KIMI_K2_5:()=>vt,MODEL_MOONSHOTAI_KIMI_K2_7_CODE:()=>Mt,MODEL_MOONSHOTAI_KIMI_LATEST:()=>Ot,MODEL_O1:()=>so,MODEL_O1_MINI:()=>no,MODEL_O3_MINI:()=>io,MODEL_OPENAI_GPT_4O:()=>xt,MODEL_OPENAI_GPT_4_1_MINI:()=>Dt,MODEL_OPENAI_GPT_4_1_NANO:()=>At,MODEL_OPENAI_GPT_5_1_CHAT:()=>Lt,MODEL_OPENAI_GPT_5_1_CODEX:()=>Pt,MODEL_OPENAI_GPT_5_5:()=>Tt,MODEL_OPENAI_GPT_5_5_PRO:()=>Ct,MODEL_OPENAI_GPT_5_MINI:()=>yt,MODEL_OPENAI_GPT_5_NANO:()=>It,MODEL_OPENAI_GPT_LATEST:()=>Et,MODEL_OPENAI_GPT_MINI_LATEST:()=>St,MODEL_OPENROUTER_AUTO:()=>uo,MODEL_OPENROUTER_FUSION:()=>ho,MODEL_PLAMO_2_2_PRIME:()=>fr,MODEL_PLAMO_3_0_PRIME:()=>ue,MODEL_ZAI_GLM_4_5_AIR:()=>_o,MODEL_ZAI_GLM_4_5_AIR_FREE:()=>Wt,MODEL_ZAI_GLM_4_7_FLASH:()=>go,MODEL_ZAI_GLM_5_2:()=>oe,MistralChatService:()=>Ce,MistralChatServiceProvider:()=>Te,OPENROUTER_CREDITS_THRESHOLD:()=>ei,OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS:()=>Qr,OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS:()=>Yr,OPENROUTER_FREE_MODELS:()=>fo,OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE:()=>Mo,OPENROUTER_VISION_SUPPORTED_MODELS:()=>tr,OpenAIChatService:()=>S,OpenAIChatServiceProvider:()=>Pe,OpenAICompatibleChatServiceProvider:()=>Le,OpenRouterChatService:()=>ye,OpenRouterChatServiceProvider:()=>Ie,PLAMO_API_BASE_URL:()=>_r,PLAMO_SUPPORTED_MODELS:()=>wo,PlamoChatService:()=>xe,PlamoChatServiceProvider:()=>De,SAKANA_API_BASE_URL:()=>mr,SAKANA_SUPPORTED_MODELS:()=>No,SakanaChatService:()=>Ae,SakanaChatServiceProvider:()=>Re,StreamTextAccumulator:()=>v,VISION_SUPPORTED_MODELS:()=>Ge,XAIChatService:()=>be,XAIChatServiceProvider:()=>Ne,XAI_VISION_SUPPORTED_MODELS:()=>rr,ZAIChatService:()=>we,ZAIChatServiceProvider:()=>Ve,ZAI_VISION_SUPPORTED_MODELS:()=>or,allowsReasoningLow:()=>st,allowsReasoningMinimal:()=>Ue,allowsReasoningNone:()=>Fe,allowsReasoningXHigh:()=>lo,buildOpenAICompatibleTools:()=>x,getDefaultReasoningEffortForGPT5Model:()=>Ke,getMaxTokensForResponseLength:()=>E,installGASFetch:()=>Kr,isGPT5Model:()=>q,isKimiThinkingRequiredModel:()=>Je,isKimiVisionModel:()=>le,isMistralReasoningEffort:()=>Ro,isMistralReasoningEffortModel:()=>Ye,isMistralVisionModel:()=>bo,isOpenRouterFreeModel:()=>J,isOpenRouterVisionModel:()=>re,isResponsesOnlyGPT5Model:()=>ao,isXaiVisionModel:()=>se,isZaiToolStreamModel:()=>Lo,isZaiVisionModel:()=>ne,parseOpenAICompatibleOneShot:()=>I,parseOpenAICompatibleTextStream:()=>P,parseOpenAICompatibleToolStream:()=>y,processChatWithOptionalTools:()=>M,refreshOpenRouterFreeModels:()=>fi,resolveVisionModel:()=>O,runOnceText:()=>ai,safeJsonParse:()=>Or,safeParseToolCallInput:()=>Y,screenplayToText:()=>si,textToScreenplay:()=>vr,textsToScreenplay:()=>ni});var U="https://api.openai.com/v1/chat/completions",A="https://api.openai.com/v1/responses",K="gpt-5-nano",Q="gpt-5-mini",ee="gpt-5",te="gpt-5.1",H="gpt-5.4",W="gpt-5.5",B="gpt-5.4-mini",$="gpt-5.4-nano",G="gpt-5.4-pro",ot="gpt-4.1",rt="gpt-4.1-mini",it="gpt-4.1-nano",z="gpt-4o-mini",nt="gpt-4o",io="o3-mini",no="o1-mini",so="o1",Ge=[K,Q,ee,te,H,W,B,$,G,ot,rt,it,z,nt,"o1"],Wo=[K,Q,ee,te,H,W,B,$,G];function q(r){return Wo.includes(r)}function ao(r){return r===G}function lo(r){return r===W||r===H||r===B||r===$||r===G}function Fe(r){return r===te||r===H||r===W||r===B||r===$}function Ue(r){return r===K||r===Q||r===ee}function st(r){return r!==G}function Ke(r){return Fe(r)?"none":Ue(r)?"minimal":"medium"}var po="https://generativelanguage.googleapis.com",Bo="gemma-4-31b-it",$o="gemma-4-26b-a4b-it",at="gemini-3.5-flash",zo="gemini-3.1-pro-preview",j="gemini-3.1-flash-lite",qo="gemini-3.1-flash-lite-preview",jo="gemini-3-pro-preview",Jo="gemini-3-flash-preview",Xo="gemini-2.5-pro",Zo="gemini-2.5-flash",Yo="gemini-2.5-flash-lite",Qo="gemini-2.5-flash-lite-preview-06-17",lt=[at,j,zo,Jo,Xo,Zo,Yo,Bo,$o],er=[qo,jo,Qo],He=[...lt,...er];var co="https://api.anthropic.com/v1/messages",pt="claude-3-haiku-20240307",Jr="claude-3-5-haiku-20241022",Xr="claude-3-5-sonnet-20241022",Zr="claude-3-7-sonnet-20250219",ct="claude-sonnet-4-20250514",ut="claude-opus-4-20250514",ht="claude-sonnet-4-5-20250929",R="claude-haiku-4-5-20251001",mt="claude-opus-4-5-20251101",dt="claude-sonnet-4-6",gt="claude-opus-4-6",_t="claude-opus-4-7",ft="claude-opus-4-8",We=[pt,ct,ut,ht,R,mt,dt,gt,_t,ft];var Be="https://openrouter.ai/api/v1/chat/completions",uo="openrouter/auto",ho="openrouter/fusion",b="openai/gpt-oss-20b:free",Mt="moonshotai/kimi-k2.7-code",vt="moonshotai/kimi-k2.5",Ot="~moonshotai/kimi-latest",Et="~openai/gpt-latest",St="~openai/gpt-mini-latest",Ct="openai/gpt-5.5-pro",Tt="openai/gpt-5.5",Lt="openai/gpt-5.1-chat",Pt="openai/gpt-5.1-codex",yt="openai/gpt-5-mini",It="openai/gpt-5-nano",xt="openai/gpt-4o",Dt="openai/gpt-4.1-mini",At="openai/gpt-4.1-nano",Rt="~anthropic/claude-sonnet-latest",bt="~anthropic/claude-haiku-latest",Nt="anthropic/claude-opus-4",wt="anthropic/claude-sonnet-4",Vt="anthropic/claude-3.7-sonnet",mo="anthropic/claude-3.5-sonnet",kt="anthropic/claude-haiku-4.5",Gt="~google/gemini-pro-latest",Ft="~google/gemini-flash-latest",Ut="google/gemini-2.5-pro",Kt="google/gemini-2.5-flash",Ht="google/gemini-2.5-flash-lite-preview-09-2025",oe="z-ai/glm-5.2",go="z-ai/glm-4.7-flash",_o="z-ai/glm-4.5-air",Wt="z-ai/glm-4.5-air:free",fo=[b,Wt],tr=[Ot,Et,St,Ct,Tt,Lt,Pt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,Ft,Ut,Kt,Ht,Mt,vt],Mo=20,Yr=50,Qr=1e3,ei=10;function J(r){return r.trim().endsWith(":free")}function re(r){return tr.some(e=>r.includes(e))}var $e="https://api.z.ai/api/paas/v4/chat/completions",ie="glm-5.2",vo="glm-5",Oo="glm-5-turbo",Eo="glm-4.7",So="glm-4.7-FlashX",Co="glm-4.7-Flash",To="glm-4.6",Bt="glm-4.6V",$t="glm-4.6V-FlashX",X="glm-4.6V-Flash",or=[Bt,$t,X];function ne(r){return or.includes(r)}function Lo(r){return r.toLowerCase().startsWith("glm-4.6")}var ze="https://api.x.ai/v1/chat/completions",zt="grok-4.3",qt="grok-4.20-0309-reasoning",jt="grok-4.20-0309-non-reasoning",Jt="grok-4-1-fast-reasoning",N="grok-4-1-fast-non-reasoning",rr=[zt,qt,jt,Jt,N];function se(r){return rr.includes(r)}var ae="https://api.moonshot.ai/v1/chat/completions",qe="kimi-k2.7-code",je="kimi-k2.7-code-highspeed",w="kimi-k2.6",Xt="kimi-k2.5",ir=[qe,je,w,Xt],nr=[qe,je];function le(r){return ir.includes(r)}function Je(r){return nr.includes(r)}var sr="https://api.deepseek.com",Xe=`${sr}/chat/completions`,pe="deepseek-v4-flash",ar="deepseek-v4-pro",lr="deepseek-chat",pr="deepseek-reasoner",Po=[pe,ar],ti=[lr,pr];var cr="https://api.mistral.ai/v1",Ze=`${cr}/chat/completions`,V="mistral-small-latest",yo="mistral-small-2603",Zt="mistral-medium-3-5",Io="mistral-medium-2508",xo="mistral-large-latest",Do="mistral-large-2512",Ao=[V,Zt,xo,Do,yo,Io],ur=[V,Zt],hr=[V,yo,Zt,Io,xo,Do];function Ye(r){return ur.includes(r)}function Ro(r){return r==="none"||r==="high"}function bo(r){return hr.includes(r)}var mr="https://api.sakana.ai/v1",Qe=`${mr}/chat/completions`,ce="fugu",dr="fugu-ultra",gr="fugu-ultra-20260615",No=[ce,dr,gr];var _r="https://api.platform.preferredai.jp/v1",et=`${_r}/chat/completions`,ue="plamo-3.0-prime",fr="plamo-2.2-prime",wo=[ue,fr];var T={VERY_SHORT:"veryShort",SHORT:"short",MEDIUM:"medium",LONG:"long",VERY_LONG:"veryLong",DEEP:"deep"},Yt={[T.VERY_SHORT]:40,[T.SHORT]:100,[T.MEDIUM]:200,[T.LONG]:300,[T.VERY_LONG]:1e3,[T.DEEP]:5e3},Vo=5e3,ko={casual:{reasoning_effort:"minimal",verbosity:"low",description:"Fast responses for casual chat, quick questions (GPT-4 like experience)"},balanced:{reasoning_effort:"medium",verbosity:"medium",description:"Balanced reasoning for business tasks, learning, general problem solving"},expert:{reasoning_effort:"high",verbosity:"high",description:"Deep reasoning for research, complex analysis, expert-level tasks"}};function E(r){return r?Yt[r]??Vo:Vo}var oi="You are a friendly AI avatar. Comment on the situation based on the broadcast screen.",ri=`You are a skilled summarizing assistant.
1
+ "use strict";var AITuberOnAirChat=(()=>{var io=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var qr=Object.prototype.hasOwnProperty;var jr=(r,e)=>{for(var t in e)io(r,t,{get:e[t],enumerable:!0})},Xr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of zr(e))!qr.call(r,i)&&i!==t&&io(r,i,{get:()=>e[i],enumerable:!(o=$r(e,i))||o.enumerable});return r};var Jr=r=>Xr(io({},"__esModule",{value:!0}),r);var wi={};jr(wi,{CHAT_RESPONSE_LENGTH:()=>T,CLAUDE_VISION_SUPPORTED_MODELS:()=>We,ChatServiceFactory:()=>ke,ChatServiceHttpClient:()=>f,ClaudeChatService:()=>me,ClaudeChatServiceProvider:()=>de,DEEPSEEK_API_BASE_URL:()=>lr,DEEPSEEK_DEPRECATED_MODELS:()=>ri,DEEPSEEK_SUPPORTED_MODELS:()=>Io,DEFAULT_MAX_TOKENS:()=>Go,DEFAULT_SUMMARY_PROMPT_TEMPLATE:()=>ni,DEFAULT_VISION_PROMPT:()=>ii,DeepSeekChatService:()=>ge,DeepSeekChatServiceProvider:()=>_e,EMOTION_TAG_CLEANUP_REGEX:()=>Ko,EMOTION_TAG_REGEX:()=>Or,ENDPOINT_CLAUDE_API:()=>uo,ENDPOINT_DEEPSEEK_CHAT_COMPLETIONS_API:()=>Ze,ENDPOINT_GEMINI_API:()=>co,ENDPOINT_KIMI_CHAT_COMPLETIONS_API:()=>ae,ENDPOINT_MISTRAL_CHAT_COMPLETIONS_API:()=>Ye,ENDPOINT_OPENAI_CHAT_COMPLETIONS_API:()=>U,ENDPOINT_OPENAI_RESPONSES_API:()=>A,ENDPOINT_OPENROUTER_API:()=>Be,ENDPOINT_PLAMO_CHAT_COMPLETIONS_API:()=>tt,ENDPOINT_SAKANA_CHAT_COMPLETIONS_API:()=>et,ENDPOINT_XAI_CHAT_COMPLETIONS_API:()=>ze,ENDPOINT_ZAI_CHAT_COMPLETIONS_API:()=>$e,EmotionParser:()=>he,GEMINI_DEPRECATED_MODELS:()=>or,GEMINI_NANO_MAX_CONTEXT_MESSAGES:()=>Uo,GEMINI_RECOMMENDED_MODELS:()=>pt,GEMINI_VISION_SUPPORTED_MODELS:()=>He,GPT5_PRESETS:()=>Fo,GPT_5_MODELS:()=>$o,GeminiChatService:()=>fe,GeminiChatServiceProvider:()=>Me,GeminiNanoChatService:()=>ve,GeminiNanoChatServiceProvider:()=>Oe,HttpError:()=>F,KIMI_THINKING_REQUIRED_MODELS:()=>ar,KIMI_VISION_SUPPORTED_MODELS:()=>sr,KimiChatService:()=>Ee,KimiChatServiceProvider:()=>Se,MAX_TOKENS_BY_LENGTH:()=>Qt,MISTRAL_API_BASE_URL:()=>hr,MISTRAL_REASONING_EFFORT_SUPPORTED_MODELS:()=>mr,MISTRAL_SUPPORTED_MODELS:()=>bo,MISTRAL_VISION_SUPPORTED_MODELS:()=>dr,MODEL_ANTHROPIC_CLAUDE_3_5_SONNET:()=>go,MODEL_ANTHROPIC_CLAUDE_3_7_SONNET:()=>kt,MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU:()=>Gt,MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST:()=>Nt,MODEL_ANTHROPIC_CLAUDE_OPUS_4:()=>wt,MODEL_ANTHROPIC_CLAUDE_SONNET_4:()=>Vt,MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST:()=>bt,MODEL_CLAUDE_3_5_HAIKU:()=>Zr,MODEL_CLAUDE_3_5_SONNET:()=>Yr,MODEL_CLAUDE_3_7_SONNET:()=>Qr,MODEL_CLAUDE_3_HAIKU:()=>ct,MODEL_CLAUDE_4_5_HAIKU:()=>R,MODEL_CLAUDE_4_5_OPUS:()=>dt,MODEL_CLAUDE_4_5_SONNET:()=>mt,MODEL_CLAUDE_4_6_OPUS:()=>_t,MODEL_CLAUDE_4_6_SONNET:()=>gt,MODEL_CLAUDE_4_7_OPUS:()=>ft,MODEL_CLAUDE_4_8_OPUS:()=>Mt,MODEL_CLAUDE_4_OPUS:()=>ht,MODEL_CLAUDE_4_SONNET:()=>ut,MODEL_DEEPSEEK_CHAT:()=>cr,MODEL_DEEPSEEK_REASONER:()=>ur,MODEL_DEEPSEEK_V4_FLASH:()=>pe,MODEL_DEEPSEEK_V4_PRO:()=>pr,MODEL_FUGU:()=>ce,MODEL_FUGU_ULTRA:()=>_r,MODEL_FUGU_ULTRA_20260615:()=>fr,MODEL_GEMINI_2_5_FLASH:()=>Qo,MODEL_GEMINI_2_5_FLASH_LITE:()=>er,MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17:()=>tr,MODEL_GEMINI_2_5_PRO:()=>Yo,MODEL_GEMINI_3_1_FLASH_LITE:()=>j,MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW:()=>Xo,MODEL_GEMINI_3_1_PRO_PREVIEW:()=>jo,MODEL_GEMINI_3_5_FLASH:()=>lt,MODEL_GEMINI_3_FLASH_PREVIEW:()=>Zo,MODEL_GEMINI_3_PRO_PREVIEW:()=>Jo,MODEL_GEMINI_NANO:()=>Z,MODEL_GEMMA_4_26B_A4B_IT:()=>qo,MODEL_GEMMA_4_31B_IT:()=>zo,MODEL_GLM_4_6:()=>Lo,MODEL_GLM_4_6V:()=>$t,MODEL_GLM_4_6V_FLASH:()=>J,MODEL_GLM_4_6V_FLASHX:()=>zt,MODEL_GLM_4_7:()=>So,MODEL_GLM_4_7_FLASH:()=>To,MODEL_GLM_4_7_FLASHX:()=>Co,MODEL_GLM_5:()=>Oo,MODEL_GLM_5_2:()=>ie,MODEL_GLM_5_TURBO:()=>Eo,MODEL_GOOGLE_GEMINI_2_5_FLASH:()=>Ht,MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:()=>Wt,MODEL_GOOGLE_GEMINI_2_5_PRO:()=>Kt,MODEL_GOOGLE_GEMINI_FLASH_LATEST:()=>Ut,MODEL_GOOGLE_GEMINI_PRO_LATEST:()=>Ft,MODEL_GPT_4O:()=>st,MODEL_GPT_4O_MINI:()=>z,MODEL_GPT_4_1:()=>rt,MODEL_GPT_4_1_MINI:()=>it,MODEL_GPT_4_1_NANO:()=>nt,MODEL_GPT_5:()=>ee,MODEL_GPT_5_1:()=>te,MODEL_GPT_5_4:()=>H,MODEL_GPT_5_4_MINI:()=>B,MODEL_GPT_5_4_NANO:()=>$,MODEL_GPT_5_4_PRO:()=>G,MODEL_GPT_5_5:()=>W,MODEL_GPT_5_MINI:()=>Q,MODEL_GPT_5_NANO:()=>K,MODEL_GPT_OSS_20B_FREE:()=>b,MODEL_GROK_4_1_FAST_NON_REASONING:()=>N,MODEL_GROK_4_1_FAST_REASONING:()=>Xt,MODEL_GROK_4_20_NON_REASONING:()=>jt,MODEL_GROK_4_20_REASONING:()=>qt,MODEL_GROK_4_3:()=>qe,MODEL_KIMI_K2_5:()=>Zt,MODEL_KIMI_K2_6:()=>w,MODEL_KIMI_K2_7_CODE:()=>je,MODEL_KIMI_K2_7_CODE_HIGHSPEED:()=>Xe,MODEL_MISTRAL_LARGE_2512:()=>Ro,MODEL_MISTRAL_LARGE_LATEST:()=>Ao,MODEL_MISTRAL_MEDIUM_2508:()=>Do,MODEL_MISTRAL_MEDIUM_3_5:()=>Yt,MODEL_MISTRAL_SMALL_2603:()=>xo,MODEL_MISTRAL_SMALL_LATEST:()=>V,MODEL_MOONSHOTAI_KIMI_K2_5:()=>Ot,MODEL_MOONSHOTAI_KIMI_K2_7_CODE:()=>vt,MODEL_MOONSHOTAI_KIMI_LATEST:()=>Et,MODEL_O1:()=>ao,MODEL_O1_MINI:()=>so,MODEL_O3_MINI:()=>no,MODEL_OPENAI_GPT_4O:()=>Dt,MODEL_OPENAI_GPT_4_1_MINI:()=>At,MODEL_OPENAI_GPT_4_1_NANO:()=>Rt,MODEL_OPENAI_GPT_5_1_CHAT:()=>Pt,MODEL_OPENAI_GPT_5_1_CODEX:()=>yt,MODEL_OPENAI_GPT_5_5:()=>Lt,MODEL_OPENAI_GPT_5_5_PRO:()=>Tt,MODEL_OPENAI_GPT_5_MINI:()=>It,MODEL_OPENAI_GPT_5_NANO:()=>xt,MODEL_OPENAI_GPT_LATEST:()=>St,MODEL_OPENAI_GPT_MINI_LATEST:()=>Ct,MODEL_OPENROUTER_AUTO:()=>ho,MODEL_OPENROUTER_FUSION:()=>mo,MODEL_PLAMO_2_2_PRIME:()=>vr,MODEL_PLAMO_3_0_PRIME:()=>ue,MODEL_ZAI_GLM_4_5_AIR:()=>fo,MODEL_ZAI_GLM_4_5_AIR_FREE:()=>Bt,MODEL_ZAI_GLM_4_7_FLASH:()=>_o,MODEL_ZAI_GLM_5_2:()=>oe,MistralChatService:()=>Ce,MistralChatServiceProvider:()=>Te,OPENROUTER_CREDITS_THRESHOLD:()=>oi,OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS:()=>ti,OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS:()=>ei,OPENROUTER_FREE_MODELS:()=>Mo,OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE:()=>vo,OPENROUTER_VISION_SUPPORTED_MODELS:()=>rr,OpenAIChatService:()=>S,OpenAIChatServiceProvider:()=>Pe,OpenAICompatibleChatServiceProvider:()=>Le,OpenRouterChatService:()=>ye,OpenRouterChatServiceProvider:()=>Ie,PLAMO_API_BASE_URL:()=>Mr,PLAMO_SUPPORTED_MODELS:()=>ko,PlamoChatService:()=>xe,PlamoChatServiceProvider:()=>De,SAKANA_API_BASE_URL:()=>gr,SAKANA_SUPPORTED_MODELS:()=>Vo,SakanaChatService:()=>Ae,SakanaChatServiceProvider:()=>Re,StreamTextAccumulator:()=>v,VISION_SUPPORTED_MODELS:()=>Ge,XAIChatService:()=>be,XAIChatServiceProvider:()=>Ne,XAI_VISION_SUPPORTED_MODELS:()=>nr,ZAIChatService:()=>we,ZAIChatServiceProvider:()=>Ve,ZAI_VISION_SUPPORTED_MODELS:()=>ir,allowsReasoningLow:()=>at,allowsReasoningMinimal:()=>Ue,allowsReasoningNone:()=>Fe,allowsReasoningXHigh:()=>po,buildOpenAICompatibleTools:()=>x,getDefaultReasoningEffortForGPT5Model:()=>Ke,getDefaultXaiReasoningEffort:()=>yo,getMaxTokensForResponseLength:()=>E,installGASFetch:()=>Wr,isGPT5Model:()=>q,isKimiThinkingRequiredModel:()=>Je,isKimiVisionModel:()=>le,isMistralReasoningEffort:()=>No,isMistralReasoningEffortModel:()=>Qe,isMistralVisionModel:()=>wo,isOpenRouterFreeModel:()=>X,isOpenRouterVisionModel:()=>re,isResponsesOnlyGPT5Model:()=>lo,isXaiReasoningEffortModel:()=>Jt,isXaiVisionModel:()=>se,isZaiToolStreamModel:()=>Po,isZaiVisionModel:()=>ne,parseOpenAICompatibleOneShot:()=>I,parseOpenAICompatibleTextStream:()=>P,parseOpenAICompatibleToolStream:()=>y,processChatWithOptionalTools:()=>M,refreshOpenRouterFreeModels:()=>vi,resolveVisionModel:()=>O,runOnceText:()=>pi,safeJsonParse:()=>Sr,safeParseToolCallInput:()=>Y,screenplayToText:()=>li,textToScreenplay:()=>Er,textsToScreenplay:()=>ai});var U="https://api.openai.com/v1/chat/completions",A="https://api.openai.com/v1/responses",K="gpt-5-nano",Q="gpt-5-mini",ee="gpt-5",te="gpt-5.1",H="gpt-5.4",W="gpt-5.5",B="gpt-5.4-mini",$="gpt-5.4-nano",G="gpt-5.4-pro",rt="gpt-4.1",it="gpt-4.1-mini",nt="gpt-4.1-nano",z="gpt-4o-mini",st="gpt-4o",no="o3-mini",so="o1-mini",ao="o1",Ge=[K,Q,ee,te,H,W,B,$,G,rt,it,nt,z,st,"o1"],$o=[K,Q,ee,te,H,W,B,$,G];function q(r){return $o.includes(r)}function lo(r){return r===G}function po(r){return r===W||r===H||r===B||r===$||r===G}function Fe(r){return r===te||r===H||r===W||r===B||r===$}function Ue(r){return r===K||r===Q||r===ee}function at(r){return r!==G}function Ke(r){return Fe(r)?"none":Ue(r)?"minimal":"medium"}var co="https://generativelanguage.googleapis.com",zo="gemma-4-31b-it",qo="gemma-4-26b-a4b-it",lt="gemini-3.5-flash",jo="gemini-3.1-pro-preview",j="gemini-3.1-flash-lite",Xo="gemini-3.1-flash-lite-preview",Jo="gemini-3-pro-preview",Zo="gemini-3-flash-preview",Yo="gemini-2.5-pro",Qo="gemini-2.5-flash",er="gemini-2.5-flash-lite",tr="gemini-2.5-flash-lite-preview-06-17",pt=[lt,j,jo,Zo,Yo,Qo,er,zo,qo],or=[Xo,Jo,tr],He=[...pt,...or];var uo="https://api.anthropic.com/v1/messages",ct="claude-3-haiku-20240307",Zr="claude-3-5-haiku-20241022",Yr="claude-3-5-sonnet-20241022",Qr="claude-3-7-sonnet-20250219",ut="claude-sonnet-4-20250514",ht="claude-opus-4-20250514",mt="claude-sonnet-4-5-20250929",R="claude-haiku-4-5-20251001",dt="claude-opus-4-5-20251101",gt="claude-sonnet-4-6",_t="claude-opus-4-6",ft="claude-opus-4-7",Mt="claude-opus-4-8",We=[ct,ut,ht,mt,R,dt,gt,_t,ft,Mt];var Be="https://openrouter.ai/api/v1/chat/completions",ho="openrouter/auto",mo="openrouter/fusion",b="openai/gpt-oss-20b:free",vt="moonshotai/kimi-k2.7-code",Ot="moonshotai/kimi-k2.5",Et="~moonshotai/kimi-latest",St="~openai/gpt-latest",Ct="~openai/gpt-mini-latest",Tt="openai/gpt-5.5-pro",Lt="openai/gpt-5.5",Pt="openai/gpt-5.1-chat",yt="openai/gpt-5.1-codex",It="openai/gpt-5-mini",xt="openai/gpt-5-nano",Dt="openai/gpt-4o",At="openai/gpt-4.1-mini",Rt="openai/gpt-4.1-nano",bt="~anthropic/claude-sonnet-latest",Nt="~anthropic/claude-haiku-latest",wt="anthropic/claude-opus-4",Vt="anthropic/claude-sonnet-4",kt="anthropic/claude-3.7-sonnet",go="anthropic/claude-3.5-sonnet",Gt="anthropic/claude-haiku-4.5",Ft="~google/gemini-pro-latest",Ut="~google/gemini-flash-latest",Kt="google/gemini-2.5-pro",Ht="google/gemini-2.5-flash",Wt="google/gemini-2.5-flash-lite-preview-09-2025",oe="z-ai/glm-5.2",_o="z-ai/glm-4.7-flash",fo="z-ai/glm-4.5-air",Bt="z-ai/glm-4.5-air:free",Mo=[b,Bt],rr=[Et,St,Ct,Tt,Lt,Pt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,Ft,Ut,Kt,Ht,Wt,vt,Ot],vo=20,ei=50,ti=1e3,oi=10;function X(r){return r.trim().endsWith(":free")}function re(r){return rr.some(e=>r.includes(e))}var $e="https://api.z.ai/api/paas/v4/chat/completions",ie="glm-5.2",Oo="glm-5",Eo="glm-5-turbo",So="glm-4.7",Co="glm-4.7-FlashX",To="glm-4.7-Flash",Lo="glm-4.6",$t="glm-4.6V",zt="glm-4.6V-FlashX",J="glm-4.6V-Flash",ir=[$t,zt,J];function ne(r){return ir.includes(r)}function Po(r){return r.toLowerCase().startsWith("glm-4.6")}var ze="https://api.x.ai/v1/chat/completions",qe="grok-4.3",qt="grok-4.20-0309-reasoning",jt="grok-4.20-0309-non-reasoning",Xt="grok-4-1-fast-reasoning",N="grok-4-1-fast-non-reasoning",nr=[qe,qt,jt,Xt,N];function se(r){return nr.includes(r)}function Jt(r){return r===qe}function yo(r){return Jt(r)?"none":void 0}var ae="https://api.moonshot.ai/v1/chat/completions",je="kimi-k2.7-code",Xe="kimi-k2.7-code-highspeed",w="kimi-k2.6",Zt="kimi-k2.5",sr=[je,Xe,w,Zt],ar=[je,Xe];function le(r){return sr.includes(r)}function Je(r){return ar.includes(r)}var lr="https://api.deepseek.com",Ze=`${lr}/chat/completions`,pe="deepseek-v4-flash",pr="deepseek-v4-pro",cr="deepseek-chat",ur="deepseek-reasoner",Io=[pe,pr],ri=[cr,ur];var hr="https://api.mistral.ai/v1",Ye=`${hr}/chat/completions`,V="mistral-small-latest",xo="mistral-small-2603",Yt="mistral-medium-3-5",Do="mistral-medium-2508",Ao="mistral-large-latest",Ro="mistral-large-2512",bo=[V,Yt,Ao,Ro,xo,Do],mr=[V,Yt],dr=[V,xo,Yt,Do,Ao,Ro];function Qe(r){return mr.includes(r)}function No(r){return r==="none"||r==="high"}function wo(r){return dr.includes(r)}var gr="https://api.sakana.ai/v1",et=`${gr}/chat/completions`,ce="fugu",_r="fugu-ultra",fr="fugu-ultra-20260615",Vo=[ce,_r,fr];var Mr="https://api.platform.preferredai.jp/v1",tt=`${Mr}/chat/completions`,ue="plamo-3.0-prime",vr="plamo-2.2-prime",ko=[ue,vr];var T={VERY_SHORT:"veryShort",SHORT:"short",MEDIUM:"medium",LONG:"long",VERY_LONG:"veryLong",DEEP:"deep"},Qt={[T.VERY_SHORT]:40,[T.SHORT]:100,[T.MEDIUM]:200,[T.LONG]:300,[T.VERY_LONG]:1e3,[T.DEEP]:5e3},Go=5e3,Fo={casual:{reasoning_effort:"minimal",verbosity:"low",description:"Fast responses for casual chat, quick questions (GPT-4 like experience)"},balanced:{reasoning_effort:"medium",verbosity:"medium",description:"Balanced reasoning for business tasks, learning, general problem solving"},expert:{reasoning_effort:"high",verbosity:"high",description:"Deep reasoning for research, complex analysis, expert-level tasks"}};function E(r){return r?Qt[r]??Go:Go}var ii="You are a friendly AI avatar. Comment on the situation based on the broadcast screen.",ni=`You are a skilled summarizing assistant.
2
2
  Analyze the following conversation and produce a summary in the **same language** as the majority of the conversation:
3
3
  - Summaries should highlight key points
4
4
  - Stay concise (around {maxLength} characters if possible)
@@ -7,15 +7,15 @@ Analyze the following conversation and produce a summary in the **same language*
7
7
  If the conversation is in Japanese, summarize in Japanese.
8
8
  If it's in English, summarize in English.
9
9
  If it's in another language, summarize in that language.
10
- `;var Z="gemini-nano",Go=20;var F=class extends Error{constructor(t,o,i){super(`HTTP ${t}: ${o}`);this.status=t;this.statusText=o;this.body=i;this.name="HttpError"}},tt=class tt{static setFetch(e){this.fetchImpl=e}static async post(e,t,o={},i={}){let{timeout:n=3e4,retries:s=0,retryDelay:a=1e3}=i,c={...{"Content-Type":"application/json"},...o},d=null;for(let u=0;u<=s;u++)try{let m=typeof AbortController<"u",p=m?new AbortController:void 0,h=m?setTimeout(()=>p.abort(),n):void 0,g=await tt.fetchImpl(e,{method:"POST",headers:c,body:typeof t=="string"?t:JSON.stringify(t),...p?{signal:p.signal}:{}});if(h&&clearTimeout(h),!g.ok){let C=await g.text();throw new F(g.status,g.statusText,C)}return g}catch(m){if(d=m,m instanceof F&&m.status>=400&&m.status<500)throw m;if(m instanceof Error&&m.name==="AbortError")throw new Error(`Request timeout after ${n}ms`);u<s&&await new Promise(p=>setTimeout(p,a*(u+1)))}throw d||new Error("Request failed")}static async handleErrorResponse(e){let t=await e.text();throw new F(e.status,e.statusText,t)}static async get(e,t={},o={}){let{timeout:i=3e4,retries:n=0,retryDelay:s=1e3}=o,a=null;for(let l=0;l<=n;l++)try{let c=typeof AbortController<"u",d=c?new AbortController:void 0,u=c?setTimeout(()=>d.abort(),i):void 0,m=await tt.fetchImpl(e,{method:"GET",headers:t,...d?{signal:d.signal}:{}});if(u&&clearTimeout(u),!m.ok){let p=await m.text();throw new F(m.status,m.statusText,p)}return m}catch(c){if(a=c,c instanceof F&&c.status>=400&&c.status<500)throw c;if(c instanceof Error&&c.name==="AbortError")throw new Error(`Request timeout after ${i}ms`);l<n&&await new Promise(d=>setTimeout(d,s*(l+1)))}throw a||new Error("Request failed")}};tt.fetchImpl=(e,t)=>fetch(e,t);var f=tt;var v=class{static append(e,t){if(!t)return;let o=e[e.length-1];o&&o.type==="text"?o.text+=t:e.push({type:"text",text:t})}static getFullText(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}static addTextBlock(e,t){t&&e.push({type:"text",text:t})}};var ii=["happy","sad","angry","surprised","neutral"],Mr=/\[([a-z]+)\]/i,Fo=/\[[a-z]+\]\s*/gi,he=class{static extractEmotion(e){let t=e.match(Mr);if(t){let o=t[1].toLowerCase(),i=e.replace(Fo,"").trim();return{emotion:o,cleanText:i}}return{cleanText:e}}static isValidEmotion(e){return ii.includes(e)}static cleanEmotionTags(e){return e.replace(Fo,"").trim()}static addEmotionTag(e,t){return`[${e}] ${t}`}};function vr(r){let{emotion:e,cleanText:t}=he.extractEmotion(r);return e?{emotion:e,text:t}:{text:t}}function ni(r){return r.map(e=>vr(e))}function si(r){return r.emotion?he.addEmotionTag(r.emotion,r.text):r.text}async function ai(r,e){let{blocks:t}=await r.chatOnce(e,!1,()=>{});return v.getFullText(t)}var Or=(r,e,t)=>{try{return JSON.parse(r)}catch(o){return t?.(r,o),e}},Y=(r,e)=>r?Or(r,{},e):{};var Er=(r,e)=>{try{return JSON.parse(r)}catch(t){if(e){e(r,t);return}throw t}},Uo=r=>typeof r=="string"?r:Array.isArray(r)?r.map(e=>typeof e=="string"?e:e&&typeof e=="object"&&e.type==="text"&&typeof e.text=="string"?e.text:"").join(""):"",Sr=async(r,e)=>{let t=r.body?.getReader();if(!t)throw new Error("Response body is null.");let o=new TextDecoder,i="",n=!1;for(;!n;){let{done:s,value:a}=await t.read();if(s)break;i+=o.decode(a,{stream:!0});let l=i.split(`
11
- `);i=l.pop()||"";for(let c of l){let d=c.trim();if(!d||d.startsWith(":")||!d.startsWith("data:"))continue;let u=d.slice(5).trim();if(u==="[DONE]"){n=!0;break}e(u)}}};async function P(r,e,t={}){let o="";return await Sr(r,i=>{let n=Er(i,t.onJsonError);if(!n)return;let s=Uo(n.choices?.[0]?.delta?.content);s&&(e(s),o+=s)}),o}async function y(r,e,t={}){let o=[],i=new Map,n,s,a=t.appendTextBlock??v.append;await Sr(r,d=>{let u=Er(d,t.onJsonError);if(!u)return;let m=u.choices?.[0];typeof m?.finish_reason=="string"&&(n=m.finish_reason),u.usage&&(s=u.usage);let p=m?.delta,h=Uo(p?.content);h&&(e(h),a(o,h)),p?.tool_calls&&p.tool_calls.forEach(g=>{let C=i.get(g.index)??{id:g.id,name:g.function?.name,args:""};C.args+=g.function?.arguments||"",i.set(g.index,C)})});let l=Array.from(i.entries()).sort((d,u)=>d[0]-u[0]).map(([d,u])=>({type:"tool_use",id:u.id,name:u.name,input:Y(u.args,t.onJsonError)}));return{blocks:[...o,...l],stop_reason:l.length?"tool_use":"end",truncated:n==="length",finish_reason:n,usage:s}}function I(r,e={}){let t=r?.choices?.[0],o=[];if(t?.message?.tool_calls?.length)t.message.tool_calls.forEach(i=>o.push({type:"tool_use",id:i.id,name:i.function?.name,input:Y(i.function?.arguments,e.onJsonError)}));else{let i=Uo(t?.message?.content);i&&o.push({type:"text",text:i})}return{blocks:o,stop_reason:t?.finish_reason==="tool_calls"||o.some(i=>i.type==="tool_use")?"tool_use":"end",truncated:t?.finish_reason==="length",finish_reason:t?.finish_reason,usage:r?.usage}}var x=(r,e="chat-completions")=>r.length===0?[]:e==="responses"?r.map(t=>({type:"function",name:t.name,description:t.description,parameters:t.parameters})):r.map(t=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters}}));async function M(r){if(!r.hasTools){let t=await r.runWithoutTools();await r.onCompleteResponse(t);return}let e=await r.runWithTools();if(r.onToolBlocks&&r.onToolBlocks(e.blocks),e.stop_reason==="end"){let t=v.getFullText(e.blocks);await r.onCompleteResponse(t);return}throw new Error(r.toolErrorMessage)}var O=r=>{let e=r.model??r.defaultModel,t=r.visionModel??(r.supportsVisionForModel(e)?e:r.defaultVisionModel);if(r.validate==="explicit"&&r.visionModel&&!r.supportsVisionForModel(r.visionModel))throw new Error(`Model ${r.visionModel} does not support vision capabilities.`);if(r.validate==="resolved"&&!r.supportsVisionForModel(t))throw new Error(`Model ${t} does not support vision capabilities.`);return t};var li="https://openrouter.ai/api/v1/models",pi=2,ci=12e3,ui=1,hi=10;function Ko(r){return r instanceof Error?r.message:String(r)}function Qt(r,e){return typeof r!="number"||!Number.isFinite(r)?e:Math.max(1,Math.floor(r))}function mi(r){let e=new Set,t=[];for(let o of r){let i=o.trim();!i||e.has(i)||(e.add(i),t.push(i))}return t}async function Cr(r,e,t){if(!(typeof AbortController<"u"))return fetch(r,e);let i=new AbortController,n=setTimeout(()=>i.abort(),t);try{return await fetch(r,{...e,signal:i.signal})}catch(s){throw s instanceof Error&&s.name==="AbortError"?new Error(`Timeout after ${t}ms`):s}finally{clearTimeout(n)}}async function Tr(r){let e=`HTTP ${r.status} ${r.statusText}`.trim(),t="";try{t=await r.text()}catch{return e}let o=t.replace(/\s+/g," ").trim().slice(0,200);return o?`${e}: ${o}`:e}function di(r){if(!r||typeof r!="object")throw new Error("Invalid models response shape");let e=r,t=Array.isArray(e.data)?e.data:Array.isArray(e.models)?e.models:[];if(t.length===0)return[];let o=t.map(i=>i.id).filter(i=>typeof i=="string");return mi(o)}async function gi({modelId:r,apiKey:e,endpoint:t,timeoutMs:o,appName:i,appUrl:n}){let s={Authorization:`Bearer ${e}`,"Content-Type":"application/json"};i&&(s["X-Title"]=i),n&&(s["HTTP-Referer"]=n);try{let a=await Cr(t,{method:"POST",headers:s,body:JSON.stringify({model:r,messages:[{role:"user",content:"Reply only with OK."}],stream:!1})},o);if(!a.ok)return{id:r,ok:!1,reason:await Tr(a)};try{await a.json()}catch(l){return{id:r,ok:!1,reason:`JSON parse failed: ${Ko(l)}`}}return{id:r,ok:!0}}catch(a){return{id:r,ok:!1,reason:Ko(a)}}}async function _i(r,e,t){if(r.length===0)return[];let o=new Array(r.length),i=0,n=Math.min(e,r.length);return await Promise.all(Array.from({length:n},async()=>{for(;i<r.length;){let s=i;i+=1,o[s]=await t(r[s])}})),o}async function fi(r){let e=r.apiKey.trim();if(!e)throw new Error("OpenRouter API key is required.");let t=r.modelsEndpoint||li,o=r.endpoint||Be,i=Qt(r.timeoutMs,ci),n=Qt(r.concurrency,pi),s=Qt(r.maxCandidates,ui),a=Qt(r.maxWorking,hi),l=await Cr(t,{method:"GET"},i);if(!l.ok)throw new Error(await Tr(l));let c;try{c=await l.json()}catch(h){throw new Error(`JSON parse failed: ${Ko(h)}`)}let d=di(c).filter(h=>J(h)).slice(0,s),u=await _i(d,n,h=>gi({modelId:h,apiKey:e,endpoint:o,timeoutMs:i,appName:r.appName,appUrl:r.appUrl})),m=u.filter(h=>h.ok).map(h=>h.id).slice(0,a),p=u.filter(h=>!h.ok).map(h=>({id:h.id,reason:h.reason||"Unknown error"}));return{working:m,failed:p,fetchedAt:Date.now()}}function Lr(r){return r.map(e=>({role:eo(e.role),content:e.content}))}function Pr(r){return r.map(e=>{if(typeof e.content=="string")return{role:eo(e.role),content:[{type:"text",text:e.content}]};if(Array.isArray(e.content)){let t=e.content.map(o=>{if(o.type==="image_url"){if(o.image_url.url.startsWith("data:")){let i=o.image_url.url.match(/^data:([^;]+);base64,(.+)$/);return i?{type:"image",source:{type:"base64",media_type:i[1],data:i[2]}}:null}return{type:"image",source:{type:"url",url:o.image_url.url,media_type:Mi(o.image_url.url)}}}return o}).filter(o=>o);return{role:eo(e.role),content:t}}return{role:eo(e.role),content:[]}})}function eo(r){switch(r){case"system":return"system";case"user":return"user";case"assistant":return"assistant";default:return"user"}}function Mi(r){switch(r.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";case"webp":return"image/webp";default:return"image/jpeg"}}var me=class{constructor(e,t=R,o=R,i=[],n=[],s){this.provider="claude";if(this.apiKey=e,this.model=t||R,this.visionModel=o||R,this.tools=i,this.mcpServers=n,this.responseLength=s,!We.includes(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`)}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e)}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e)}hasMCPServers(){return this.mcpServers.length>0}async processChat(e,t,o){await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callClaude(e,this.model,!0);return this.parsePureStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callClaude(e,this.visionModel,!0);return this.parsePureStream(i,t)},runWithTools:()=>this.visionChatOnce(e),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async callClaude(e,t,o,i){let n=e.find(u=>u.role==="system")?.content??"",s=e.filter(u=>u.role!=="system"),a=s.some(u=>Array.isArray(u.content)&&u.content.some(m=>m.type==="image_url"||m.type==="image")),l={model:t,system:n,messages:a?Pr(s):Lr(s),stream:o,max_tokens:i!==void 0?i:E(this.responseLength)};this.tools.length&&(l.tools=this.tools.map(u=>({name:u.name,description:u.description,input_schema:u.parameters})),l.tool_choice={type:"auto"}),this.mcpServers.length>0&&(l.mcp_servers=this.mcpServers);let c={"Content-Type":"application/json","x-api-key":this.apiKey,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"};return this.mcpServers.length>0&&(c["anthropic-beta"]="mcp-client-2025-04-04"),await f.post(co,l,c)}async parseStream(e,t){let o=e.body.getReader(),i=new TextDecoder,n=[],s=new Map,a="";for(;;){let{done:l,value:c}=await o.read();if(l)break;a+=i.decode(c,{stream:!0});let d;for(;(d=a.indexOf(`
12
- `))!==-1;){let u=a.slice(0,d).trim();if(a=a.slice(d+1),!u.startsWith("data:"))continue;let m=u.slice(5).trim();if(m==="[DONE]")break;let p=JSON.parse(m);if(p.type==="content_block_delta"&&p.delta?.text&&(t(p.delta.text),n.push({type:"text",text:p.delta.text})),p.type==="content_block_start"&&p.content_block?.type==="tool_use"?s.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_use"?s.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:"",server_name:p.content_block.server_name}):p.type==="content_block_start"&&p.content_block?.type==="tool_result"?n.push({type:"tool_result",tool_use_id:p.content_block.tool_use_id,content:p.content_block.content??""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_result"&&n.push({type:"mcp_tool_result",tool_use_id:p.content_block.tool_use_id,is_error:p.content_block.is_error??!1,content:p.content_block.content??[]}),p.type==="content_block_delta"&&p.delta?.type==="input_json_delta"){let h=s.get(p.index);h&&(h.args+=p.delta.partial_json||"")}if(p.type==="content_block_stop"&&s.has(p.index)){let{id:h,name:g,args:C,server_name:k}=s.get(p.index);k?n.push({type:"mcp_tool_use",id:h,name:g,server_name:k,input:JSON.parse(C||"{}")}):n.push({type:"tool_use",id:h,name:g,input:JSON.parse(C||"{}")}),s.delete(p.index)}}}return{blocks:n,stop_reason:n.some(l=>l.type==="tool_use"||l.type==="mcp_tool_use")?"tool_use":"end"}}async parsePureStream(e,t){let{blocks:o}=await this.parseStream(e,t);return o.filter(i=>i.type==="text").map(i=>i.text).join("")}parseOneShot(e){let t=[];return(e.content??[]).forEach(o=>{o.type==="text"?t.push({type:"text",text:o.text}):o.type==="tool_use"?t.push({type:"tool_use",id:o.id,name:o.name,input:o.input??{}}):o.type==="mcp_tool_use"?t.push({type:"mcp_tool_use",id:o.id,name:o.name,server_name:o.server_name,input:o.input??{}}):o.type==="tool_result"?t.push({type:"tool_result",tool_use_id:o.tool_use_id,content:o.content??""}):o.type==="mcp_tool_result"&&t.push({type:"mcp_tool_result",tool_use_id:o.tool_use_id,is_error:o.is_error??!1,content:o.content??[]})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use"||o.type==="mcp_tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callClaude(e,this.model,t,i),s=t?await this.parseStream(n,o):this.parseOneShot(await n.json());return this.convertToStandardCompletion(s)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callClaude(e,this.visionModel,t,i),s=t?await this.parseStream(n,o):this.parseOneShot(await n.json());return this.convertToStandardCompletion(s)}convertToStandardCompletion(e){return{blocks:e.blocks.filter(o=>o.type==="text"||o.type==="tool_use"||o.type==="tool_result"),stop_reason:e.stop_reason}}};var de=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new me(e.apiKey,e.model||this.getDefaultModel(),t,e.tools??[],e.mcpServers??[],e.responseLength)}getProviderName(){return"claude"}getSupportedModels(){return[ct,ut,ht,R,mt,dt,gt,_t,ft,pt]}getDefaultModel(){return R}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return We.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};async function to(r,e,t={}){let o=r.body.getReader(),i=new TextDecoder,n=[],s=new Map,a,l,c,d="";for(;;){let{done:m,value:p}=await o.read();if(m)break;d+=i.decode(p,{stream:!0});let h="",g="",C=d.split(`
13
- `);d=C.pop()||"";for(let k=0;k<C.length;k++){let _=C[k].trim();if(_.startsWith("event:"))h=_.slice(6).trim();else if(_.startsWith("data:"))g=_.slice(5).trim();else if(_===""&&h&&g){try{let D=JSON.parse(g);vi(h,D,e,n,s,t,L=>{L.responseStatus!==void 0&&(a=L.responseStatus),L.incompleteDetails!==void 0&&(l=L.incompleteDetails),L.usage!==void 0&&(c=L.usage)})}catch(D){t.onJsonError?.(g,D),console.warn("Failed to parse SSE data:",g)}h="",g=""}}}let u=Array.from(s.values()).map(m=>({type:"tool_use",id:m.id,name:m.name,input:m.input||{}}));return{blocks:[...n,...u],stop_reason:u.length?"tool_use":"end",truncated:a==="incomplete",response_status:a,incomplete_details:l,usage:c}}function vi(r,e,t,o,i,n,s){switch(r){case"response.output_item.added":e.item?.type==="message"&&Array.isArray(e.item.content)?e.item.content.forEach(a=>{a.type==="output_text"&&a.text&&(t(a.text),v.append(o,a.text))}):e.item?.type==="function_call"&&i.set(e.item.id,{id:e.item.id,name:e.item.name,input:Y(e.item.arguments,n.onJsonError)});break;case"response.content_part.added":e.part?.type==="output_text"&&typeof e.part.text=="string"&&(t(e.part.text),v.append(o,e.part.text));break;case"response.output_text.delta":case"response.content_part.delta":{let a=typeof e.delta=="string"?e.delta:e.delta?.text??"";a&&(t(a),v.append(o,a));break}case"response.output_text.done":case"response.content_part.done":case"response.reasoning.started":case"response.reasoning.delta":case"response.reasoning.done":break;case"response.completed":s(yr(e,"completed"));break;case"response.incomplete":s(yr(e,"incomplete"));break;default:break}}function yr(r,e){let t=r?.response??r;return{responseStatus:t?.status??e,incompleteDetails:t?.incomplete_details??null,usage:t?.usage}}function Ir(r,e={}){let t=[];return r.output&&Array.isArray(r.output)&&r.output.forEach(o=>{o.type==="message"&&o.content&&o.content.forEach(i=>{i.type==="output_text"&&i.text&&t.push({type:"text",text:i.text})}),o.type==="function_call"&&t.push({type:"tool_use",id:o.id,name:o.name,input:Y(o.arguments,e.onJsonError)})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use")?"tool_use":"end",truncated:r?.status==="incomplete",response_status:r?.status,incomplete_details:r?.incomplete_details??null,usage:r?.usage}}function xr({tools:r,mcpServers:e,isResponsesAPI:t}){let o=[];return r.length>0&&o.push(...x(r,t?"responses":"chat-completions")),e.length>0&&t&&o.push(...Oi(e)),o}function Oi(r){return r.map(e=>{let t={type:"mcp",server_label:e.name,server_url:e.url};return e.require_approval&&(t.require_approval=e.require_approval),e.tool_configuration?.allowed_tools&&(t.allowed_tools=e.tool_configuration.allowed_tools),e.authorization_token&&(t.headers={Authorization:`Bearer ${e.authorization_token}`}),t})}var Ei={[T.VERY_SHORT]:800,[T.SHORT]:1200,[T.MEDIUM]:2e3,[T.LONG]:3e3,[T.VERY_LONG]:8e3,[T.DEEP]:25e3},Si={none:1200,minimal:1600,low:2500,medium:4e3,high:8e3,xhigh:12e3},Ci=new Set(["openai-compatible","deepseek","mistral","sakana","plamo"]);function Dr({provider:r,endpoint:e,messages:t,model:o,stream:i,tools:n,mcpServers:s,responseLength:a,verbosity:l,reasoning_effort:c,enableReasoningSummary:d,maxTokens:u}){let m=e===A;Li(e,s);let p={model:o,stream:i},h=Ti({provider:r,model:o,responseLength:a,reasoning_effort:c,maxTokens:u});m?h!==void 0&&(p.max_output_tokens=h):h!==void 0&&(Ar(r)?p.max_tokens=h:p.max_completion_tokens=h),m?p.input=Pi(t):p.messages=r==="mistral"?yi(t):t,q(o)&&(m?(c&&(p.reasoning={...p.reasoning,effort:c},d&&(p.reasoning.summary="auto")),l&&(p.text={...p.text,format:{type:"text"},verbosity:l})):(c&&(p.reasoning_effort=c),l&&(p.verbosity=l))),r==="mistral"&&Ye(o)&&c&&Ro(c)&&(p.reasoning_effort=c),r==="plamo"&&c&&(p.reasoning_effort=c);let g=xr({tools:n,mcpServers:s,isResponsesAPI:m});return g.length>0&&(p.tools=g,m||(p.tool_choice="auto")),p}function Ti({provider:r,model:e,responseLength:t,reasoning_effort:o,maxTokens:i}){if(i!==void 0)return i;let n=Ar(r)?t!==void 0?E(t):void 0:E(t);if(r!=="openai"||!q(e)||t===void 0)return n;let s=o??Ke(e);return Math.max(n??0,Ei[t],Si[s])}function Li(r,e){if(e.length>0&&r===U)throw new Error(`MCP servers are not supported with Chat Completions API. Current endpoint: ${r}. Please use OpenAI Responses API endpoint: ${A}. MCP tools are only available in the Responses API endpoint.`)}function Pi(r){return r.map(e=>{let o={role:e.role==="tool"?"user":e.role};return typeof e.content=="string"?o.content=e.content:Array.isArray(e.content)?o.content=e.content.map(i=>i.type==="text"?{type:"input_text",text:i.text}:i.type==="image_url"?{type:"input_image",image_url:i.image_url.url}:i):o.content=e.content,o})}function yi(r){return r.map(e=>{let t={role:e.role};return Array.isArray(e.content)?(t.content=e.content.map(o=>o.type==="image_url"&&typeof o.image_url=="object"&&typeof o.image_url?.url=="string"?{type:"image_url",image_url:o.image_url.url}:o),t):(t.content=e.content,t)})}function Ar(r){return Ci.has(r)}var S=class{constructor(e,t=z,o=z,i,n=U,s=[],a,l,c,d=!1,u="openai",m=!0){if(this.provider=u,this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.mcpServers=s,this.responseLength=a,this.verbosity=l,this.reasoning_effort=c,this.enableReasoningSummary=d,m&&!Ge.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenAI(e,this.model,!0),n=this.endpoint===A;try{if(n){let s=await to(i,t);return v.getFullText(s.blocks)}return this.handleStream(i,t)}catch(s){throw console.error("[processChat] Error in streaming/completion:",s),s}},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){try{await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenAI(e,this.visionModel,!0),n=this.endpoint===A;try{if(n){let s=await to(i,t);return v.getFullText(s.blocks)}return this.handleStream(i,t)}catch(s){throw console.error("[processVisionChat] Error in streaming/completion:",s),s}},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callOpenAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callOpenAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return this.endpoint===A?t?to(e,o):Ir(await e.json()):t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callOpenAI(e,t,o=!1,i){let n=Dr({provider:this.provider,endpoint:this.endpoint,messages:e,model:t,stream:o,tools:this.tools,mcpServers:this.mcpServers,responseLength:this.responseLength,verbosity:this.verbosity,reasoning_effort:this.reasoning_effort,enableReasoningSummary:this.enableReasoningSummary,maxTokens:i}),s={};return(this.provider!=="openai-compatible"||this.apiKey.trim()!=="")&&(s.Authorization=`Bearer ${this.apiKey}`),await f.post(this.endpoint,n,s)}async handleStream(e,t){return P(e,t)}async parseStream(e,t){return y(e,t,{appendTextBlock:v.addTextBlock})}parseOneShot(e){return I(e)}};var ge=class extends S{constructor(e,t=pe,o=t,i,n=Xe,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"deepseek",!1)}};var _e=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new ge(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"deepseek"}getSupportedModels(){return[...Po]}getDefaultModel(){return pe}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("deepseek provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return Xe}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Rr=(r,e)=>({name:`mcp_${r.name}_search`,description:e==="schema-fetch-failed"?`Search using ${r.name} MCP server (schema fetch failed)`:`Search using ${r.name} MCP server`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}),oo=class{static async fetchToolSchemas(e){return(await this.fetchToolSchemasWithStatus(e)).schemas}static async fetchToolSchemasWithStatus(e){try{let t={"Content-Type":"application/json"};e.authorization_token&&(t.Authorization=`Bearer ${e.authorization_token}`);let i=await(await f.post(`${e.url}/tools`,{},t)).json();return Array.isArray(i.tools)?{schemas:i.tools.map(n=>({name:`mcp_${e.name}_${n.name}`,description:n.description||`Tool from ${e.name} MCP server`,parameters:n.inputSchema||{type:"object",properties:{},required:[]}})),failures:[]}:{schemas:[Rr(e)],failures:[]}}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),{schemas:[Rr(e,"schema-fetch-failed")],failures:[{server:e,error:t}]}}}static async fetchAllToolSchemas(e){return(await this.fetchAllToolSchemasWithStatus(e)).schemas}static async fetchAllToolSchemasWithStatus(e){let t=[],o=[];for(let i of e)try{let n=await this.fetchToolSchemasWithStatus(i);t.push(...n.schemas),o.push(...n.failures)}catch(n){console.error(`Failed to fetch schemas from ${i.name}:`,n),o.push({server:i,error:n})}return{schemas:t,failures:o}}};function br(r){switch(r){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}function Nr(r,e={}){let t=[],o=null,i=[],n=()=>{o&&i.length&&(t.push({role:o,parts:[...i]}),i=[])};for(let s of r){let a=br(s.role);if(s.tool_calls){n();for(let l of s.tool_calls)e.callIdMap?.set(l.id,l.function.name),t.push({role:"model",parts:[{functionCall:{name:l.function.name,args:JSON.parse(l.function.arguments||"{}")}}]});continue}if(s.role==="tool"){n();let l=s.name??e.callIdMap?.get(s.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:l,response:kr(Vr(s.content))}}]});continue}a!==o&&n(),o=a,i.push({text:s.content})}return n(),t}async function wr(r,e={}){let t=e.imageFetcher??f.get,o=e.blobToBase64??Ii,i=[],n=null,s=[];for(let a of r){let l=br(a.role);if(a.tool_calls){for(let c of a.tool_calls)i.push({role:"model",parts:[{functionCall:{name:c.function.name,args:JSON.parse(c.function.arguments||"{}")}}]});continue}if(a.role==="tool"){let c=a.name??e.callIdMap?.get(a.tool_call_id)??"result";i.push({role:"user",parts:[{functionResponse:{name:c,response:kr(Vr(a.content))}}]});continue}if(l!==n&&s.length>0&&(i.push({role:n,parts:[...s]}),s=[]),n=l,typeof a.content=="string")s.push({text:a.content});else if(Array.isArray(a.content)){for(let c of a.content)if(c.type==="text")s.push({text:c.text});else if(c.type==="image_url")try{let u=await(await t(c.image_url.url)).blob(),m=await o(u);s.push({inlineData:{mimeType:u.type||"image/jpeg",data:m.split(",")[1]}})}catch(d){throw console.error("Error processing image:",d),new Error(`Failed to process image: ${d.message}`)}}}return n&&s.length>0&&i.push({role:n,parts:[...s]}),i}function Vr(r){try{return JSON.parse(r)}catch{return r}}function kr(r){return r===null?{content:null}:typeof r=="object"?r:{content:r}}function Ii(r){return new Promise((e,t)=>{let o=new FileReader;o.onloadend=()=>e(o.result),o.onerror=t,o.readAsDataURL(r)})}function xi(r,e){return[...r,...e].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}function Gr(r,e){let t=xi(r,e);if(t.length!==0)return{tools:[{functionDeclarations:t}],toolConfig:{functionCallingConfig:{mode:"AUTO"}}}}function Fr(r){return r.map(e=>({name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server (fallback)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}))}var fe=class{constructor(e,t=j,o=j,i=[],n=[],s){this.provider="gemini";this.mcpToolSchemas=[];this.mcpSchemasInitialized=!1;this.callIdMap=new Map;if(this.apiKey=e,this.model=t,this.responseLength=s,!He.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o,this.tools=i,this.mcpServers=n}isGemma4Model(e){return/^gemma-4-/.test(e)}shouldMinimizeThinking(e){return e===at||this.isGemma4Model(e)}shouldExposeTextPart(e,t){return!(!e.text||this.isGemma4Model(t)&&e.thought===!0)}adaptKeysForApi(e){let t={toolConfig:"tool_config",functionCallingConfig:"function_calling_config",functionDeclarations:"function_declarations",functionCall:"function_call",functionResponse:"function_response"};return Array.isArray(e)?e.map(o=>this.adaptKeysForApi(o)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,i])=>[t[o]??o,this.adaptKeysForApi(i)])):e}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e),this.mcpSchemasInitialized=!1,this.mcpSchemaInitializationError=void 0}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e),this.mcpSchemasInitialized=!1,this.mcpSchemaInitializationError=void 0}hasMCPServers(){return this.mcpServers.length>0}getMCPSchemaInitializationError(){return this.mcpSchemaInitializationError}async initializeMCPSchemas(){if(!(this.mcpSchemasInitialized||this.mcpServers.length===0))try{let e=new Promise((i,n)=>setTimeout(()=>n(new Error("MCP schema fetch timeout")),5e3)),t=oo.fetchAllToolSchemasWithStatus(this.mcpServers),o=await Promise.race([t,e]);this.mcpToolSchemas=o.schemas,this.mcpSchemasInitialized=!0,this.mcpSchemaInitializationError=o.failures[0]?.error}catch(e){console.warn("Failed to initialize MCP schemas, using fallback:",e),this.mcpSchemaInitializationError=e,this.mcpToolSchemas=Fr(this.mcpServers),this.mcpSchemasInitialized=!0}}async processChat(e,t,o){try{await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callGemini(e,this.model,!0),{blocks:n}=await this.parseStream(i,t,this.model);return v.getFullText(n)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use chatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processChat:",i),i}}async processVisionChat(e,t,o){try{await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callGemini(e,this.visionModel,!0),{blocks:n}=await this.parseStream(i,t,this.visionModel);return v.getFullText(n)},runWithTools:()=>this.visionChatOnce(e),onToolBlocks:i=>{i.filter(n=>n.type==="text").forEach(n=>t(n.text))},onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async callGemini(e,t,o=!1,i){let a={contents:e.some(_=>Array.isArray(_.content)&&_.content.some(D=>D?.type==="image_url"||D?.inlineData))?await wr(e,{callIdMap:this.callIdMap}):Nr(e,{callIdMap:this.callIdMap}),generationConfig:{maxOutputTokens:i!==void 0?i:E(this.responseLength)}};this.shouldMinimizeThinking(t)&&(a.generationConfig.thinkingConfig={includeThoughts:!1,thinkingLevel:"MINIMAL"});let l=[];if(this.mcpServers.length>0)try{await this.initializeMCPSchemas(),l=this.mcpToolSchemas}catch(_){console.warn("MCP initialization failed, skipping MCP tools:",_)}let c=Gr(this.tools,l);c&&Object.assign(a,c);let d=async(_,D)=>{let L=o?"streamGenerateContent":"generateContent",Ho=o?"?alt=sse":"",Hr=`${po}/${_}/models/${t}:${L}${Ho}${Ho?"&":"?"}key=${this.apiKey}`;return f.post(Hr,D)},u=/flash[-_]lite/.test(t),m=this.isGemma4Model(t),p=/gemini-2\.5/.test(t),h=/^gemini-3(?:\.[0-9]+)?-/.test(t),g=u||m||p||h,C=g?"v1beta":"v1",k=async()=>{try{let _=C==="v1"?a:this.adaptKeysForApi(a);return await d(C,_)}catch(_){let D=/Unknown name|Cannot find field|404/.test(_?.message||"")||_?.status===404;if(!g&&D)try{return await d("v1beta",this.adaptKeysForApi(a))}catch(L){throw L instanceof Error&&(L.cause=_),L}throw _}};try{return await k()}catch(_){throw _.body&&(console.error("Gemini API Error Details:",_.body),console.error("Request Body:",JSON.stringify(a,null,2))),_}}async parseStream(e,t,o){let i=e.body.getReader(),n=new TextDecoder,s=[],a=[],l="",c=u=>{if(!u||u==="[DONE]")return;let m;try{m=JSON.parse(u)}catch{return}for(let p of m.candidates??[])for(let h of p.content?.parts??[])this.shouldExposeTextPart(h,o)&&(t(h.text),v.addTextBlock(s,h.text)),h.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:h.functionCall.name,input:h.functionCall.args??{}}),h.functionResponse&&a.push({type:"tool_result",tool_use_id:h.functionResponse.name,content:JSON.stringify(h.functionResponse.response)})};for(;;){let{done:u,value:m}=await i.read();if(u)break;l+=n.decode(m,{stream:!0});let p;for(;(p=l.indexOf(`
14
- `))!==-1;){let h=l.slice(0,p);if(l=l.slice(p+1),h.endsWith("\r")&&(h=h.slice(0,-1)),!h.trim()){c("");continue}h.startsWith("data:")&&(h=h.slice(5).trim()),h&&c(h)}}return l&&c(l),{blocks:[...s,...a],stop_reason:a.some(u=>u.type==="tool_use")?"tool_use":"end"}}parseOneShot(e,t){let o=[],i=[];for(let s of e.candidates??[])for(let a of s.content?.parts??[])this.shouldExposeTextPart(a,t)&&o.push({type:"text",text:a.text}),a.functionCall&&i.push({type:"tool_use",id:this.genUUID(),name:a.functionCall.name,input:a.functionCall.args??{}}),a.functionResponse&&i.push({type:"tool_result",tool_use_id:a.functionResponse.name,content:JSON.stringify(a.functionResponse.response)});return{blocks:[...o,...i],stop_reason:i.some(s=>s.type==="tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callGemini(e,this.model,t,i);return t?this.parseStream(n,o,this.model):this.parseOneShot(await n.json(),this.model)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callGemini(e,this.visionModel,t,i);return t?this.parseStream(n,o,this.visionModel):this.parseOneShot(await n.json(),this.visionModel)}genUUID(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}};var Me=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new fe(e.apiKey,e.model||this.getDefaultModel(),t,e.tools||[],e.mcpServers||[],e.responseLength)}getProviderName(){return"gemini"}getSupportedModels(){return[...lt]}getDefaultModel(){return j}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return He.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};function Di(){if(typeof globalThis<"u"&&"LanguageModel"in globalThis)return globalThis.LanguageModel}var ve=class{constructor(e={}){this.provider="gemini-nano";this.expectedInputLanguages=e.expectedInputLanguages??["ja"],this.expectedOutputLanguages=e.expectedOutputLanguages??["ja"],this._responseLength=e.responseLength}getModel(){return Z}getVisionModel(){return Z}async processChat(e,t,o){let i=await this.generateResponse(e);t(i),await o(i)}async processVisionChat(e,t,o){throw new Error("Gemini Nano does not support vision capabilities.")}async chatOnce(e,t=!1,o=()=>{},i){let n=await this.generateResponse(e);return o(n),{blocks:[{type:"text",text:n}],stop_reason:"end"}}async visionChatOnce(e,t=!1,o=()=>{},i){throw new Error("Gemini Nano does not support vision capabilities.")}async generateResponse(e){let t=Di();if(!t)throw new Error("Gemini Nano is not available in this environment. Chrome 138+ with Prompt API enabled is required.");let o=await t.availability();if(o!=="available"&&o!=="downloadable")throw new Error(`Gemini Nano Prompt API is not ready in this environment. LanguageModel.availability() returned "${o}". Expected "available" or "downloadable".`);let n=e.filter(c=>c.role==="system").map(c=>c.content).join(`
10
+ `;var Z="gemini-nano",Uo=20;var F=class extends Error{constructor(t,o,i){super(`HTTP ${t}: ${o}`);this.status=t;this.statusText=o;this.body=i;this.name="HttpError"}},ot=class ot{static setFetch(e){this.fetchImpl=e}static async post(e,t,o={},i={}){let{timeout:n=3e4,retries:s=0,retryDelay:a=1e3}=i,c={...{"Content-Type":"application/json"},...o},d=null;for(let u=0;u<=s;u++)try{let m=typeof AbortController<"u",p=m?new AbortController:void 0,h=m?setTimeout(()=>p.abort(),n):void 0,g=await ot.fetchImpl(e,{method:"POST",headers:c,body:typeof t=="string"?t:JSON.stringify(t),...p?{signal:p.signal}:{}});if(h&&clearTimeout(h),!g.ok){let C=await g.text();throw new F(g.status,g.statusText,C)}return g}catch(m){if(d=m,m instanceof F&&m.status>=400&&m.status<500)throw m;if(m instanceof Error&&m.name==="AbortError")throw new Error(`Request timeout after ${n}ms`);u<s&&await new Promise(p=>setTimeout(p,a*(u+1)))}throw d||new Error("Request failed")}static async handleErrorResponse(e){let t=await e.text();throw new F(e.status,e.statusText,t)}static async get(e,t={},o={}){let{timeout:i=3e4,retries:n=0,retryDelay:s=1e3}=o,a=null;for(let l=0;l<=n;l++)try{let c=typeof AbortController<"u",d=c?new AbortController:void 0,u=c?setTimeout(()=>d.abort(),i):void 0,m=await ot.fetchImpl(e,{method:"GET",headers:t,...d?{signal:d.signal}:{}});if(u&&clearTimeout(u),!m.ok){let p=await m.text();throw new F(m.status,m.statusText,p)}return m}catch(c){if(a=c,c instanceof F&&c.status>=400&&c.status<500)throw c;if(c instanceof Error&&c.name==="AbortError")throw new Error(`Request timeout after ${i}ms`);l<n&&await new Promise(d=>setTimeout(d,s*(l+1)))}throw a||new Error("Request failed")}};ot.fetchImpl=(e,t)=>fetch(e,t);var f=ot;var v=class{static append(e,t){if(!t)return;let o=e[e.length-1];o&&o.type==="text"?o.text+=t:e.push({type:"text",text:t})}static getFullText(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}static addTextBlock(e,t){t&&e.push({type:"text",text:t})}};var si=["happy","sad","angry","surprised","neutral"],Or=/\[([a-z]+)\]/i,Ko=/\[[a-z]+\]\s*/gi,he=class{static extractEmotion(e){let t=e.match(Or);if(t){let o=t[1].toLowerCase(),i=e.replace(Ko,"").trim();return{emotion:o,cleanText:i}}return{cleanText:e}}static isValidEmotion(e){return si.includes(e)}static cleanEmotionTags(e){return e.replace(Ko,"").trim()}static addEmotionTag(e,t){return`[${e}] ${t}`}};function Er(r){let{emotion:e,cleanText:t}=he.extractEmotion(r);return e?{emotion:e,text:t}:{text:t}}function ai(r){return r.map(e=>Er(e))}function li(r){return r.emotion?he.addEmotionTag(r.emotion,r.text):r.text}async function pi(r,e){let{blocks:t}=await r.chatOnce(e,!1,()=>{});return v.getFullText(t)}var Sr=(r,e,t)=>{try{return JSON.parse(r)}catch(o){return t?.(r,o),e}},Y=(r,e)=>r?Sr(r,{},e):{};var Cr=(r,e)=>{try{return JSON.parse(r)}catch(t){if(e){e(r,t);return}throw t}},Ho=r=>typeof r=="string"?r:Array.isArray(r)?r.map(e=>typeof e=="string"?e:e&&typeof e=="object"&&e.type==="text"&&typeof e.text=="string"?e.text:"").join(""):"",Tr=async(r,e)=>{let t=r.body?.getReader();if(!t)throw new Error("Response body is null.");let o=new TextDecoder,i="",n=!1;for(;!n;){let{done:s,value:a}=await t.read();if(s)break;i+=o.decode(a,{stream:!0});let l=i.split(`
11
+ `);i=l.pop()||"";for(let c of l){let d=c.trim();if(!d||d.startsWith(":")||!d.startsWith("data:"))continue;let u=d.slice(5).trim();if(u==="[DONE]"){n=!0;break}e(u)}}};async function P(r,e,t={}){let o="";return await Tr(r,i=>{let n=Cr(i,t.onJsonError);if(!n)return;let s=Ho(n.choices?.[0]?.delta?.content);s&&(e(s),o+=s)}),o}async function y(r,e,t={}){let o=[],i=new Map,n,s,a=t.appendTextBlock??v.append;await Tr(r,d=>{let u=Cr(d,t.onJsonError);if(!u)return;let m=u.choices?.[0];typeof m?.finish_reason=="string"&&(n=m.finish_reason),u.usage&&(s=u.usage);let p=m?.delta,h=Ho(p?.content);h&&(e(h),a(o,h)),p?.tool_calls&&p.tool_calls.forEach(g=>{let C=i.get(g.index)??{id:g.id,name:g.function?.name,args:""};C.args+=g.function?.arguments||"",i.set(g.index,C)})});let l=Array.from(i.entries()).sort((d,u)=>d[0]-u[0]).map(([d,u])=>({type:"tool_use",id:u.id,name:u.name,input:Y(u.args,t.onJsonError)}));return{blocks:[...o,...l],stop_reason:l.length?"tool_use":"end",truncated:n==="length",finish_reason:n,usage:s}}function I(r,e={}){let t=r?.choices?.[0],o=[];if(t?.message?.tool_calls?.length)t.message.tool_calls.forEach(i=>o.push({type:"tool_use",id:i.id,name:i.function?.name,input:Y(i.function?.arguments,e.onJsonError)}));else{let i=Ho(t?.message?.content);i&&o.push({type:"text",text:i})}return{blocks:o,stop_reason:t?.finish_reason==="tool_calls"||o.some(i=>i.type==="tool_use")?"tool_use":"end",truncated:t?.finish_reason==="length",finish_reason:t?.finish_reason,usage:r?.usage}}var x=(r,e="chat-completions")=>r.length===0?[]:e==="responses"?r.map(t=>({type:"function",name:t.name,description:t.description,parameters:t.parameters})):r.map(t=>({type:"function",function:{name:t.name,description:t.description,parameters:t.parameters}}));async function M(r){if(!r.hasTools){let t=await r.runWithoutTools();await r.onCompleteResponse(t);return}let e=await r.runWithTools();if(r.onToolBlocks&&r.onToolBlocks(e.blocks),e.stop_reason==="end"){let t=v.getFullText(e.blocks);await r.onCompleteResponse(t);return}throw new Error(r.toolErrorMessage)}var O=r=>{let e=r.model??r.defaultModel,t=r.visionModel??(r.supportsVisionForModel(e)?e:r.defaultVisionModel);if(r.validate==="explicit"&&r.visionModel&&!r.supportsVisionForModel(r.visionModel))throw new Error(`Model ${r.visionModel} does not support vision capabilities.`);if(r.validate==="resolved"&&!r.supportsVisionForModel(t))throw new Error(`Model ${t} does not support vision capabilities.`);return t};var ci="https://openrouter.ai/api/v1/models",ui=2,hi=12e3,mi=1,di=10;function Wo(r){return r instanceof Error?r.message:String(r)}function eo(r,e){return typeof r!="number"||!Number.isFinite(r)?e:Math.max(1,Math.floor(r))}function gi(r){let e=new Set,t=[];for(let o of r){let i=o.trim();!i||e.has(i)||(e.add(i),t.push(i))}return t}async function Lr(r,e,t){if(!(typeof AbortController<"u"))return fetch(r,e);let i=new AbortController,n=setTimeout(()=>i.abort(),t);try{return await fetch(r,{...e,signal:i.signal})}catch(s){throw s instanceof Error&&s.name==="AbortError"?new Error(`Timeout after ${t}ms`):s}finally{clearTimeout(n)}}async function Pr(r){let e=`HTTP ${r.status} ${r.statusText}`.trim(),t="";try{t=await r.text()}catch{return e}let o=t.replace(/\s+/g," ").trim().slice(0,200);return o?`${e}: ${o}`:e}function _i(r){if(!r||typeof r!="object")throw new Error("Invalid models response shape");let e=r,t=Array.isArray(e.data)?e.data:Array.isArray(e.models)?e.models:[];if(t.length===0)return[];let o=t.map(i=>i.id).filter(i=>typeof i=="string");return gi(o)}async function fi({modelId:r,apiKey:e,endpoint:t,timeoutMs:o,appName:i,appUrl:n}){let s={Authorization:`Bearer ${e}`,"Content-Type":"application/json"};i&&(s["X-Title"]=i),n&&(s["HTTP-Referer"]=n);try{let a=await Lr(t,{method:"POST",headers:s,body:JSON.stringify({model:r,messages:[{role:"user",content:"Reply only with OK."}],stream:!1})},o);if(!a.ok)return{id:r,ok:!1,reason:await Pr(a)};try{await a.json()}catch(l){return{id:r,ok:!1,reason:`JSON parse failed: ${Wo(l)}`}}return{id:r,ok:!0}}catch(a){return{id:r,ok:!1,reason:Wo(a)}}}async function Mi(r,e,t){if(r.length===0)return[];let o=new Array(r.length),i=0,n=Math.min(e,r.length);return await Promise.all(Array.from({length:n},async()=>{for(;i<r.length;){let s=i;i+=1,o[s]=await t(r[s])}})),o}async function vi(r){let e=r.apiKey.trim();if(!e)throw new Error("OpenRouter API key is required.");let t=r.modelsEndpoint||ci,o=r.endpoint||Be,i=eo(r.timeoutMs,hi),n=eo(r.concurrency,ui),s=eo(r.maxCandidates,mi),a=eo(r.maxWorking,di),l=await Lr(t,{method:"GET"},i);if(!l.ok)throw new Error(await Pr(l));let c;try{c=await l.json()}catch(h){throw new Error(`JSON parse failed: ${Wo(h)}`)}let d=_i(c).filter(h=>X(h)).slice(0,s),u=await Mi(d,n,h=>fi({modelId:h,apiKey:e,endpoint:o,timeoutMs:i,appName:r.appName,appUrl:r.appUrl})),m=u.filter(h=>h.ok).map(h=>h.id).slice(0,a),p=u.filter(h=>!h.ok).map(h=>({id:h.id,reason:h.reason||"Unknown error"}));return{working:m,failed:p,fetchedAt:Date.now()}}function yr(r){return r.map(e=>({role:to(e.role),content:e.content}))}function Ir(r){return r.map(e=>{if(typeof e.content=="string")return{role:to(e.role),content:[{type:"text",text:e.content}]};if(Array.isArray(e.content)){let t=e.content.map(o=>{if(o.type==="image_url"){if(o.image_url.url.startsWith("data:")){let i=o.image_url.url.match(/^data:([^;]+);base64,(.+)$/);return i?{type:"image",source:{type:"base64",media_type:i[1],data:i[2]}}:null}return{type:"image",source:{type:"url",url:o.image_url.url,media_type:Oi(o.image_url.url)}}}return o}).filter(o=>o);return{role:to(e.role),content:t}}return{role:to(e.role),content:[]}})}function to(r){switch(r){case"system":return"system";case"user":return"user";case"assistant":return"assistant";default:return"user"}}function Oi(r){switch(r.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";case"webp":return"image/webp";default:return"image/jpeg"}}var me=class{constructor(e,t=R,o=R,i=[],n=[],s){this.provider="claude";if(this.apiKey=e,this.model=t||R,this.visionModel=o||R,this.tools=i,this.mcpServers=n,this.responseLength=s,!We.includes(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`)}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e)}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e)}hasMCPServers(){return this.mcpServers.length>0}async processChat(e,t,o){await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callClaude(e,this.model,!0);return this.parsePureStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callClaude(e,this.visionModel,!0);return this.parsePureStream(i,t)},runWithTools:()=>this.visionChatOnce(e),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async callClaude(e,t,o,i){let n=e.find(u=>u.role==="system")?.content??"",s=e.filter(u=>u.role!=="system"),a=s.some(u=>Array.isArray(u.content)&&u.content.some(m=>m.type==="image_url"||m.type==="image")),l={model:t,system:n,messages:a?Ir(s):yr(s),stream:o,max_tokens:i!==void 0?i:E(this.responseLength)};this.tools.length&&(l.tools=this.tools.map(u=>({name:u.name,description:u.description,input_schema:u.parameters})),l.tool_choice={type:"auto"}),this.mcpServers.length>0&&(l.mcp_servers=this.mcpServers);let c={"Content-Type":"application/json","x-api-key":this.apiKey,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"};return this.mcpServers.length>0&&(c["anthropic-beta"]="mcp-client-2025-04-04"),await f.post(uo,l,c)}async parseStream(e,t){let o=e.body.getReader(),i=new TextDecoder,n=[],s=new Map,a="";for(;;){let{done:l,value:c}=await o.read();if(l)break;a+=i.decode(c,{stream:!0});let d;for(;(d=a.indexOf(`
12
+ `))!==-1;){let u=a.slice(0,d).trim();if(a=a.slice(d+1),!u.startsWith("data:"))continue;let m=u.slice(5).trim();if(m==="[DONE]")break;let p=JSON.parse(m);if(p.type==="content_block_delta"&&p.delta?.text&&(t(p.delta.text),n.push({type:"text",text:p.delta.text})),p.type==="content_block_start"&&p.content_block?.type==="tool_use"?s.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_use"?s.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:"",server_name:p.content_block.server_name}):p.type==="content_block_start"&&p.content_block?.type==="tool_result"?n.push({type:"tool_result",tool_use_id:p.content_block.tool_use_id,content:p.content_block.content??""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_result"&&n.push({type:"mcp_tool_result",tool_use_id:p.content_block.tool_use_id,is_error:p.content_block.is_error??!1,content:p.content_block.content??[]}),p.type==="content_block_delta"&&p.delta?.type==="input_json_delta"){let h=s.get(p.index);h&&(h.args+=p.delta.partial_json||"")}if(p.type==="content_block_stop"&&s.has(p.index)){let{id:h,name:g,args:C,server_name:k}=s.get(p.index);k?n.push({type:"mcp_tool_use",id:h,name:g,server_name:k,input:JSON.parse(C||"{}")}):n.push({type:"tool_use",id:h,name:g,input:JSON.parse(C||"{}")}),s.delete(p.index)}}}return{blocks:n,stop_reason:n.some(l=>l.type==="tool_use"||l.type==="mcp_tool_use")?"tool_use":"end"}}async parsePureStream(e,t){let{blocks:o}=await this.parseStream(e,t);return o.filter(i=>i.type==="text").map(i=>i.text).join("")}parseOneShot(e){let t=[];return(e.content??[]).forEach(o=>{o.type==="text"?t.push({type:"text",text:o.text}):o.type==="tool_use"?t.push({type:"tool_use",id:o.id,name:o.name,input:o.input??{}}):o.type==="mcp_tool_use"?t.push({type:"mcp_tool_use",id:o.id,name:o.name,server_name:o.server_name,input:o.input??{}}):o.type==="tool_result"?t.push({type:"tool_result",tool_use_id:o.tool_use_id,content:o.content??""}):o.type==="mcp_tool_result"&&t.push({type:"mcp_tool_result",tool_use_id:o.tool_use_id,is_error:o.is_error??!1,content:o.content??[]})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use"||o.type==="mcp_tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callClaude(e,this.model,t,i),s=t?await this.parseStream(n,o):this.parseOneShot(await n.json());return this.convertToStandardCompletion(s)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callClaude(e,this.visionModel,t,i),s=t?await this.parseStream(n,o):this.parseOneShot(await n.json());return this.convertToStandardCompletion(s)}convertToStandardCompletion(e){return{blocks:e.blocks.filter(o=>o.type==="text"||o.type==="tool_use"||o.type==="tool_result"),stop_reason:e.stop_reason}}};var de=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new me(e.apiKey,e.model||this.getDefaultModel(),t,e.tools??[],e.mcpServers??[],e.responseLength)}getProviderName(){return"claude"}getSupportedModels(){return[ut,ht,mt,R,dt,gt,_t,ft,Mt,ct]}getDefaultModel(){return R}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return We.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};async function oo(r,e,t={}){let o=r.body.getReader(),i=new TextDecoder,n=[],s=new Map,a,l,c,d="";for(;;){let{done:m,value:p}=await o.read();if(m)break;d+=i.decode(p,{stream:!0});let h="",g="",C=d.split(`
13
+ `);d=C.pop()||"";for(let k=0;k<C.length;k++){let _=C[k].trim();if(_.startsWith("event:"))h=_.slice(6).trim();else if(_.startsWith("data:"))g=_.slice(5).trim();else if(_===""&&h&&g){try{let D=JSON.parse(g);Ei(h,D,e,n,s,t,L=>{L.responseStatus!==void 0&&(a=L.responseStatus),L.incompleteDetails!==void 0&&(l=L.incompleteDetails),L.usage!==void 0&&(c=L.usage)})}catch(D){t.onJsonError?.(g,D),console.warn("Failed to parse SSE data:",g)}h="",g=""}}}let u=Array.from(s.values()).map(m=>({type:"tool_use",id:m.id,name:m.name,input:m.input||{}}));return{blocks:[...n,...u],stop_reason:u.length?"tool_use":"end",truncated:a==="incomplete",response_status:a,incomplete_details:l,usage:c}}function Ei(r,e,t,o,i,n,s){switch(r){case"response.output_item.added":e.item?.type==="message"&&Array.isArray(e.item.content)?e.item.content.forEach(a=>{a.type==="output_text"&&a.text&&(t(a.text),v.append(o,a.text))}):e.item?.type==="function_call"&&i.set(e.item.id,{id:e.item.id,name:e.item.name,input:Y(e.item.arguments,n.onJsonError)});break;case"response.content_part.added":e.part?.type==="output_text"&&typeof e.part.text=="string"&&(t(e.part.text),v.append(o,e.part.text));break;case"response.output_text.delta":case"response.content_part.delta":{let a=typeof e.delta=="string"?e.delta:e.delta?.text??"";a&&(t(a),v.append(o,a));break}case"response.output_text.done":case"response.content_part.done":case"response.reasoning.started":case"response.reasoning.delta":case"response.reasoning.done":break;case"response.completed":s(xr(e,"completed"));break;case"response.incomplete":s(xr(e,"incomplete"));break;default:break}}function xr(r,e){let t=r?.response??r;return{responseStatus:t?.status??e,incompleteDetails:t?.incomplete_details??null,usage:t?.usage}}function Dr(r,e={}){let t=[];return r.output&&Array.isArray(r.output)&&r.output.forEach(o=>{o.type==="message"&&o.content&&o.content.forEach(i=>{i.type==="output_text"&&i.text&&t.push({type:"text",text:i.text})}),o.type==="function_call"&&t.push({type:"tool_use",id:o.id,name:o.name,input:Y(o.arguments,e.onJsonError)})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use")?"tool_use":"end",truncated:r?.status==="incomplete",response_status:r?.status,incomplete_details:r?.incomplete_details??null,usage:r?.usage}}function Ar({tools:r,mcpServers:e,isResponsesAPI:t}){let o=[];return r.length>0&&o.push(...x(r,t?"responses":"chat-completions")),e.length>0&&t&&o.push(...Si(e)),o}function Si(r){return r.map(e=>{let t={type:"mcp",server_label:e.name,server_url:e.url};return e.require_approval&&(t.require_approval=e.require_approval),e.tool_configuration?.allowed_tools&&(t.allowed_tools=e.tool_configuration.allowed_tools),e.authorization_token&&(t.headers={Authorization:`Bearer ${e.authorization_token}`}),t})}var Ci={[T.VERY_SHORT]:800,[T.SHORT]:1200,[T.MEDIUM]:2e3,[T.LONG]:3e3,[T.VERY_LONG]:8e3,[T.DEEP]:25e3},Ti={none:1200,minimal:1600,low:2500,medium:4e3,high:8e3,xhigh:12e3},Li=new Set(["openai-compatible","deepseek","mistral","sakana","plamo"]);function Rr({provider:r,endpoint:e,messages:t,model:o,stream:i,tools:n,mcpServers:s,responseLength:a,verbosity:l,reasoning_effort:c,enableReasoningSummary:d,maxTokens:u}){let m=e===A;yi(e,s);let p={model:o,stream:i},h=Pi({provider:r,model:o,responseLength:a,reasoning_effort:c,maxTokens:u});m?h!==void 0&&(p.max_output_tokens=h):h!==void 0&&(br(r)?p.max_tokens=h:p.max_completion_tokens=h),m?p.input=Ii(t):p.messages=r==="mistral"?xi(t):t,q(o)&&(m?(c&&(p.reasoning={...p.reasoning,effort:c},d&&(p.reasoning.summary="auto")),l&&(p.text={...p.text,format:{type:"text"},verbosity:l})):(c&&(p.reasoning_effort=c),l&&(p.verbosity=l))),r==="mistral"&&Qe(o)&&c&&No(c)&&(p.reasoning_effort=c),r==="plamo"&&c&&(p.reasoning_effort=c);let g=Ar({tools:n,mcpServers:s,isResponsesAPI:m});return g.length>0&&(p.tools=g,m||(p.tool_choice="auto")),p}function Pi({provider:r,model:e,responseLength:t,reasoning_effort:o,maxTokens:i}){if(i!==void 0)return i;let n=br(r)?t!==void 0?E(t):void 0:E(t);if(r!=="openai"||!q(e)||t===void 0)return n;let s=o??Ke(e);return Math.max(n??0,Ci[t],Ti[s])}function yi(r,e){if(e.length>0&&r===U)throw new Error(`MCP servers are not supported with Chat Completions API. Current endpoint: ${r}. Please use OpenAI Responses API endpoint: ${A}. MCP tools are only available in the Responses API endpoint.`)}function Ii(r){return r.map(e=>{let o={role:e.role==="tool"?"user":e.role};return typeof e.content=="string"?o.content=e.content:Array.isArray(e.content)?o.content=e.content.map(i=>i.type==="text"?{type:"input_text",text:i.text}:i.type==="image_url"?{type:"input_image",image_url:i.image_url.url}:i):o.content=e.content,o})}function xi(r){return r.map(e=>{let t={role:e.role};return Array.isArray(e.content)?(t.content=e.content.map(o=>o.type==="image_url"&&typeof o.image_url=="object"&&typeof o.image_url?.url=="string"?{type:"image_url",image_url:o.image_url.url}:o),t):(t.content=e.content,t)})}function br(r){return Li.has(r)}var S=class{constructor(e,t=z,o=z,i,n=U,s=[],a,l,c,d=!1,u="openai",m=!0){if(this.provider=u,this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.mcpServers=s,this.responseLength=a,this.verbosity=l,this.reasoning_effort=c,this.enableReasoningSummary=d,m&&!Ge.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenAI(e,this.model,!0),n=this.endpoint===A;try{if(n){let s=await oo(i,t);return v.getFullText(s.blocks)}return this.handleStream(i,t)}catch(s){throw console.error("[processChat] Error in streaming/completion:",s),s}},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){try{await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenAI(e,this.visionModel,!0),n=this.endpoint===A;try{if(n){let s=await oo(i,t);return v.getFullText(s.blocks)}return this.handleStream(i,t)}catch(s){throw console.error("[processVisionChat] Error in streaming/completion:",s),s}},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callOpenAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callOpenAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return this.endpoint===A?t?oo(e,o):Dr(await e.json()):t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callOpenAI(e,t,o=!1,i){let n=Rr({provider:this.provider,endpoint:this.endpoint,messages:e,model:t,stream:o,tools:this.tools,mcpServers:this.mcpServers,responseLength:this.responseLength,verbosity:this.verbosity,reasoning_effort:this.reasoning_effort,enableReasoningSummary:this.enableReasoningSummary,maxTokens:i}),s={};return(this.provider!=="openai-compatible"||this.apiKey.trim()!=="")&&(s.Authorization=`Bearer ${this.apiKey}`),await f.post(this.endpoint,n,s)}async handleStream(e,t){return P(e,t)}async parseStream(e,t){return y(e,t,{appendTextBlock:v.addTextBlock})}parseOneShot(e){return I(e)}};var ge=class extends S{constructor(e,t=pe,o=t,i,n=Ze,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"deepseek",!1)}};var _e=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new ge(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"deepseek"}getSupportedModels(){return[...Io]}getDefaultModel(){return pe}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("deepseek provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return Ze}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Nr=(r,e)=>({name:`mcp_${r.name}_search`,description:e==="schema-fetch-failed"?`Search using ${r.name} MCP server (schema fetch failed)`:`Search using ${r.name} MCP server`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}),ro=class{static async fetchToolSchemas(e){return(await this.fetchToolSchemasWithStatus(e)).schemas}static async fetchToolSchemasWithStatus(e){try{let t={"Content-Type":"application/json"};e.authorization_token&&(t.Authorization=`Bearer ${e.authorization_token}`);let i=await(await f.post(`${e.url}/tools`,{},t)).json();return Array.isArray(i.tools)?{schemas:i.tools.map(n=>({name:`mcp_${e.name}_${n.name}`,description:n.description||`Tool from ${e.name} MCP server`,parameters:n.inputSchema||{type:"object",properties:{},required:[]}})),failures:[]}:{schemas:[Nr(e)],failures:[]}}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),{schemas:[Nr(e,"schema-fetch-failed")],failures:[{server:e,error:t}]}}}static async fetchAllToolSchemas(e){return(await this.fetchAllToolSchemasWithStatus(e)).schemas}static async fetchAllToolSchemasWithStatus(e){let t=[],o=[];for(let i of e)try{let n=await this.fetchToolSchemasWithStatus(i);t.push(...n.schemas),o.push(...n.failures)}catch(n){console.error(`Failed to fetch schemas from ${i.name}:`,n),o.push({server:i,error:n})}return{schemas:t,failures:o}}};function wr(r){switch(r){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}function Vr(r,e={}){let t=[],o=null,i=[],n=()=>{o&&i.length&&(t.push({role:o,parts:[...i]}),i=[])};for(let s of r){let a=wr(s.role);if(s.tool_calls){n();for(let l of s.tool_calls)e.callIdMap?.set(l.id,l.function.name),t.push({role:"model",parts:[{functionCall:{name:l.function.name,args:JSON.parse(l.function.arguments||"{}")}}]});continue}if(s.role==="tool"){n();let l=s.name??e.callIdMap?.get(s.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:l,response:Fr(Gr(s.content))}}]});continue}a!==o&&n(),o=a,i.push({text:s.content})}return n(),t}async function kr(r,e={}){let t=e.imageFetcher??f.get,o=e.blobToBase64??Di,i=[],n=null,s=[];for(let a of r){let l=wr(a.role);if(a.tool_calls){for(let c of a.tool_calls)i.push({role:"model",parts:[{functionCall:{name:c.function.name,args:JSON.parse(c.function.arguments||"{}")}}]});continue}if(a.role==="tool"){let c=a.name??e.callIdMap?.get(a.tool_call_id)??"result";i.push({role:"user",parts:[{functionResponse:{name:c,response:Fr(Gr(a.content))}}]});continue}if(l!==n&&s.length>0&&(i.push({role:n,parts:[...s]}),s=[]),n=l,typeof a.content=="string")s.push({text:a.content});else if(Array.isArray(a.content)){for(let c of a.content)if(c.type==="text")s.push({text:c.text});else if(c.type==="image_url")try{let u=await(await t(c.image_url.url)).blob(),m=await o(u);s.push({inlineData:{mimeType:u.type||"image/jpeg",data:m.split(",")[1]}})}catch(d){throw console.error("Error processing image:",d),new Error(`Failed to process image: ${d.message}`)}}}return n&&s.length>0&&i.push({role:n,parts:[...s]}),i}function Gr(r){try{return JSON.parse(r)}catch{return r}}function Fr(r){return r===null?{content:null}:typeof r=="object"?r:{content:r}}function Di(r){return new Promise((e,t)=>{let o=new FileReader;o.onloadend=()=>e(o.result),o.onerror=t,o.readAsDataURL(r)})}function Ai(r,e){return[...r,...e].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}function Ur(r,e){let t=Ai(r,e);if(t.length!==0)return{tools:[{functionDeclarations:t}],toolConfig:{functionCallingConfig:{mode:"AUTO"}}}}function Kr(r){return r.map(e=>({name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server (fallback)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}))}var fe=class{constructor(e,t=j,o=j,i=[],n=[],s){this.provider="gemini";this.mcpToolSchemas=[];this.mcpSchemasInitialized=!1;this.callIdMap=new Map;if(this.apiKey=e,this.model=t,this.responseLength=s,!He.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o,this.tools=i,this.mcpServers=n}isGemma4Model(e){return/^gemma-4-/.test(e)}shouldMinimizeThinking(e){return e===lt||this.isGemma4Model(e)}shouldExposeTextPart(e,t){return!(!e.text||this.isGemma4Model(t)&&e.thought===!0)}adaptKeysForApi(e){let t={toolConfig:"tool_config",functionCallingConfig:"function_calling_config",functionDeclarations:"function_declarations",functionCall:"function_call",functionResponse:"function_response"};return Array.isArray(e)?e.map(o=>this.adaptKeysForApi(o)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,i])=>[t[o]??o,this.adaptKeysForApi(i)])):e}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e),this.mcpSchemasInitialized=!1,this.mcpSchemaInitializationError=void 0}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e),this.mcpSchemasInitialized=!1,this.mcpSchemaInitializationError=void 0}hasMCPServers(){return this.mcpServers.length>0}getMCPSchemaInitializationError(){return this.mcpSchemaInitializationError}async initializeMCPSchemas(){if(!(this.mcpSchemasInitialized||this.mcpServers.length===0))try{let e=new Promise((i,n)=>setTimeout(()=>n(new Error("MCP schema fetch timeout")),5e3)),t=ro.fetchAllToolSchemasWithStatus(this.mcpServers),o=await Promise.race([t,e]);this.mcpToolSchemas=o.schemas,this.mcpSchemasInitialized=!0,this.mcpSchemaInitializationError=o.failures[0]?.error}catch(e){console.warn("Failed to initialize MCP schemas, using fallback:",e),this.mcpSchemaInitializationError=e,this.mcpToolSchemas=Kr(this.mcpServers),this.mcpSchemasInitialized=!0}}async processChat(e,t,o){try{await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callGemini(e,this.model,!0),{blocks:n}=await this.parseStream(i,t,this.model);return v.getFullText(n)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use chatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processChat:",i),i}}async processVisionChat(e,t,o){try{await M({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let i=await this.callGemini(e,this.visionModel,!0),{blocks:n}=await this.parseStream(i,t,this.visionModel);return v.getFullText(n)},runWithTools:()=>this.visionChatOnce(e),onToolBlocks:i=>{i.filter(n=>n.type==="text").forEach(n=>t(n.text))},onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async callGemini(e,t,o=!1,i){let a={contents:e.some(_=>Array.isArray(_.content)&&_.content.some(D=>D?.type==="image_url"||D?.inlineData))?await kr(e,{callIdMap:this.callIdMap}):Vr(e,{callIdMap:this.callIdMap}),generationConfig:{maxOutputTokens:i!==void 0?i:E(this.responseLength)}};this.shouldMinimizeThinking(t)&&(a.generationConfig.thinkingConfig={includeThoughts:!1,thinkingLevel:"MINIMAL"});let l=[];if(this.mcpServers.length>0)try{await this.initializeMCPSchemas(),l=this.mcpToolSchemas}catch(_){console.warn("MCP initialization failed, skipping MCP tools:",_)}let c=Ur(this.tools,l);c&&Object.assign(a,c);let d=async(_,D)=>{let L=o?"streamGenerateContent":"generateContent",Bo=o?"?alt=sse":"",Br=`${co}/${_}/models/${t}:${L}${Bo}${Bo?"&":"?"}key=${this.apiKey}`;return f.post(Br,D)},u=/flash[-_]lite/.test(t),m=this.isGemma4Model(t),p=/gemini-2\.5/.test(t),h=/^gemini-3(?:\.[0-9]+)?-/.test(t),g=u||m||p||h,C=g?"v1beta":"v1",k=async()=>{try{let _=C==="v1"?a:this.adaptKeysForApi(a);return await d(C,_)}catch(_){let D=/Unknown name|Cannot find field|404/.test(_?.message||"")||_?.status===404;if(!g&&D)try{return await d("v1beta",this.adaptKeysForApi(a))}catch(L){throw L instanceof Error&&(L.cause=_),L}throw _}};try{return await k()}catch(_){throw _.body&&(console.error("Gemini API Error Details:",_.body),console.error("Request Body:",JSON.stringify(a,null,2))),_}}async parseStream(e,t,o){let i=e.body.getReader(),n=new TextDecoder,s=[],a=[],l="",c=u=>{if(!u||u==="[DONE]")return;let m;try{m=JSON.parse(u)}catch{return}for(let p of m.candidates??[])for(let h of p.content?.parts??[])this.shouldExposeTextPart(h,o)&&(t(h.text),v.addTextBlock(s,h.text)),h.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:h.functionCall.name,input:h.functionCall.args??{}}),h.functionResponse&&a.push({type:"tool_result",tool_use_id:h.functionResponse.name,content:JSON.stringify(h.functionResponse.response)})};for(;;){let{done:u,value:m}=await i.read();if(u)break;l+=n.decode(m,{stream:!0});let p;for(;(p=l.indexOf(`
14
+ `))!==-1;){let h=l.slice(0,p);if(l=l.slice(p+1),h.endsWith("\r")&&(h=h.slice(0,-1)),!h.trim()){c("");continue}h.startsWith("data:")&&(h=h.slice(5).trim()),h&&c(h)}}return l&&c(l),{blocks:[...s,...a],stop_reason:a.some(u=>u.type==="tool_use")?"tool_use":"end"}}parseOneShot(e,t){let o=[],i=[];for(let s of e.candidates??[])for(let a of s.content?.parts??[])this.shouldExposeTextPart(a,t)&&o.push({type:"text",text:a.text}),a.functionCall&&i.push({type:"tool_use",id:this.genUUID(),name:a.functionCall.name,input:a.functionCall.args??{}}),a.functionResponse&&i.push({type:"tool_result",tool_use_id:a.functionResponse.name,content:JSON.stringify(a.functionResponse.response)});return{blocks:[...o,...i],stop_reason:i.some(s=>s.type==="tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callGemini(e,this.model,t,i);return t?this.parseStream(n,o,this.model):this.parseOneShot(await n.json(),this.model)}async visionChatOnce(e,t=!1,o=()=>{},i){let n=await this.callGemini(e,this.visionModel,t,i);return t?this.parseStream(n,o,this.visionModel):this.parseOneShot(await n.json(),this.visionModel)}genUUID(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}};var Me=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new fe(e.apiKey,e.model||this.getDefaultModel(),t,e.tools||[],e.mcpServers||[],e.responseLength)}getProviderName(){return"gemini"}getSupportedModels(){return[...pt]}getDefaultModel(){return j}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return He.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};function Ri(){if(typeof globalThis<"u"&&"LanguageModel"in globalThis)return globalThis.LanguageModel}var ve=class{constructor(e={}){this.provider="gemini-nano";this.expectedInputLanguages=e.expectedInputLanguages??["ja"],this.expectedOutputLanguages=e.expectedOutputLanguages??["ja"],this._responseLength=e.responseLength}getModel(){return Z}getVisionModel(){return Z}async processChat(e,t,o){let i=await this.generateResponse(e);t(i),await o(i)}async processVisionChat(e,t,o){throw new Error("Gemini Nano does not support vision capabilities.")}async chatOnce(e,t=!1,o=()=>{},i){let n=await this.generateResponse(e);return o(n),{blocks:[{type:"text",text:n}],stop_reason:"end"}}async visionChatOnce(e,t=!1,o=()=>{},i){throw new Error("Gemini Nano does not support vision capabilities.")}async generateResponse(e){let t=Ri();if(!t)throw new Error("Gemini Nano is not available in this environment. Chrome 138+ with Prompt API enabled is required.");let o=await t.availability();if(o!=="available"&&o!=="downloadable")throw new Error(`Gemini Nano Prompt API is not ready in this environment. LanguageModel.availability() returned "${o}". Expected "available" or "downloadable".`);let n=e.filter(c=>c.role==="system").map(c=>c.content).join(`
15
15
  `),s=e.filter(c=>c.role!=="system").slice(-20),a=[...s].reverse().find(c=>c.role==="user");if(!a)throw new Error("No user message found in the provided messages.");let l=await this.createSession(t,n,s);try{return await l.prompt(a.content)}finally{try{l.destroy()}catch{}}}async createSession(e,t,o){let i=this.buildSystemPrompt(t),n=o.slice(0,-1);if(n.length>0){let s=n.map(a=>`${a.role==="user"?"User":"Assistant"}: ${a.content}`).join(`
16
16
  `);i+=`
17
17
 
18
18
  The following is the prior conversation history. Use it as context for your response:
19
19
  `+s}return e.create({systemPrompt:i,expectedInputs:[{type:"text",languages:this.expectedInputLanguages}],expectedOutputs:[{type:"text",languages:this.expectedOutputLanguages}]})}buildSystemPrompt(e){let t=[];e&&t.push(e);let o=this.getResponseLengthInstruction();return o&&t.push(o),t.join(`
20
20
 
21
- `)}getResponseLengthInstruction(){if(!this._responseLength)return;let e=Yt[this._responseLength];if(e)return`Please keep your response concise, within approximately ${e} tokens.`}};var Oe=class{createChatService(e){return new ve({expectedInputLanguages:e.expectedInputLanguages,expectedOutputLanguages:e.expectedOutputLanguages,responseLength:e.responseLength})}getProviderName(){return"gemini-nano"}getSupportedModels(){return[Z]}getDefaultModel(){return Z}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}};var Ee=class{constructor(e,t=w,o=w,i,n=ae,s,a,l){this.provider="kimi";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.responseFormat=a,this.thinking=l??{type:"enabled"},this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callKimi(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!le(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callKimi(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callKimi(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!le(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callKimi(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callKimi(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s),this.responseFormat&&(n.response_format=this.responseFormat);let a=this.resolveEffectiveThinking(t);a&&(this.isSelfHostedEndpoint()?a.type==="disabled"&&(n.chat_template_kwargs={thinking:!1}):n.thinking=a);let l=this.buildToolsDefinition();return l.length>0&&(n.tools=l,n.tool_choice="auto"),n}isSelfHostedEndpoint(){return this.normalizeEndpoint(this.endpoint)!==this.normalizeEndpoint(ae)}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveEffectiveThinking(e){if(Je(e)){if(this.thinking?.type==="disabled")throw new Error(`Model ${e} requires thinking mode and does not support thinking: disabled.`);return this.thinking??{type:"enabled"}}return this.tools.length>0?{type:"disabled"}:this.thinking}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Se=class{constructor(){this.defaultThinking={type:"enabled"}}createChatService(e){let t=this.resolveEndpoint(e),o=e.model||this.getDefaultModel(),i=O({model:o,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:a=>this.supportsVisionForModel(a),validate:"explicit"}),n=e.tools,s=this.resolveThinking(o,n,e.thinking);return new Ee(e.apiKey,o,i,n,t,e.responseLength,e.responseFormat,s)}getProviderName(){return"kimi"}getSupportedModels(){return[qe,je,w,Xt]}getDefaultModel(){return w}getDefaultVisionModel(){return w}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return le(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}resolveEndpoint(e){if(e.endpoint)return this.normalizeEndpoint(e.endpoint);if(e.baseUrl){let t=this.normalizeEndpoint(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return ae}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveThinking(e,t,o){if(Je(e)){if(o?.type==="disabled")throw new Error(`Model ${e} requires thinking mode and does not support thinking: disabled.`);return o??this.defaultThinking}return t&&t.length>0?{type:"disabled"}:o??this.defaultThinking}};var Ce=class extends S{constructor(e,t=V,o=t,i,n=Ze,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"mistral",!1)}};var Te=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),i=e.tools,n=Ye(t)?e.reasoning_effort:void 0;return new Ce(e.apiKey,t,o,i,this.resolveEndpoint(e),e.responseLength,n)}getProviderName(){return"mistral"}getSupportedModels(){return[...Ao]}getDefaultModel(){return V}getDefaultVisionModel(){return V}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return bo(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("mistral provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return Ze}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Le=class{createChatService(e){return this.validateRequiredOptions(e),new S(e.apiKey?.trim()??"",e.model,e.visionModel??e.model,e.tools,e.endpoint,[],e.responseLength,e.verbosity,e.reasoning_effort,e.enableReasoningSummary,this.getProviderName(),!1)}getProviderName(){return"openai-compatible"}getSupportedModels(){return[]}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"unknown"}supportsVisionForModel(e){return!0}getVisionSupportLevelForModel(e){return"unknown"}getDefaultModel(){return"local-model"}validateRequiredOptions(e){if(e.mcpServers!==void 0)throw new Error("openai-compatible provider does not support mcpServers.");let t=e.endpoint?.trim();if(!t)throw new Error("openai-compatible provider requires endpoint (full URL).");let o;try{o=new URL(t)}catch{throw new Error("openai-compatible provider requires endpoint to be a full URL.")}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error("openai-compatible provider requires endpoint to be a full URL.");if(!e.model?.trim())throw new Error("openai-compatible provider requires model.")}};var Pe=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=O({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:c=>this.supportsVisionForModel(c),validate:"resolved"}),i=t.tools,n=t.mcpServers??[],s=t.model||this.getDefaultModel(),a=!1;n.length>0||ao(s)?a=!0:q(s)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?A:U);return new S(t.apiKey,s,o,i,l,n,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName())}getProviderName(){return"openai"}getSupportedModels(){return[K,Q,ee,te,H,W,B,$,G,ot,rt,it,z,nt,io,no,"o1"]}getDefaultModel(){return K}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Ge.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}optimizeGPT5Options(e){let t=e.model||this.getDefaultModel();if(!q(t))return e;let o={...e};if(e.gpt5Preset){let i=ko[e.gpt5Preset];o.reasoning_effort=i.reasoning_effort,o.verbosity=i.verbosity}else e.reasoning_effort||(o.reasoning_effort=Ke(t));return o.reasoning_effort=this.normalizeReasoningEffort(t,o.reasoning_effort),o}normalizeReasoningEffort(e,t){if(t)return t==="none"&&!Fe(e)||t==="minimal"&&!Ue(e)?t==="minimal"&&Fe(e)?"none":t==="none"&&Ue(e)?"minimal":st(e)?"low":"medium":t==="low"&&!st(e)?"medium":t==="xhigh"&&!lo(e)?"high":t}};var Ai=r=>[b,oe].includes(r.trim()),Ri=r=>r.trim()===oe?"none":void 0,ye=class{constructor(e,t=b,o=b,i,n=Be,s,a,l,c,d,u){this.provider="openrouter";this.lastRequestTime=0;this.requestCount=0;this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.appName=a,this.appUrl=l,this.reasoning_effort=c,this.includeReasoning=d,this.reasoningMaxTokens=u,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async applyRateLimiting(){if(!J(this.model))return;let e=Date.now(),t=e-this.lastRequestTime;if(t>6e4&&(this.requestCount=0),this.requestCount>=Mo){let o=6e4-t;o>0&&(console.log(`Rate limit reached for free tier. Waiting ${o}ms...`),await new Promise(i=>setTimeout(i,o)),this.requestCount=0)}this.lastRequestTime=e,this.requestCount++}async processChat(e,t,o){await this.applyRateLimiting(),await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenRouter(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!re(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();try{await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenRouter(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async chatOnce(e,t=!0,o=()=>{},i){await this.applyRateLimiting();let n=await this.callOpenRouter(e,this.model,t,i);return t?this.parseStream(n,o):this.parseOneShot(await n.json())}async visionChatOnce(e,t=!1,o=()=>{},i){if(!re(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();let n=await this.callOpenRouter(e,this.visionModel,t,i);return t?this.parseStream(n,o):this.parseOneShot(await n.json())}async callOpenRouter(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i),s={Authorization:`Bearer ${this.apiKey}`};return this.appUrl&&(s["HTTP-Referer"]=this.appUrl),this.appName&&(s["X-Title"]=this.appName),await f.post(this.endpoint,n,s)}buildRequestBody(e,t,o,i){let n={model:t,messages:e,stream:o},s=i!==void 0?i:E(this.responseLength);s&&Ai(t)?console.warn(`OpenRouter: Token limits are disabled for ${t} because this model can return empty content when a token limit is set.`):s&&(n.max_tokens=s);let a=Ri(t);if(this.reasoning_effort!==void 0||this.includeReasoning!==void 0||this.reasoningMaxTokens||a){if(n.reasoning={},this.reasoning_effort&&this.reasoning_effort!=="none"){let l=this.reasoning_effort==="minimal"?"low":this.reasoning_effort;n.reasoning.effort=l}else this.reasoning_effort===void 0&&a&&(n.reasoning.effort=a);(this.reasoning_effort==="none"||this.includeReasoning!==!0)&&(n.reasoning.exclude=!0),this.reasoningMaxTokens&&(n.reasoning.max_tokens=this.reasoningMaxTokens)}else n.reasoning={exclude:!0};return this.tools.length>0&&(n.tools=x(this.tools,"chat-completions"),n.tool_choice="auto"),n}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ie=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:e.model||this.getDefaultModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),o=e.tools,i=e.appName,n=e.appUrl;return new ye(e.apiKey,e.model||this.getDefaultModel(),t,o,e.endpoint,e.responseLength,i,n,e.reasoning_effort,e.includeReasoning,e.reasoningMaxTokens)}getProviderName(){return"openrouter"}getSupportedModels(){return[uo,ho,b,Wt,Et,St,Ct,Tt,Lt,Pt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,mo,kt,Gt,Ft,Ut,Kt,Ht,oe,go,_o,Ot,Mt,vt]}getDefaultModel(){return b}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return this.getSupportedModels().some(e=>this.supportsVisionForModel(e))?"supported":"unsupported"}supportsVisionForModel(e){return re(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}getFreeModels(){return fo}isModelFree(e){return J(e)}};var xe=class extends S{constructor(e,t=ue,o=t,i,n=et,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"plamo",!1)}};var De=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new xe(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength,e.reasoning_effort)}getProviderName(){return"plamo"}getSupportedModels(){return[...wo]}getDefaultModel(){return ue}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("plamo provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return et}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Ae=class extends S{constructor(e,t=ce,o=t,i,n=Qe,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"sakana",!1)}};var Re=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new Ae(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"sakana"}getSupportedModels(){return[...No]}getDefaultModel(){return ce}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("sakana provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return Qe}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var be=class{constructor(e,t=N,o=N,i,n=ze,s){this.provider="xai";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callXAI(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callXAI(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callXAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callXAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callXAI(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s);let a=this.buildToolsDefinition();return a.length>0&&(n.tools=a,n.tool_choice="auto"),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ne=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:n=>this.supportsVisionForModel(n),validate:"explicit"}),i=e.tools;return new be(e.apiKey,t,o,i,e.endpoint||ze,e.responseLength)}getProviderName(){return"xai"}getSupportedModels(){return[zt,qt,jt,Jt,N]}getDefaultModel(){return N}getDefaultVisionModel(){return N}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return se(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var we=class{constructor(e,t=ie,o=X,i,n=$e,s,a,l){this.provider="zai";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.responseFormat=a,this.thinking=l??{type:"disabled"},this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callZAI(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!ne(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callZAI(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callZAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!ne(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callZAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callZAI(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s),this.responseFormat&&(n.response_format=this.responseFormat),this.thinking&&(n.thinking=this.thinking);let a=this.buildToolsDefinition();return a.length>0&&(n.tools=a,n.tool_choice="auto",o&&Lo(t)&&(n.tool_stream=!0)),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ve=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),i=e.tools,n=e.thinking??{type:"disabled"};return new we(e.apiKey,t,o,i,e.endpoint||$e,e.responseLength,e.responseFormat,n)}getProviderName(){return"zai"}getSupportedModels(){return[ie,vo,Oo,Eo,So,Co,To,Bt,$t,X]}getDefaultModel(){return ie}getDefaultVisionModel(){return X}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ne(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Ur=[new Pe,new Le,new Me,new Oe,new de,new Ie,new Ve,new Ne,new Se,new _e,new Te,new Re,new De];var ke=class{static registerProvider(e){this.providers.set(e.getProviderName(),e)}static createChatService(e,t){let o=this.providers.get(e);if(!o)throw new Error(`Unknown chat provider: ${e}`);return o.createChatService(t)}static getProviders(){return this.providers}static getAvailableProviders(){return Array.from(this.providers.keys())}static getSupportedModels(e){let t=this.providers.get(e);return t?t.getSupportedModels():[]}static getVisionSupportLevel(e){let t=this.providers.get(e);return t?t.getVisionSupportLevel():"unsupported"}static getVisionSupportLevelForModel(e,t){let o=this.providers.get(e);return o?o.getVisionSupportLevelForModel?o.getVisionSupportLevelForModel(t):o.supportsVisionForModel?o.supportsVisionForModel(t)?"supported":"unsupported":o.getVisionSupportLevel():"unsupported"}};ke.providers=new Map;Ur.forEach(r=>ke.registerProvider(r));function Kr(){f.setFetch(async(r,e={})=>{let t=(e.method||"GET").toString().toUpperCase(),o=e.headers,i={};if(Array.isArray(o))for(let[u,m]of o)i[u]=String(m);else if(o&&typeof o=="object")for(let[u,m]of Object.entries(o))i[u]=String(m);let n={method:t,headers:i,muteHttpExceptions:!0},s=e.body;typeof s=="string"?n.payload=s:s!=null&&(i["Content-Type"]||(i["Content-Type"]="application/json"),n.payload=JSON.stringify(s));let a=UrlFetchApp.fetch(r,n),l=a.getResponseCode(),c=a.getContentText();return{ok:l>=200&&l<300,status:l,statusText:String(l),text:async()=>c,json:async()=>c?JSON.parse(c):null}})}return jr(bi);})();
21
+ `)}getResponseLengthInstruction(){if(!this._responseLength)return;let e=Qt[this._responseLength];if(e)return`Please keep your response concise, within approximately ${e} tokens.`}};var Oe=class{createChatService(e){return new ve({expectedInputLanguages:e.expectedInputLanguages,expectedOutputLanguages:e.expectedOutputLanguages,responseLength:e.responseLength})}getProviderName(){return"gemini-nano"}getSupportedModels(){return[Z]}getDefaultModel(){return Z}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}};var Ee=class{constructor(e,t=w,o=w,i,n=ae,s,a,l){this.provider="kimi";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.responseFormat=a,this.thinking=l??{type:"enabled"},this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callKimi(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!le(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callKimi(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callKimi(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!le(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callKimi(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callKimi(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s),this.responseFormat&&(n.response_format=this.responseFormat);let a=this.resolveEffectiveThinking(t);a&&(this.isSelfHostedEndpoint()?a.type==="disabled"&&(n.chat_template_kwargs={thinking:!1}):n.thinking=a);let l=this.buildToolsDefinition();return l.length>0&&(n.tools=l,n.tool_choice="auto"),n}isSelfHostedEndpoint(){return this.normalizeEndpoint(this.endpoint)!==this.normalizeEndpoint(ae)}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveEffectiveThinking(e){if(Je(e)){if(this.thinking?.type==="disabled")throw new Error(`Model ${e} requires thinking mode and does not support thinking: disabled.`);return this.thinking??{type:"enabled"}}return this.tools.length>0?{type:"disabled"}:this.thinking}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Se=class{constructor(){this.defaultThinking={type:"enabled"}}createChatService(e){let t=this.resolveEndpoint(e),o=e.model||this.getDefaultModel(),i=O({model:o,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:a=>this.supportsVisionForModel(a),validate:"explicit"}),n=e.tools,s=this.resolveThinking(o,n,e.thinking);return new Ee(e.apiKey,o,i,n,t,e.responseLength,e.responseFormat,s)}getProviderName(){return"kimi"}getSupportedModels(){return[je,Xe,w,Zt]}getDefaultModel(){return w}getDefaultVisionModel(){return w}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return le(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}resolveEndpoint(e){if(e.endpoint)return this.normalizeEndpoint(e.endpoint);if(e.baseUrl){let t=this.normalizeEndpoint(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return ae}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveThinking(e,t,o){if(Je(e)){if(o?.type==="disabled")throw new Error(`Model ${e} requires thinking mode and does not support thinking: disabled.`);return o??this.defaultThinking}return t&&t.length>0?{type:"disabled"}:o??this.defaultThinking}};var Ce=class extends S{constructor(e,t=V,o=t,i,n=Ye,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"mistral",!1)}};var Te=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),i=e.tools,n=Qe(t)?e.reasoning_effort:void 0;return new Ce(e.apiKey,t,o,i,this.resolveEndpoint(e),e.responseLength,n)}getProviderName(){return"mistral"}getSupportedModels(){return[...bo]}getDefaultModel(){return V}getDefaultVisionModel(){return V}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return wo(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("mistral provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return Ye}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Le=class{createChatService(e){return this.validateRequiredOptions(e),new S(e.apiKey?.trim()??"",e.model,e.visionModel??e.model,e.tools,e.endpoint,[],e.responseLength,e.verbosity,e.reasoning_effort,e.enableReasoningSummary,this.getProviderName(),!1)}getProviderName(){return"openai-compatible"}getSupportedModels(){return[]}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"unknown"}supportsVisionForModel(e){return!0}getVisionSupportLevelForModel(e){return"unknown"}getDefaultModel(){return"local-model"}validateRequiredOptions(e){if(e.mcpServers!==void 0)throw new Error("openai-compatible provider does not support mcpServers.");let t=e.endpoint?.trim();if(!t)throw new Error("openai-compatible provider requires endpoint (full URL).");let o;try{o=new URL(t)}catch{throw new Error("openai-compatible provider requires endpoint to be a full URL.")}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error("openai-compatible provider requires endpoint to be a full URL.");if(!e.model?.trim())throw new Error("openai-compatible provider requires model.")}};var Pe=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=O({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:c=>this.supportsVisionForModel(c),validate:"resolved"}),i=t.tools,n=t.mcpServers??[],s=t.model||this.getDefaultModel(),a=!1;n.length>0||lo(s)?a=!0:q(s)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?A:U);return new S(t.apiKey,s,o,i,l,n,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName())}getProviderName(){return"openai"}getSupportedModels(){return[K,Q,ee,te,H,W,B,$,G,rt,it,nt,z,st,no,so,"o1"]}getDefaultModel(){return K}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Ge.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}optimizeGPT5Options(e){let t=e.model||this.getDefaultModel();if(!q(t))return e;let o={...e};if(e.gpt5Preset){let i=Fo[e.gpt5Preset];o.reasoning_effort=i.reasoning_effort,o.verbosity=i.verbosity}else e.reasoning_effort||(o.reasoning_effort=Ke(t));return o.reasoning_effort=this.normalizeReasoningEffort(t,o.reasoning_effort),o}normalizeReasoningEffort(e,t){if(t)return t==="none"&&!Fe(e)||t==="minimal"&&!Ue(e)?t==="minimal"&&Fe(e)?"none":t==="none"&&Ue(e)?"minimal":at(e)?"low":"medium":t==="low"&&!at(e)?"medium":t==="xhigh"&&!po(e)?"high":t}};var bi=r=>[b,oe].includes(r.trim()),Ni=r=>r.trim()===oe?"none":void 0,ye=class{constructor(e,t=b,o=b,i,n=Be,s,a,l,c,d,u){this.provider="openrouter";this.lastRequestTime=0;this.requestCount=0;this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.appName=a,this.appUrl=l,this.reasoning_effort=c,this.includeReasoning=d,this.reasoningMaxTokens=u,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async applyRateLimiting(){if(!X(this.model))return;let e=Date.now(),t=e-this.lastRequestTime;if(t>6e4&&(this.requestCount=0),this.requestCount>=vo){let o=6e4-t;o>0&&(console.log(`Rate limit reached for free tier. Waiting ${o}ms...`),await new Promise(i=>setTimeout(i,o)),this.requestCount=0)}this.lastRequestTime=e,this.requestCount++}async processChat(e,t,o){await this.applyRateLimiting(),await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenRouter(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!re(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();try{await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callOpenRouter(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(i){throw console.error("Error in processVisionChat:",i),i}}async chatOnce(e,t=!0,o=()=>{},i){await this.applyRateLimiting();let n=await this.callOpenRouter(e,this.model,t,i);return t?this.parseStream(n,o):this.parseOneShot(await n.json())}async visionChatOnce(e,t=!1,o=()=>{},i){if(!re(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();let n=await this.callOpenRouter(e,this.visionModel,t,i);return t?this.parseStream(n,o):this.parseOneShot(await n.json())}async callOpenRouter(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i),s={Authorization:`Bearer ${this.apiKey}`};return this.appUrl&&(s["HTTP-Referer"]=this.appUrl),this.appName&&(s["X-Title"]=this.appName),await f.post(this.endpoint,n,s)}buildRequestBody(e,t,o,i){let n={model:t,messages:e,stream:o},s=i!==void 0?i:E(this.responseLength);s&&bi(t)?console.warn(`OpenRouter: Token limits are disabled for ${t} because this model can return empty content when a token limit is set.`):s&&(n.max_tokens=s);let a=Ni(t);if(this.reasoning_effort!==void 0||this.includeReasoning!==void 0||this.reasoningMaxTokens||a){if(n.reasoning={},this.reasoning_effort&&this.reasoning_effort!=="none"){let l=this.reasoning_effort==="minimal"?"low":this.reasoning_effort;n.reasoning.effort=l}else this.reasoning_effort===void 0&&a&&(n.reasoning.effort=a);(this.reasoning_effort==="none"||this.includeReasoning!==!0)&&(n.reasoning.exclude=!0),this.reasoningMaxTokens&&(n.reasoning.max_tokens=this.reasoningMaxTokens)}else n.reasoning={exclude:!0};return this.tools.length>0&&(n.tools=x(this.tools,"chat-completions"),n.tool_choice="auto"),n}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ie=class{createChatService(e){let t=O({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:e.model||this.getDefaultModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),o=e.tools,i=e.appName,n=e.appUrl;return new ye(e.apiKey,e.model||this.getDefaultModel(),t,o,e.endpoint,e.responseLength,i,n,e.reasoning_effort,e.includeReasoning,e.reasoningMaxTokens)}getProviderName(){return"openrouter"}getSupportedModels(){return[ho,mo,b,Bt,St,Ct,Tt,Lt,Pt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,go,Gt,Ft,Ut,Kt,Ht,Wt,oe,_o,fo,Et,vt,Ot]}getDefaultModel(){return b}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return this.getSupportedModels().some(e=>this.supportsVisionForModel(e))?"supported":"unsupported"}supportsVisionForModel(e){return re(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}getFreeModels(){return Mo}isModelFree(e){return X(e)}};var xe=class extends S{constructor(e,t=ue,o=t,i,n=tt,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"plamo",!1)}};var De=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new xe(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength,e.reasoning_effort)}getProviderName(){return"plamo"}getSupportedModels(){return[...ko]}getDefaultModel(){return ue}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("plamo provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return tt}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Ae=class extends S{constructor(e,t=ce,o=t,i,n=et,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"sakana",!1)}};var Re=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new Ae(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"sakana"}getSupportedModels(){return[...Vo]}getDefaultModel(){return ce}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}supportsVisionForModel(e){return!1}getVisionSupportLevelForModel(e){return"unsupported"}validateRequiredOptions(e){if(!e.apiKey?.trim())throw new Error("sakana provider requires apiKey.")}resolveEndpoint(e){if(e.endpoint)return this.normalizeUrl(e.endpoint);if(e.baseUrl){let t=this.normalizeUrl(e.baseUrl);return t.endsWith("/chat/completions")?t:`${t}/chat/completions`}return et}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var be=class{constructor(e,t=N,o=N,i,n=ze,s,a){this.provider="xai";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.visionModel=o,this.reasoningEffort=a}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callXAI(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callXAI(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callXAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callXAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callXAI(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s),this.reasoningEffort&&Jt(t)&&(n.reasoning_effort=this.reasoningEffort);let a=this.buildToolsDefinition();return a.length>0&&(n.tools=a,n.tool_choice="auto"),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ne=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:n=>this.supportsVisionForModel(n),validate:"explicit"}),i=e.tools;return new be(e.apiKey,t,o,i,e.endpoint||ze,e.responseLength,e.reasoning_effort??yo(t))}getProviderName(){return"xai"}getSupportedModels(){return[qe,qt,jt,Xt,N]}getDefaultModel(){return N}getDefaultVisionModel(){return N}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return se(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var we=class{constructor(e,t=ie,o=J,i,n=$e,s,a,l){this.provider="zai";this.apiKey=e,this.model=t,this.tools=i||[],this.endpoint=n,this.responseLength=s,this.responseFormat=a,this.thinking=l??{type:"disabled"},this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callZAI(e,this.model,!0);return this.handleStream(i,t)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}async processVisionChat(e,t,o){if(!ne(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await M({hasTools:this.tools.length>0,runWithoutTools:async()=>{let i=await this.callZAI(e,this.visionModel,!0);return this.handleStream(i,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}async chatOnce(e,t=!0,o=()=>{},i){let n=await this.callZAI(e,this.model,t,i);return this.parseResponse(n,t,o)}async visionChatOnce(e,t=!1,o=()=>{},i){if(!ne(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let n=await this.callZAI(e,this.visionModel,t,i);return this.parseResponse(n,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callZAI(e,t,o=!1,i){let n=this.buildRequestBody(e,t,o,i);return await f.post(this.endpoint,n,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,i){let n={model:t,stream:o,messages:e},s=i!==void 0?i:E(this.responseLength);s!==void 0&&(n.max_tokens=s),this.responseFormat&&(n.response_format=this.responseFormat),this.thinking&&(n.thinking=this.thinking);let a=this.buildToolsDefinition();return a.length>0&&(n.tools=a,n.tool_choice="auto",o&&Po(t)&&(n.tool_stream=!0)),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return P(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return I(e)}};var Ve=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=O({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),i=e.tools,n=e.thinking??{type:"disabled"};return new we(e.apiKey,t,o,i,e.endpoint||$e,e.responseLength,e.responseFormat,n)}getProviderName(){return"zai"}getSupportedModels(){return[ie,Oo,Eo,So,Co,To,Lo,$t,zt,J]}getDefaultModel(){return ie}getDefaultVisionModel(){return J}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ne(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Hr=[new Pe,new Le,new Me,new Oe,new de,new Ie,new Ve,new Ne,new Se,new _e,new Te,new Re,new De];var ke=class{static registerProvider(e){this.providers.set(e.getProviderName(),e)}static createChatService(e,t){let o=this.providers.get(e);if(!o)throw new Error(`Unknown chat provider: ${e}`);return o.createChatService(t)}static getProviders(){return this.providers}static getAvailableProviders(){return Array.from(this.providers.keys())}static getSupportedModels(e){let t=this.providers.get(e);return t?t.getSupportedModels():[]}static getVisionSupportLevel(e){let t=this.providers.get(e);return t?t.getVisionSupportLevel():"unsupported"}static getVisionSupportLevelForModel(e,t){let o=this.providers.get(e);return o?o.getVisionSupportLevelForModel?o.getVisionSupportLevelForModel(t):o.supportsVisionForModel?o.supportsVisionForModel(t)?"supported":"unsupported":o.getVisionSupportLevel():"unsupported"}};ke.providers=new Map;Hr.forEach(r=>ke.registerProvider(r));function Wr(){f.setFetch(async(r,e={})=>{let t=(e.method||"GET").toString().toUpperCase(),o=e.headers,i={};if(Array.isArray(o))for(let[u,m]of o)i[u]=String(m);else if(o&&typeof o=="object")for(let[u,m]of Object.entries(o))i[u]=String(m);let n={method:t,headers:i,muteHttpExceptions:!0},s=e.body;typeof s=="string"?n.payload=s:s!=null&&(i["Content-Type"]||(i["Content-Type"]="application/json"),n.payload=JSON.stringify(s));let a=UrlFetchApp.fetch(r,n),l=a.getResponseCode(),c=a.getContentText();return{ok:l>=200&&l<300,status:l,statusText:String(l),text:async()=>c,json:async()=>c?JSON.parse(c):null}})}return Jr(wi);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aituber-onair/chat",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Chat and LLM API integration library for AITuber OnAir",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",