@aituber-onair/chat 0.44.0 → 0.45.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.
- package/README.ja.md +7 -7
- package/README.md +7 -7
- package/dist/cjs/constants/xai.d.ts +9 -0
- package/dist/cjs/constants/xai.d.ts.map +1 -1
- package/dist/cjs/constants/xai.js +27 -2
- package/dist/cjs/constants/xai.js.map +1 -1
- package/dist/cjs/services/ChatServiceFactory.js +1 -1
- package/dist/cjs/services/ChatServiceFactory.js.map +1 -1
- package/dist/cjs/services/providers/xai/XAIChatService.d.ts.map +1 -1
- package/dist/cjs/services/providers/xai/XAIChatService.js +1 -1
- package/dist/cjs/services/providers/xai/XAIChatService.js.map +1 -1
- package/dist/cjs/services/providers/xai/XAIChatServiceProvider.d.ts.map +1 -1
- package/dist/cjs/services/providers/xai/XAIChatServiceProvider.js +2 -1
- package/dist/cjs/services/providers/xai/XAIChatServiceProvider.js.map +1 -1
- package/dist/esm/constants/xai.d.ts +9 -0
- package/dist/esm/constants/xai.d.ts.map +1 -1
- package/dist/esm/constants/xai.js +24 -1
- package/dist/esm/constants/xai.js.map +1 -1
- package/dist/esm/services/ChatServiceFactory.js +1 -1
- package/dist/esm/services/ChatServiceFactory.js.map +1 -1
- package/dist/esm/services/providers/xai/XAIChatService.d.ts.map +1 -1
- package/dist/esm/services/providers/xai/XAIChatService.js +2 -2
- package/dist/esm/services/providers/xai/XAIChatService.js.map +1 -1
- package/dist/esm/services/providers/xai/XAIChatServiceProvider.d.ts.map +1 -1
- package/dist/esm/services/providers/xai/XAIChatServiceProvider.js +3 -2
- package/dist/esm/services/providers/xai/XAIChatServiceProvider.js.map +1 -1
- package/dist/umd/aituber-onair-chat.js +31 -4
- package/dist/umd/aituber-onair-chat.min.js +7 -7
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -675,17 +675,17 @@ const zaiService = ChatServiceFactory.createChatService('zai', {
|
|
|
675
675
|
```typescript
|
|
676
676
|
const xaiService = ChatServiceFactory.createChatService('xai', {
|
|
677
677
|
apiKey: process.env.XAI_API_KEY,
|
|
678
|
-
model: 'grok-4.
|
|
679
|
-
reasoning_effort: '
|
|
680
|
-
visionModel: 'grok-4.3', // 任意: xAI
|
|
678
|
+
model: 'grok-4.5',
|
|
679
|
+
reasoning_effort: 'low', // 任意(Grok 4.5): low, medium, high
|
|
680
|
+
visionModel: 'grok-4.3', // 任意: ビジョン対応の xAI モデルを指定
|
|
681
681
|
});
|
|
682
682
|
```
|
|
683
683
|
|
|
684
684
|
注意:
|
|
685
685
|
- xAIはOpenAI互換のChat Completionsを利用します。
|
|
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` は
|
|
688
|
-
-
|
|
686
|
+
- 対応モデル: `grok-4.5`, `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` は対応モデルにのみ送信されます。`grok-4.5` は `low`, `medium`, `high` に対応し、チャット用途向けにデフォルトは `low` です。`grok-4.3` は `none`, `low`, `medium`, `high` に対応し、デフォルトは `none` です。
|
|
688
|
+
- 対応 xAI モデルではビジョンとツール・関数呼び出しを利用できます。Grok 4.5 も React basic サンプルで画像チャットを直接検証できるようにビジョン対応として有効化しています。
|
|
689
689
|
|
|
690
690
|
#### Kimi(Moonshot)
|
|
691
691
|
|
|
@@ -1133,7 +1133,7 @@ vision、JSON mode、reasoning 設定を使うべきかを provider 固有ロジ
|
|
|
1133
1133
|
- **Claude**: Claude Sonnet 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Opus 4.5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Haiku 4.5 に加え、まだ利用可能だが非推奨の Claude 4 Opus, Claude 4 Sonnet, Claude 3 Haiku をサポート
|
|
1134
1134
|
- **OpenRouter**: OpenRouterのキュレーション済みモデル一覧(OpenAI/Claude/Gemini/Z.ai/Kimi)をサポート。モデルIDはOpenRouter節を参照してください
|
|
1135
1135
|
- **Z.ai**: GLM-5.2/GLM-5/GLM-5-Turbo(テキスト)、GLM-4.7/4.6(テキスト)、GLM-4.6V系(ビジョン)をサポート
|
|
1136
|
-
- **xAI**: Grok 4.3、Grok 4.20 の Reasoning/Non-Reasoning、Grok 4-1 Fast の Reasoning/Non-Reasoning をサポートし、全モデルでビジョン対応
|
|
1136
|
+
- **xAI**: Grok 4.5 をチャット用途向けに `reasoning_effort: 'low'` デフォルトでサポート。加えて Grok 4.3、Grok 4.20 の Reasoning/Non-Reasoning、Grok 4-1 Fast の Reasoning/Non-Reasoning をサポートし、全モデルでビジョン対応
|
|
1137
1137
|
- **Kimi**: Kimi K2.7 Code(`kimi-k2.7-code`)、Kimi K2.7 Code HighSpeed(`kimi-k2.7-code-highspeed`)、Kimi K2.6(`kimi-k2.6`、デフォルト)、Kimi K2.5(`kimi-k2.5`、いずれもビジョン対応)をサポート
|
|
1138
1138
|
- **DeepSeek**: DeepSeek V4 Flash(`deepseek-v4-flash`)と DeepSeek V4 Pro(`deepseek-v4-pro`)をOpenAI互換Chat Completions経由でサポート。legacy alias の`deepseek-chat`と`deepseek-reasoner`はDeepSeek側で非推奨です
|
|
1139
1139
|
- **Mistral**: `mistral-small-latest`, `mistral-medium-3-5`, `mistral-large-latest`, `mistral-large-2512`, `mistral-small-2603`, `mistral-medium-2508`などの現行generalist modelをサポートし、streamingとvisionにも対応。adjustable `reasoning_effort`は対応モデルにだけ送信します
|
package/README.md
CHANGED
|
@@ -687,17 +687,17 @@ Notes:
|
|
|
687
687
|
```typescript
|
|
688
688
|
const xaiService = ChatServiceFactory.createChatService('xai', {
|
|
689
689
|
apiKey: process.env.XAI_API_KEY,
|
|
690
|
-
model: 'grok-4.
|
|
691
|
-
reasoning_effort: '
|
|
692
|
-
visionModel: 'grok-4.3', // Optional:
|
|
690
|
+
model: 'grok-4.5',
|
|
691
|
+
reasoning_effort: 'low', // Optional for Grok 4.5: low, medium, high
|
|
692
|
+
visionModel: 'grok-4.3', // Optional: use a vision-capable xAI model
|
|
693
693
|
});
|
|
694
694
|
```
|
|
695
695
|
|
|
696
696
|
Notes:
|
|
697
697
|
- xAI uses OpenAI-compatible Chat Completions.
|
|
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.
|
|
700
|
-
-
|
|
698
|
+
- Supported models: `grok-4.5`, `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 models that support it. `grok-4.5` supports `low`, `medium`, and `high` and defaults to `low` for chat-style responses. `grok-4.3` supports `none`, `low`, `medium`, and `high` and defaults to `none`.
|
|
700
|
+
- Supported xAI models can be used with vision and tool/function calling. Grok 4.5 vision support is enabled so image chat can be validated directly in the React basic sample.
|
|
701
701
|
|
|
702
702
|
#### Kimi (Moonshot)
|
|
703
703
|
|
|
@@ -1148,7 +1148,7 @@ Currently, the following AI providers are built-in:
|
|
|
1148
1148
|
- **Claude**: Supports current Claude API model IDs including Claude Sonnet 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Opus 4.5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Haiku 4.5, plus deprecated-but-still-available Claude 4 Opus, Claude 4 Sonnet, and Claude 3 Haiku
|
|
1149
1149
|
- **OpenRouter**: Supports a curated OpenRouter model list (OpenAI/Claude/Gemini/Z.ai/Kimi). See the OpenRouter section for model IDs.
|
|
1150
1150
|
- **Z.ai**: Supports GLM-5.2/GLM-5/GLM-5-Turbo (text), GLM-4.7/4.6 (text), and GLM-4.6V family (vision)
|
|
1151
|
-
- **xAI**: Supports Grok 4.3, Grok 4.20 Reasoning/Non-Reasoning, and Grok 4-1 Fast Reasoning/Non-Reasoning, all with vision support
|
|
1151
|
+
- **xAI**: Supports Grok 4.5 with `reasoning_effort: 'low'` by default for chat-style responses, plus Grok 4.3, Grok 4.20 Reasoning/Non-Reasoning, and Grok 4-1 Fast Reasoning/Non-Reasoning, all with vision support.
|
|
1152
1152
|
- **Kimi**: Supports Kimi K2.7 Code (`kimi-k2.7-code`), Kimi K2.7 Code HighSpeed (`kimi-k2.7-code-highspeed`), Kimi K2.6 (`kimi-k2.6`, default), and Kimi K2.5 (`kimi-k2.5`) with vision support
|
|
1153
1153
|
- **DeepSeek**: Supports DeepSeek V4 Flash (`deepseek-v4-flash`) and DeepSeek V4 Pro (`deepseek-v4-pro`) via OpenAI-compatible Chat Completions. Legacy aliases `deepseek-chat` and `deepseek-reasoner` are deprecated by DeepSeek.
|
|
1154
1154
|
- **Mistral**: Supports current Mistral generalist models including `mistral-small-latest`, `mistral-medium-3-5`, `mistral-large-latest`, `mistral-large-2512`, `mistral-small-2603`, and `mistral-medium-2508`, with streaming and vision support. Adjustable `reasoning_effort` is only sent for supported models.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const ENDPOINT_XAI_CHAT_COMPLETIONS_API = "https://api.x.ai/v1/chat/completions";
|
|
2
|
+
export declare const MODEL_GROK_4_5 = "grok-4.5";
|
|
2
3
|
export declare const MODEL_GROK_4_3 = "grok-4.3";
|
|
3
4
|
export declare const MODEL_GROK_4_20_REASONING = "grok-4.20-0309-reasoning";
|
|
4
5
|
export declare const MODEL_GROK_4_20_NON_REASONING = "grok-4.20-0309-non-reasoning";
|
|
@@ -14,8 +15,16 @@ export declare function isXaiVisionModel(model: string): boolean;
|
|
|
14
15
|
* Check if a model supports the xAI reasoning_effort parameter
|
|
15
16
|
*/
|
|
16
17
|
export declare function isXaiReasoningEffortModel(model: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a model supports disabling reasoning with reasoning_effort none
|
|
20
|
+
*/
|
|
21
|
+
export declare function isXaiReasoningEffortNoneModel(model: string): boolean;
|
|
17
22
|
/**
|
|
18
23
|
* Get default reasoning effort for xAI models
|
|
19
24
|
*/
|
|
20
25
|
export declare function getDefaultXaiReasoningEffort(model: string): XaiReasoningEffort | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Normalize xAI reasoning_effort for each model's documented support
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeXaiReasoningEffort(model: string, reasoningEffort?: XaiReasoningEffort): XaiReasoningEffort | undefined;
|
|
21
30
|
//# 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;AAE/E,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGpE,eAAO,MAAM,2BAA2B,
|
|
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,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,UAOvC,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,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GACZ,kBAAkB,GAAG,SAAS,CAMhC;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,kBAAkB,GACnC,kBAAkB,GAAG,SAAS,CAUhC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
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.MODEL_GROK_4_5 = exports.ENDPOINT_XAI_CHAT_COMPLETIONS_API = void 0;
|
|
4
4
|
exports.isXaiVisionModel = isXaiVisionModel;
|
|
5
5
|
exports.isXaiReasoningEffortModel = isXaiReasoningEffortModel;
|
|
6
|
+
exports.isXaiReasoningEffortNoneModel = isXaiReasoningEffortNoneModel;
|
|
6
7
|
exports.getDefaultXaiReasoningEffort = getDefaultXaiReasoningEffort;
|
|
8
|
+
exports.normalizeXaiReasoningEffort = normalizeXaiReasoningEffort;
|
|
7
9
|
exports.ENDPOINT_XAI_CHAT_COMPLETIONS_API = 'https://api.x.ai/v1/chat/completions';
|
|
8
10
|
// xAI Grok models
|
|
11
|
+
exports.MODEL_GROK_4_5 = 'grok-4.5';
|
|
9
12
|
exports.MODEL_GROK_4_3 = 'grok-4.3';
|
|
10
13
|
exports.MODEL_GROK_4_20_REASONING = 'grok-4.20-0309-reasoning';
|
|
11
14
|
exports.MODEL_GROK_4_20_NON_REASONING = 'grok-4.20-0309-non-reasoning';
|
|
@@ -13,6 +16,7 @@ exports.MODEL_GROK_4_1_FAST_REASONING = 'grok-4-1-fast-reasoning';
|
|
|
13
16
|
exports.MODEL_GROK_4_1_FAST_NON_REASONING = 'grok-4-1-fast-non-reasoning';
|
|
14
17
|
// Vision support for models
|
|
15
18
|
exports.XAI_VISION_SUPPORTED_MODELS = [
|
|
19
|
+
exports.MODEL_GROK_4_5,
|
|
16
20
|
exports.MODEL_GROK_4_3,
|
|
17
21
|
exports.MODEL_GROK_4_20_REASONING,
|
|
18
22
|
exports.MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -29,12 +33,33 @@ function isXaiVisionModel(model) {
|
|
|
29
33
|
* Check if a model supports the xAI reasoning_effort parameter
|
|
30
34
|
*/
|
|
31
35
|
function isXaiReasoningEffortModel(model) {
|
|
36
|
+
return model === exports.MODEL_GROK_4_5 || model === exports.MODEL_GROK_4_3;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if a model supports disabling reasoning with reasoning_effort none
|
|
40
|
+
*/
|
|
41
|
+
function isXaiReasoningEffortNoneModel(model) {
|
|
32
42
|
return model === exports.MODEL_GROK_4_3;
|
|
33
43
|
}
|
|
34
44
|
/**
|
|
35
45
|
* Get default reasoning effort for xAI models
|
|
36
46
|
*/
|
|
37
47
|
function getDefaultXaiReasoningEffort(model) {
|
|
38
|
-
|
|
48
|
+
if (model === exports.MODEL_GROK_4_5) {
|
|
49
|
+
return 'low';
|
|
50
|
+
}
|
|
51
|
+
return isXaiReasoningEffortNoneModel(model) ? 'none' : undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Normalize xAI reasoning_effort for each model's documented support
|
|
55
|
+
*/
|
|
56
|
+
function normalizeXaiReasoningEffort(model, reasoningEffort) {
|
|
57
|
+
if (!isXaiReasoningEffortModel(model)) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (reasoningEffort === 'none' && !isXaiReasoningEffortNoneModel(model)) {
|
|
61
|
+
return 'low';
|
|
62
|
+
}
|
|
63
|
+
return reasoningEffort ?? getDefaultXaiReasoningEffort(model);
|
|
39
64
|
}
|
|
40
65
|
//# sourceMappingURL=xai.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xai.js","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"xai.js","sourceRoot":"","sources":["../../../src/constants/xai.ts"],"names":[],"mappings":";;;AA0BA,4CAEC;AAKD,8DAEC;AAKD,sEAEC;AAKD,oEAQC;AAKD,kEAaC;AAzEY,QAAA,iCAAiC,GAC5C,sCAAsC,CAAC;AAEzC,kBAAkB;AACL,QAAA,cAAc,GAAG,UAAU,CAAC;AAC5B,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,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,IAAI,KAAK,KAAK,sBAAc,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAgB,6BAA6B,CAAC,KAAa;IACzD,OAAO,KAAK,KAAK,sBAAc,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAC1C,KAAa;IAEb,IAAI,KAAK,KAAK,sBAAc,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CACzC,KAAa,EACb,eAAoC;IAEpC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,eAAe,KAAK,MAAM,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,eAAe,IAAI,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -28,7 +28,7 @@ const REASONING_EFFORT_BY_PROVIDER = {
|
|
|
28
28
|
openrouter: ['none', 'minimal', 'low', 'medium', 'high'],
|
|
29
29
|
mistral: ['low', 'medium', 'high'],
|
|
30
30
|
plamo: ['none', 'medium'],
|
|
31
|
-
xai: ['low', 'high'],
|
|
31
|
+
xai: ['none', 'low', 'medium', 'high'],
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Chat service factory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatServiceFactory.js","sourceRoot":"","sources":["../../../src/services/ChatServiceFactory.ts"],"names":[],"mappings":";;;AAQA,2CAA6D;AAG7D,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAS;IAC/C,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,KAAK;IACL,MAAM;IACN,UAAU;IACV,SAAS;IACT,QAAQ;IACR,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAS;IACpD,QAAQ;IACR,mBAAmB;IACnB,KAAK;IACL,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,4BAA4B,GAA6B;IAC7D,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;IAC7D,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC;IACxD,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;IACzB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatServiceFactory.js","sourceRoot":"","sources":["../../../src/services/ChatServiceFactory.ts"],"names":[],"mappings":";;;AAQA,2CAA6D;AAG7D,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAS;IAC/C,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,KAAK;IACL,MAAM;IACN,UAAU;IACV,SAAS;IACT,QAAQ;IACR,OAAO;CACR,C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,CAClD,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAC9C,CAAC"}
|
|
@@ -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;
|
|
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;AAQpE,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,QAA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_tokens = tokenLimit;
|
|
119
119
|
}
|
|
120
120
|
if (this.reasoningEffort && (0, xai_1.isXaiReasoningEffortModel)(model)) {
|
|
121
|
-
body.reasoning_effort = this.reasoningEffort;
|
|
121
|
+
body.reasoning_effort = (0, xai_1.normalizeXaiReasoningEffort)(model, this.reasoningEffort);
|
|
122
122
|
}
|
|
123
123
|
const tools = this.buildToolsDefinition();
|
|
124
124
|
if (tools.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"XAIChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatService.ts"],"names":[],"mappings":";;;AAGA,gDAMgC;AAEhC,kDAGiC;AACjC,gFAA6E;AAC7E,0CAMwB;AAExB;;GAEG;AACH,MAAa,cAAc;IAYzB;;;;;OAKG;IACH,YACE,MAAc,EACd,QAAgB,uCAAiC,EACjD,cAAsB,uCAAiC,EACvD,KAAwB,EACxB,WAAmB,uCAAiC,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,CA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ACpE,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;AAxOD,wCAwOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAYA,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;IA4B9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAW9B;;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, options.reasoning_effort ?? (0, xai_1.getDefaultXaiReasoningEffort)(model));
|
|
25
|
+
return new XAIChatService_1.XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || xai_1.ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength, (0, xai_1.normalizeXaiReasoningEffort)(model, options.reasoning_effort ?? (0, xai_1.getDefaultXaiReasoningEffort)(model)));
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Get the provider name
|
|
@@ -35,6 +35,7 @@ class XAIChatServiceProvider {
|
|
|
35
35
|
*/
|
|
36
36
|
getSupportedModels() {
|
|
37
37
|
return [
|
|
38
|
+
xai_1.MODEL_GROK_4_5,
|
|
38
39
|
xai_1.MODEL_GROK_4_3,
|
|
39
40
|
xai_1.MODEL_GROK_4_20_REASONING,
|
|
40
41
|
xai_1.MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider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BAAqB,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;AA1FD,wDA0FC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const ENDPOINT_XAI_CHAT_COMPLETIONS_API = "https://api.x.ai/v1/chat/completions";
|
|
2
|
+
export declare const MODEL_GROK_4_5 = "grok-4.5";
|
|
2
3
|
export declare const MODEL_GROK_4_3 = "grok-4.3";
|
|
3
4
|
export declare const MODEL_GROK_4_20_REASONING = "grok-4.20-0309-reasoning";
|
|
4
5
|
export declare const MODEL_GROK_4_20_NON_REASONING = "grok-4.20-0309-non-reasoning";
|
|
@@ -14,8 +15,16 @@ export declare function isXaiVisionModel(model: string): boolean;
|
|
|
14
15
|
* Check if a model supports the xAI reasoning_effort parameter
|
|
15
16
|
*/
|
|
16
17
|
export declare function isXaiReasoningEffortModel(model: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a model supports disabling reasoning with reasoning_effort none
|
|
20
|
+
*/
|
|
21
|
+
export declare function isXaiReasoningEffortNoneModel(model: string): boolean;
|
|
17
22
|
/**
|
|
18
23
|
* Get default reasoning effort for xAI models
|
|
19
24
|
*/
|
|
20
25
|
export declare function getDefaultXaiReasoningEffort(model: string): XaiReasoningEffort | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Normalize xAI reasoning_effort for each model's documented support
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeXaiReasoningEffort(model: string, reasoningEffort?: XaiReasoningEffort): XaiReasoningEffort | undefined;
|
|
21
30
|
//# 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;AAE/E,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAGpE,eAAO,MAAM,2BAA2B,
|
|
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,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,UAOvC,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,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GACZ,kBAAkB,GAAG,SAAS,CAMhC;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,kBAAkB,GACnC,kBAAkB,GAAG,SAAS,CAUhC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const ENDPOINT_XAI_CHAT_COMPLETIONS_API = 'https://api.x.ai/v1/chat/completions';
|
|
2
2
|
// xAI Grok models
|
|
3
|
+
export const MODEL_GROK_4_5 = 'grok-4.5';
|
|
3
4
|
export const MODEL_GROK_4_3 = 'grok-4.3';
|
|
4
5
|
export const MODEL_GROK_4_20_REASONING = 'grok-4.20-0309-reasoning';
|
|
5
6
|
export const MODEL_GROK_4_20_NON_REASONING = 'grok-4.20-0309-non-reasoning';
|
|
@@ -7,6 +8,7 @@ export const MODEL_GROK_4_1_FAST_REASONING = 'grok-4-1-fast-reasoning';
|
|
|
7
8
|
export const MODEL_GROK_4_1_FAST_NON_REASONING = 'grok-4-1-fast-non-reasoning';
|
|
8
9
|
// Vision support for models
|
|
9
10
|
export const XAI_VISION_SUPPORTED_MODELS = [
|
|
11
|
+
MODEL_GROK_4_5,
|
|
10
12
|
MODEL_GROK_4_3,
|
|
11
13
|
MODEL_GROK_4_20_REASONING,
|
|
12
14
|
MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -23,12 +25,33 @@ export function isXaiVisionModel(model) {
|
|
|
23
25
|
* Check if a model supports the xAI reasoning_effort parameter
|
|
24
26
|
*/
|
|
25
27
|
export function isXaiReasoningEffortModel(model) {
|
|
28
|
+
return model === MODEL_GROK_4_5 || model === MODEL_GROK_4_3;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a model supports disabling reasoning with reasoning_effort none
|
|
32
|
+
*/
|
|
33
|
+
export function isXaiReasoningEffortNoneModel(model) {
|
|
26
34
|
return model === MODEL_GROK_4_3;
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
37
|
* Get default reasoning effort for xAI models
|
|
30
38
|
*/
|
|
31
39
|
export function getDefaultXaiReasoningEffort(model) {
|
|
32
|
-
|
|
40
|
+
if (model === MODEL_GROK_4_5) {
|
|
41
|
+
return 'low';
|
|
42
|
+
}
|
|
43
|
+
return isXaiReasoningEffortNoneModel(model) ? 'none' : undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Normalize xAI reasoning_effort for each model's documented support
|
|
47
|
+
*/
|
|
48
|
+
export function normalizeXaiReasoningEffort(model, reasoningEffort) {
|
|
49
|
+
if (!isXaiReasoningEffortModel(model)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (reasoningEffort === 'none' && !isXaiReasoningEffortNoneModel(model)) {
|
|
53
|
+
return 'low';
|
|
54
|
+
}
|
|
55
|
+
return reasoningEffort ?? getDefaultXaiReasoningEffort(model);
|
|
33
56
|
}
|
|
34
57
|
//# 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,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AACpE,MAAM,CAAC,MAAM,6BAA6B,GAAG,8BAA8B,CAAC;AAC5E,MAAM,CAAC,MAAM,6BAA6B,GAAG,yBAAyB,CAAC;AACvE,MAAM,CAAC,MAAM,iCAAiC,GAAG,6BAA6B,CAAC;AAI/E,4BAA4B;AAC5B,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,cAAc;IACd,yBAAyB;IACzB,6BAA6B;IAC7B,6BAA6B;IAC7B,iCAAiC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IA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,IAAI,KAAK,KAAK,cAAc,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAa,EACb,eAAoC;IAEpC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,eAAe,KAAK,MAAM,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,eAAe,IAAI,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -25,7 +25,7 @@ const REASONING_EFFORT_BY_PROVIDER = {
|
|
|
25
25
|
openrouter: ['none', 'minimal', 'low', 'medium', 'high'],
|
|
26
26
|
mistral: ['low', 'medium', 'high'],
|
|
27
27
|
plamo: ['none', 'medium'],
|
|
28
|
-
xai: ['low', 'high'],
|
|
28
|
+
xai: ['none', 'low', 'medium', 'high'],
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Chat service factory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatServiceFactory.js","sourceRoot":"","sources":["../../../src/services/ChatServiceFactory.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAS;IAC/C,QAAQ;IACR,mBAAmB;IACnB,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,KAAK;IACL,MAAM;IACN,UAAU;IACV,SAAS;IACT,QAAQ;IACR,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EA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
{"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;AAQpE,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;IAWtC;;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;IAoCxB,OAAO,CAAC,oBAAoB;YAId,YAAY;IAO1B;;OAEG;YACW,WAAW;IAUzB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENDPOINT_XAI_CHAT_COMPLETIONS_API, MODEL_GROK_4_1_FAST_NON_REASONING, isXaiReasoningEffortModel, isXaiVisionModel, } from '../../../constants/xai';
|
|
1
|
+
import { ENDPOINT_XAI_CHAT_COMPLETIONS_API, MODEL_GROK_4_1_FAST_NON_REASONING, isXaiReasoningEffortModel, isXaiVisionModel, normalizeXaiReasoningEffort, } 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';
|
|
@@ -115,7 +115,7 @@ export class XAIChatService {
|
|
|
115
115
|
body.max_tokens = tokenLimit;
|
|
116
116
|
}
|
|
117
117
|
if (this.reasoningEffort && isXaiReasoningEffortModel(model)) {
|
|
118
|
-
body.reasoning_effort = this.reasoningEffort;
|
|
118
|
+
body.reasoning_effort = normalizeXaiReasoningEffort(model, this.reasoningEffort);
|
|
119
119
|
}
|
|
120
120
|
const tools = this.buildToolsDefinition();
|
|
121
121
|
if (tools.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAChB,2BAA2B,GAC5B,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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2BAA2B,CACjD,KAAK,EACL,IAAI,CAAC,eAAe,CACrB,CAAC;QACJ,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,0BAA0B,CAAC,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACpE,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,GAAa,EAAE,SAA8B;QACtE,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,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":"
|
|
1
|
+
{"version":3,"file":"XAIChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAYA,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;IA4B9D;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAW9B;;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, getDefaultXaiReasoningEffort, isXaiVisionModel, } from '../../../constants/xai';
|
|
1
|
+
import { ENDPOINT_XAI_CHAT_COMPLETIONS_API, MODEL_GROK_4_5, 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, normalizeXaiReasoningEffort, } 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, options.reasoning_effort ?? getDefaultXaiReasoningEffort(model));
|
|
22
|
+
return new XAIChatService(options.apiKey, model, visionModel, tools, options.endpoint || ENDPOINT_XAI_CHAT_COMPLETIONS_API, options.responseLength, normalizeXaiReasoningEffort(model, options.reasoning_effort ?? getDefaultXaiReasoningEffort(model)));
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Get the provider name
|
|
@@ -32,6 +32,7 @@ export class XAIChatServiceProvider {
|
|
|
32
32
|
*/
|
|
33
33
|
getSupportedModels() {
|
|
34
34
|
return [
|
|
35
|
+
MODEL_GROK_4_5,
|
|
35
36
|
MODEL_GROK_4_3,
|
|
36
37
|
MODEL_GROK_4_20_REASONING,
|
|
37
38
|
MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -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,4BAA4B,EAC5B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"XAIChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/xai/XAIChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,OAAO,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;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"}
|
|
@@ -146,6 +146,7 @@ var AITuberOnAirChat = (() => {
|
|
|
146
146
|
MODEL_GROK_4_20_NON_REASONING: () => MODEL_GROK_4_20_NON_REASONING,
|
|
147
147
|
MODEL_GROK_4_20_REASONING: () => MODEL_GROK_4_20_REASONING,
|
|
148
148
|
MODEL_GROK_4_3: () => MODEL_GROK_4_3,
|
|
149
|
+
MODEL_GROK_4_5: () => MODEL_GROK_4_5,
|
|
149
150
|
MODEL_KIMI_K2_5: () => MODEL_KIMI_K2_5,
|
|
150
151
|
MODEL_KIMI_K2_6: () => MODEL_KIMI_K2_6,
|
|
151
152
|
MODEL_KIMI_K2_7_CODE: () => MODEL_KIMI_K2_7_CODE,
|
|
@@ -229,9 +230,11 @@ var AITuberOnAirChat = (() => {
|
|
|
229
230
|
isOpenRouterVisionModel: () => isOpenRouterVisionModel,
|
|
230
231
|
isResponsesOnlyGPT5Model: () => isResponsesOnlyGPT5Model,
|
|
231
232
|
isXaiReasoningEffortModel: () => isXaiReasoningEffortModel,
|
|
233
|
+
isXaiReasoningEffortNoneModel: () => isXaiReasoningEffortNoneModel,
|
|
232
234
|
isXaiVisionModel: () => isXaiVisionModel,
|
|
233
235
|
isZaiToolStreamModel: () => isZaiToolStreamModel,
|
|
234
236
|
isZaiVisionModel: () => isZaiVisionModel,
|
|
237
|
+
normalizeXaiReasoningEffort: () => normalizeXaiReasoningEffort,
|
|
235
238
|
parseOpenAICompatibleOneShot: () => parseOpenAICompatibleOneShot,
|
|
236
239
|
parseOpenAICompatibleTextStream: () => parseOpenAICompatibleTextStream,
|
|
237
240
|
parseOpenAICompatibleToolStream: () => parseOpenAICompatibleToolStream,
|
|
@@ -493,12 +496,14 @@ var AITuberOnAirChat = (() => {
|
|
|
493
496
|
|
|
494
497
|
// src/constants/xai.ts
|
|
495
498
|
var ENDPOINT_XAI_CHAT_COMPLETIONS_API = "https://api.x.ai/v1/chat/completions";
|
|
499
|
+
var MODEL_GROK_4_5 = "grok-4.5";
|
|
496
500
|
var MODEL_GROK_4_3 = "grok-4.3";
|
|
497
501
|
var MODEL_GROK_4_20_REASONING = "grok-4.20-0309-reasoning";
|
|
498
502
|
var MODEL_GROK_4_20_NON_REASONING = "grok-4.20-0309-non-reasoning";
|
|
499
503
|
var MODEL_GROK_4_1_FAST_REASONING = "grok-4-1-fast-reasoning";
|
|
500
504
|
var MODEL_GROK_4_1_FAST_NON_REASONING = "grok-4-1-fast-non-reasoning";
|
|
501
505
|
var XAI_VISION_SUPPORTED_MODELS = [
|
|
506
|
+
MODEL_GROK_4_5,
|
|
502
507
|
MODEL_GROK_4_3,
|
|
503
508
|
MODEL_GROK_4_20_REASONING,
|
|
504
509
|
MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -509,10 +514,25 @@ var AITuberOnAirChat = (() => {
|
|
|
509
514
|
return XAI_VISION_SUPPORTED_MODELS.includes(model);
|
|
510
515
|
}
|
|
511
516
|
function isXaiReasoningEffortModel(model) {
|
|
517
|
+
return model === MODEL_GROK_4_5 || model === MODEL_GROK_4_3;
|
|
518
|
+
}
|
|
519
|
+
function isXaiReasoningEffortNoneModel(model) {
|
|
512
520
|
return model === MODEL_GROK_4_3;
|
|
513
521
|
}
|
|
514
522
|
function getDefaultXaiReasoningEffort(model) {
|
|
515
|
-
|
|
523
|
+
if (model === MODEL_GROK_4_5) {
|
|
524
|
+
return "low";
|
|
525
|
+
}
|
|
526
|
+
return isXaiReasoningEffortNoneModel(model) ? "none" : void 0;
|
|
527
|
+
}
|
|
528
|
+
function normalizeXaiReasoningEffort(model, reasoningEffort) {
|
|
529
|
+
if (!isXaiReasoningEffortModel(model)) {
|
|
530
|
+
return void 0;
|
|
531
|
+
}
|
|
532
|
+
if (reasoningEffort === "none" && !isXaiReasoningEffortNoneModel(model)) {
|
|
533
|
+
return "low";
|
|
534
|
+
}
|
|
535
|
+
return reasoningEffort ?? getDefaultXaiReasoningEffort(model);
|
|
516
536
|
}
|
|
517
537
|
|
|
518
538
|
// src/constants/kimi.ts
|
|
@@ -4795,7 +4815,10 @@ If it's in another language, summarize in that language.
|
|
|
4795
4815
|
body.max_tokens = tokenLimit;
|
|
4796
4816
|
}
|
|
4797
4817
|
if (this.reasoningEffort && isXaiReasoningEffortModel(model)) {
|
|
4798
|
-
body.reasoning_effort =
|
|
4818
|
+
body.reasoning_effort = normalizeXaiReasoningEffort(
|
|
4819
|
+
model,
|
|
4820
|
+
this.reasoningEffort
|
|
4821
|
+
);
|
|
4799
4822
|
}
|
|
4800
4823
|
const tools = this.buildToolsDefinition();
|
|
4801
4824
|
if (tools.length > 0) {
|
|
@@ -4851,7 +4874,10 @@ If it's in another language, summarize in that language.
|
|
|
4851
4874
|
tools,
|
|
4852
4875
|
options.endpoint || ENDPOINT_XAI_CHAT_COMPLETIONS_API,
|
|
4853
4876
|
options.responseLength,
|
|
4854
|
-
|
|
4877
|
+
normalizeXaiReasoningEffort(
|
|
4878
|
+
model,
|
|
4879
|
+
options.reasoning_effort ?? getDefaultXaiReasoningEffort(model)
|
|
4880
|
+
)
|
|
4855
4881
|
);
|
|
4856
4882
|
}
|
|
4857
4883
|
/**
|
|
@@ -4865,6 +4891,7 @@ If it's in another language, summarize in that language.
|
|
|
4865
4891
|
*/
|
|
4866
4892
|
getSupportedModels() {
|
|
4867
4893
|
return [
|
|
4894
|
+
MODEL_GROK_4_5,
|
|
4868
4895
|
MODEL_GROK_4_3,
|
|
4869
4896
|
MODEL_GROK_4_20_REASONING,
|
|
4870
4897
|
MODEL_GROK_4_20_NON_REASONING,
|
|
@@ -5187,7 +5214,7 @@ If it's in another language, summarize in that language.
|
|
|
5187
5214
|
openrouter: ["none", "minimal", "low", "medium", "high"],
|
|
5188
5215
|
mistral: ["low", "medium", "high"],
|
|
5189
5216
|
plamo: ["none", "medium"],
|
|
5190
|
-
xai: ["low", "high"]
|
|
5217
|
+
xai: ["none", "low", "medium", "high"]
|
|
5191
5218
|
};
|
|
5192
5219
|
var ChatServiceFactory = class {
|
|
5193
5220
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var AITuberOnAirChat=(()=>{var no=Object.defineProperty;var zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var jr=Object.prototype.hasOwnProperty;var Jr=(r,e)=>{for(var t in e)no(r,t,{get:e[t],enumerable:!0})},Xr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qr(e))!jr.call(r,i)&&i!==t&&no(r,i,{get:()=>e[i],enumerable:!(o=zr(e,i))||o.enumerable});return r};var Zr=r=>Xr(no({},"__esModule",{value:!0}),r);var Ki={};Jr(Ki,{CHAT_RESPONSE_LENGTH:()=>T,CLAUDE_VISION_SUPPORTED_MODELS:()=>Be,ChatServiceFactory:()=>ke,ChatServiceHttpClient:()=>f,ClaudeChatService:()=>me,ClaudeChatServiceProvider:()=>de,DEEPSEEK_API_BASE_URL:()=>pr,DEEPSEEK_DEPRECATED_MODELS:()=>ii,DEEPSEEK_SUPPORTED_MODELS:()=>xo,DEFAULT_MAX_TOKENS:()=>Fo,DEFAULT_SUMMARY_PROMPT_TEMPLATE:()=>si,DEFAULT_VISION_PROMPT:()=>ni,DeepSeekChatService:()=>ge,DeepSeekChatServiceProvider:()=>_e,EMOTION_TAG_CLEANUP_REGEX:()=>Ho,EMOTION_TAG_REGEX:()=>Er,ENDPOINT_CLAUDE_API:()=>ho,ENDPOINT_DEEPSEEK_CHAT_COMPLETIONS_API:()=>Ze,ENDPOINT_GEMINI_API:()=>uo,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:()=>We,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:()=>rr,GEMINI_NANO_MAX_CONTEXT_MESSAGES:()=>Ko,GEMINI_RECOMMENDED_MODELS:()=>pt,GEMINI_VISION_SUPPORTED_MODELS:()=>He,GPT5_PRESETS:()=>Uo,GPT_5_MODELS:()=>zo,GeminiChatService:()=>fe,GeminiChatServiceProvider:()=>Me,GeminiNanoChatService:()=>ve,GeminiNanoChatServiceProvider:()=>Oe,HttpError:()=>F,KIMI_THINKING_REQUIRED_MODELS:()=>lr,KIMI_VISION_SUPPORTED_MODELS:()=>ar,KimiChatService:()=>Ee,KimiChatServiceProvider:()=>Se,MAX_TOKENS_BY_LENGTH:()=>eo,MISTRAL_API_BASE_URL:()=>mr,MISTRAL_REASONING_EFFORT_SUPPORTED_MODELS:()=>dr,MISTRAL_SUPPORTED_MODELS:()=>No,MISTRAL_VISION_SUPPORTED_MODELS:()=>gr,MODEL_ANTHROPIC_CLAUDE_3_5_SONNET:()=>_o,MODEL_ANTHROPIC_CLAUDE_3_7_SONNET:()=>Gt,MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU:()=>Ft,MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST:()=>wt,MODEL_ANTHROPIC_CLAUDE_OPUS_4:()=>Vt,MODEL_ANTHROPIC_CLAUDE_SONNET_4:()=>kt,MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST:()=>Nt,MODEL_CLAUDE_3_5_HAIKU:()=>Yr,MODEL_CLAUDE_3_5_SONNET:()=>Qr,MODEL_CLAUDE_3_7_SONNET:()=>ei,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_CLAUDE_5_SONNET:()=>vt,MODEL_DEEPSEEK_CHAT:()=>ur,MODEL_DEEPSEEK_REASONER:()=>hr,MODEL_DEEPSEEK_V4_FLASH:()=>pe,MODEL_DEEPSEEK_V4_PRO:()=>cr,MODEL_FUGU:()=>ce,MODEL_FUGU_ULTRA:()=>fr,MODEL_FUGU_ULTRA_20260615:()=>Mr,MODEL_GEMINI_2_5_FLASH:()=>er,MODEL_GEMINI_2_5_FLASH_LITE:()=>tr,MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17:()=>or,MODEL_GEMINI_2_5_PRO:()=>Qo,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:()=>Yo,MODEL_GEMINI_3_PRO_PREVIEW:()=>Zo,MODEL_GEMINI_NANO:()=>Z,MODEL_GEMMA_4_26B_A4B_IT:()=>jo,MODEL_GEMMA_4_31B_IT:()=>qo,MODEL_GLM_4_6:()=>Lo,MODEL_GLM_4_6V:()=>zt,MODEL_GLM_4_6V_FLASH:()=>X,MODEL_GLM_4_6V_FLASHX:()=>qt,MODEL_GLM_4_7:()=>Co,MODEL_GLM_4_7_FLASH:()=>Po,MODEL_GLM_4_7_FLASHX:()=>To,MODEL_GLM_5:()=>Eo,MODEL_GLM_5_2:()=>ie,MODEL_GLM_5_TURBO:()=>So,MODEL_GOOGLE_GEMINI_2_5_FLASH:()=>Bt,MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:()=>Wt,MODEL_GOOGLE_GEMINI_2_5_PRO:()=>Ht,MODEL_GOOGLE_GEMINI_FLASH_LATEST:()=>Kt,MODEL_GOOGLE_GEMINI_PRO_LATEST:()=>Ut,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:()=>W,MODEL_GPT_5_4_NANO:()=>$,MODEL_GPT_5_4_PRO:()=>G,MODEL_GPT_5_5:()=>B,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:()=>jt,MODEL_GROK_4_3:()=>qe,MODEL_KIMI_K2_5:()=>Yt,MODEL_KIMI_K2_6:()=>w,MODEL_KIMI_K2_7_CODE:()=>je,MODEL_KIMI_K2_7_CODE_HIGHSPEED:()=>Je,MODEL_MISTRAL_LARGE_2512:()=>bo,MODEL_MISTRAL_LARGE_LATEST:()=>Ro,MODEL_MISTRAL_MEDIUM_2508:()=>Ao,MODEL_MISTRAL_MEDIUM_3_5:()=>Qt,MODEL_MISTRAL_SMALL_2603:()=>Do,MODEL_MISTRAL_SMALL_LATEST:()=>V,MODEL_MOONSHOTAI_KIMI_K2_5:()=>Et,MODEL_MOONSHOTAI_KIMI_K2_7_CODE:()=>Ot,MODEL_MOONSHOTAI_KIMI_LATEST:()=>St,MODEL_O1:()=>lo,MODEL_O1_MINI:()=>ao,MODEL_O3_MINI:()=>so,MODEL_OPENAI_GPT_4O:()=>At,MODEL_OPENAI_GPT_4_1_MINI:()=>Rt,MODEL_OPENAI_GPT_4_1_NANO:()=>bt,MODEL_OPENAI_GPT_5_1_CHAT:()=>yt,MODEL_OPENAI_GPT_5_1_CODEX:()=>It,MODEL_OPENAI_GPT_5_5:()=>Lt,MODEL_OPENAI_GPT_5_5_PRO:()=>Pt,MODEL_OPENAI_GPT_5_MINI:()=>xt,MODEL_OPENAI_GPT_5_NANO:()=>Dt,MODEL_OPENAI_GPT_LATEST:()=>Ct,MODEL_OPENAI_GPT_MINI_LATEST:()=>Tt,MODEL_OPENROUTER_AUTO:()=>mo,MODEL_OPENROUTER_FUSION:()=>go,MODEL_PLAMO_2_2_PRIME:()=>Or,MODEL_PLAMO_3_0_PRIME:()=>ue,MODEL_ZAI_GLM_4_5_AIR:()=>Mo,MODEL_ZAI_GLM_4_5_AIR_FREE:()=>$t,MODEL_ZAI_GLM_4_7_FLASH:()=>fo,MODEL_ZAI_GLM_5_2:()=>oe,MistralChatService:()=>Ce,MistralChatServiceProvider:()=>Te,OPENROUTER_CREDITS_THRESHOLD:()=>ri,OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS:()=>oi,OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS:()=>ti,OPENROUTER_FREE_MODELS:()=>vo,OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE:()=>Oo,OPENROUTER_VISION_SUPPORTED_MODELS:()=>ir,OpenAIChatService:()=>C,OpenAIChatServiceProvider:()=>Le,OpenAICompatibleChatServiceProvider:()=>Pe,OpenRouterChatService:()=>ye,OpenRouterChatServiceProvider:()=>Ie,PLAMO_API_BASE_URL:()=>vr,PLAMO_SUPPORTED_MODELS:()=>Go,PlamoChatService:()=>xe,PlamoChatServiceProvider:()=>De,SAKANA_API_BASE_URL:()=>_r,SAKANA_SUPPORTED_MODELS:()=>ko,SakanaChatService:()=>Ae,SakanaChatServiceProvider:()=>Re,StreamTextAccumulator:()=>v,VISION_SUPPORTED_MODELS:()=>Ge,XAIChatService:()=>be,XAIChatServiceProvider:()=>Ne,XAI_VISION_SUPPORTED_MODELS:()=>sr,ZAIChatService:()=>we,ZAIChatServiceProvider:()=>Ve,ZAI_VISION_SUPPORTED_MODELS:()=>nr,allowsReasoningLow:()=>at,allowsReasoningMinimal:()=>Ue,allowsReasoningNone:()=>Fe,allowsReasoningXHigh:()=>co,buildOpenAICompatibleTools:()=>x,getDefaultReasoningEffortForGPT5Model:()=>Ke,getDefaultXaiReasoningEffort:()=>Io,getMaxTokensForResponseLength:()=>S,installGASFetch:()=>Wr,isGPT5Model:()=>q,isKimiThinkingRequiredModel:()=>Xe,isKimiVisionModel:()=>le,isMistralReasoningEffort:()=>wo,isMistralReasoningEffortModel:()=>Qe,isMistralVisionModel:()=>Vo,isOpenRouterFreeModel:()=>J,isOpenRouterVisionModel:()=>re,isResponsesOnlyGPT5Model:()=>po,isXaiReasoningEffortModel:()=>Zt,isXaiVisionModel:()=>se,isZaiToolStreamModel:()=>yo,isZaiVisionModel:()=>ne,parseOpenAICompatibleOneShot:()=>I,parseOpenAICompatibleTextStream:()=>L,parseOpenAICompatibleToolStream:()=>y,processChatWithOptionalTools:()=>M,refreshOpenRouterFreeModels:()=>Oi,resolveVisionModel:()=>E,runOnceText:()=>ci,safeJsonParse:()=>Cr,safeParseToolCallInput:()=>Y,screenplayToText:()=>pi,textToScreenplay:()=>Sr,textsToScreenplay:()=>li});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",B="gpt-5.5",W="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",so="o3-mini",ao="o1-mini",lo="o1",Ge=[K,Q,ee,te,H,B,W,$,G,rt,it,nt,z,st,"o1"],zo=[K,Q,ee,te,H,B,W,$,G];function q(r){return zo.includes(r)}function po(r){return r===G}function co(r){return r===B||r===H||r===W||r===$||r===G}function Fe(r){return r===te||r===H||r===B||r===W||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 uo="https://generativelanguage.googleapis.com",qo="gemma-4-31b-it",jo="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",Zo="gemini-3-pro-preview",Yo="gemini-3-flash-preview",Qo="gemini-2.5-pro",er="gemini-2.5-flash",tr="gemini-2.5-flash-lite",or="gemini-2.5-flash-lite-preview-06-17",pt=[lt,j,Jo,Yo,Qo,er,tr,qo,jo],rr=[Xo,Zo,or],He=[...pt,...rr];var ho="https://api.anthropic.com/v1/messages",ct="claude-3-haiku-20240307",Yr="claude-3-5-haiku-20241022",Qr="claude-3-5-sonnet-20241022",ei="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",vt="claude-sonnet-5",Be=[ct,ut,ht,mt,R,dt,gt,_t,ft,Mt,vt];var We="https://openrouter.ai/api/v1/chat/completions",mo="openrouter/auto",go="openrouter/fusion",b="openai/gpt-oss-20b:free",Ot="moonshotai/kimi-k2.7-code",Et="moonshotai/kimi-k2.5",St="~moonshotai/kimi-latest",Ct="~openai/gpt-latest",Tt="~openai/gpt-mini-latest",Pt="openai/gpt-5.5-pro",Lt="openai/gpt-5.5",yt="openai/gpt-5.1-chat",It="openai/gpt-5.1-codex",xt="openai/gpt-5-mini",Dt="openai/gpt-5-nano",At="openai/gpt-4o",Rt="openai/gpt-4.1-mini",bt="openai/gpt-4.1-nano",Nt="~anthropic/claude-sonnet-latest",wt="~anthropic/claude-haiku-latest",Vt="anthropic/claude-opus-4",kt="anthropic/claude-sonnet-4",Gt="anthropic/claude-3.7-sonnet",_o="anthropic/claude-3.5-sonnet",Ft="anthropic/claude-haiku-4.5",Ut="~google/gemini-pro-latest",Kt="~google/gemini-flash-latest",Ht="google/gemini-2.5-pro",Bt="google/gemini-2.5-flash",Wt="google/gemini-2.5-flash-lite-preview-09-2025",oe="z-ai/glm-5.2",fo="z-ai/glm-4.7-flash",Mo="z-ai/glm-4.5-air",$t="z-ai/glm-4.5-air:free",vo=[b,$t],ir=[St,Ct,Tt,Pt,Lt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,Ft,Ut,Kt,Ht,Bt,Wt,Ot,Et],Oo=20,ti=50,oi=1e3,ri=10;function J(r){return r.trim().endsWith(":free")}function re(r){return ir.some(e=>r.includes(e))}var $e="https://api.z.ai/api/paas/v4/chat/completions",ie="glm-5.2",Eo="glm-5",So="glm-5-turbo",Co="glm-4.7",To="glm-4.7-FlashX",Po="glm-4.7-Flash",Lo="glm-4.6",zt="glm-4.6V",qt="glm-4.6V-FlashX",X="glm-4.6V-Flash",nr=[zt,qt,X];function ne(r){return nr.includes(r)}function yo(r){return r.toLowerCase().startsWith("glm-4.6")}var ze="https://api.x.ai/v1/chat/completions",qe="grok-4.3",jt="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",sr=[qe,jt,Jt,Xt,N];function se(r){return sr.includes(r)}function Zt(r){return r===qe}function Io(r){return Zt(r)?"none":void 0}var ae="https://api.moonshot.ai/v1/chat/completions",je="kimi-k2.7-code",Je="kimi-k2.7-code-highspeed",w="kimi-k2.6",Yt="kimi-k2.5",ar=[je,Je,w,Yt],lr=[je,Je];function le(r){return ar.includes(r)}function Xe(r){return lr.includes(r)}var pr="https://api.deepseek.com",Ze=`${pr}/chat/completions`,pe="deepseek-v4-flash",cr="deepseek-v4-pro",ur="deepseek-chat",hr="deepseek-reasoner",xo=[pe,cr],ii=[ur,hr];var mr="https://api.mistral.ai/v1",Ye=`${mr}/chat/completions`,V="mistral-small-latest",Do="mistral-small-2603",Qt="mistral-medium-3-5",Ao="mistral-medium-2508",Ro="mistral-large-latest",bo="mistral-large-2512",No=[V,Qt,Ro,bo,Do,Ao],dr=[V,Qt],gr=[V,Do,Qt,Ao,Ro,bo];function Qe(r){return dr.includes(r)}function wo(r){return r==="none"||r==="high"}function Vo(r){return gr.includes(r)}var _r="https://api.sakana.ai/v1",et=`${_r}/chat/completions`,ce="fugu",fr="fugu-ultra",Mr="fugu-ultra-20260615",ko=[ce,fr,Mr];var vr="https://api.platform.preferredai.jp/v1",tt=`${vr}/chat/completions`,ue="plamo-3.0-prime",Or="plamo-2.2-prime",Go=[ue,Or];var T={VERY_SHORT:"veryShort",SHORT:"short",MEDIUM:"medium",LONG:"long",VERY_LONG:"veryLong",DEEP:"deep"},eo={[T.VERY_SHORT]:40,[T.SHORT]:100,[T.MEDIUM]:200,[T.LONG]:300,[T.VERY_LONG]:1e3,[T.DEEP]:5e3},Fo=5e3,Uo={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 S(r){return r?eo[r]??Fo:Fo}var ni="You are a friendly AI avatar. Comment on the situation based on the broadcast screen.",si=`You are a skilled summarizing assistant.
|
|
1
|
+
"use strict";var AITuberOnAirChat=(()=>{var lo=Object.defineProperty;var Xr=Object.getOwnPropertyDescriptor;var Jr=Object.getOwnPropertyNames;var Zr=Object.prototype.hasOwnProperty;var Yr=(r,e)=>{for(var t in e)lo(r,t,{get:e[t],enumerable:!0})},Qr=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jr(e))!Zr.call(r,i)&&i!==t&&lo(r,i,{get:()=>e[i],enumerable:!(o=Xr(e,i))||o.enumerable});return r};var ei=r=>Qr(lo({},"__esModule",{value:!0}),r);var Wi={};Yr(Wi,{CHAT_RESPONSE_LENGTH:()=>T,CLAUDE_VISION_SUPPORTED_MODELS:()=>ze,ChatServiceFactory:()=>Fe,ChatServiceHttpClient:()=>f,ClaudeChatService:()=>ge,ClaudeChatServiceProvider:()=>_e,DEEPSEEK_API_BASE_URL:()=>hr,DEEPSEEK_DEPRECATED_MODELS:()=>ai,DEEPSEEK_SUPPORTED_MODELS:()=>Ro,DEFAULT_MAX_TOKENS:()=>Ho,DEFAULT_SUMMARY_PROMPT_TEMPLATE:()=>pi,DEFAULT_VISION_PROMPT:()=>li,DeepSeekChatService:()=>fe,DeepSeekChatServiceProvider:()=>Me,EMOTION_TAG_CLEANUP_REGEX:()=>zo,EMOTION_TAG_REGEX:()=>Tr,ENDPOINT_CLAUDE_API:()=>_o,ENDPOINT_DEEPSEEK_CHAT_COMPLETIONS_API:()=>Qe,ENDPOINT_GEMINI_API:()=>go,ENDPOINT_KIMI_CHAT_COMPLETIONS_API:()=>pe,ENDPOINT_MISTRAL_CHAT_COMPLETIONS_API:()=>et,ENDPOINT_OPENAI_CHAT_COMPLETIONS_API:()=>U,ENDPOINT_OPENAI_RESPONSES_API:()=>A,ENDPOINT_OPENROUTER_API:()=>$e,ENDPOINT_PLAMO_CHAT_COMPLETIONS_API:()=>rt,ENDPOINT_SAKANA_CHAT_COMPLETIONS_API:()=>ot,ENDPOINT_XAI_CHAT_COMPLETIONS_API:()=>je,ENDPOINT_ZAI_CHAT_COMPLETIONS_API:()=>qe,EmotionParser:()=>de,GEMINI_DEPRECATED_MODELS:()=>sr,GEMINI_NANO_MAX_CONTEXT_MESSAGES:()=>Wo,GEMINI_RECOMMENDED_MODELS:()=>ut,GEMINI_VISION_SUPPORTED_MODELS:()=>We,GPT5_PRESETS:()=>Bo,GPT_5_MODELS:()=>Xo,GeminiChatService:()=>ve,GeminiChatServiceProvider:()=>Oe,GeminiNanoChatService:()=>Ee,GeminiNanoChatServiceProvider:()=>Se,HttpError:()=>F,KIMI_THINKING_REQUIRED_MODELS:()=>ur,KIMI_VISION_SUPPORTED_MODELS:()=>cr,KimiChatService:()=>Ce,KimiChatServiceProvider:()=>Te,MAX_TOKENS_BY_LENGTH:()=>ro,MISTRAL_API_BASE_URL:()=>_r,MISTRAL_REASONING_EFFORT_SUPPORTED_MODELS:()=>fr,MISTRAL_SUPPORTED_MODELS:()=>ko,MISTRAL_VISION_SUPPORTED_MODELS:()=>Mr,MODEL_ANTHROPIC_CLAUDE_3_5_SONNET:()=>vo,MODEL_ANTHROPIC_CLAUDE_3_7_SONNET:()=>Ut,MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU:()=>Kt,MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST:()=>kt,MODEL_ANTHROPIC_CLAUDE_OPUS_4:()=>Gt,MODEL_ANTHROPIC_CLAUDE_SONNET_4:()=>Ft,MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST:()=>Vt,MODEL_CLAUDE_3_5_HAIKU:()=>ti,MODEL_CLAUDE_3_5_SONNET:()=>oi,MODEL_CLAUDE_3_7_SONNET:()=>ri,MODEL_CLAUDE_3_HAIKU:()=>ht,MODEL_CLAUDE_4_5_HAIKU:()=>R,MODEL_CLAUDE_4_5_OPUS:()=>_t,MODEL_CLAUDE_4_5_SONNET:()=>gt,MODEL_CLAUDE_4_6_OPUS:()=>Mt,MODEL_CLAUDE_4_6_SONNET:()=>ft,MODEL_CLAUDE_4_7_OPUS:()=>vt,MODEL_CLAUDE_4_8_OPUS:()=>Ot,MODEL_CLAUDE_4_OPUS:()=>dt,MODEL_CLAUDE_4_SONNET:()=>mt,MODEL_CLAUDE_5_SONNET:()=>Et,MODEL_DEEPSEEK_CHAT:()=>dr,MODEL_DEEPSEEK_REASONER:()=>gr,MODEL_DEEPSEEK_V4_FLASH:()=>ue,MODEL_DEEPSEEK_V4_PRO:()=>mr,MODEL_FUGU:()=>he,MODEL_FUGU_ULTRA:()=>Or,MODEL_FUGU_ULTRA_20260615:()=>Er,MODEL_GEMINI_2_5_FLASH:()=>rr,MODEL_GEMINI_2_5_FLASH_LITE:()=>ir,MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17:()=>nr,MODEL_GEMINI_2_5_PRO:()=>or,MODEL_GEMINI_3_1_FLASH_LITE:()=>j,MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW:()=>Qo,MODEL_GEMINI_3_1_PRO_PREVIEW:()=>Yo,MODEL_GEMINI_3_5_FLASH:()=>ct,MODEL_GEMINI_3_FLASH_PREVIEW:()=>tr,MODEL_GEMINI_3_PRO_PREVIEW:()=>er,MODEL_GEMINI_NANO:()=>Z,MODEL_GEMMA_4_26B_A4B_IT:()=>Zo,MODEL_GEMMA_4_31B_IT:()=>Jo,MODEL_GLM_4_6:()=>xo,MODEL_GLM_4_6V:()=>jt,MODEL_GLM_4_6V_FLASH:()=>J,MODEL_GLM_4_6V_FLASHX:()=>Xt,MODEL_GLM_4_7:()=>Lo,MODEL_GLM_4_7_FLASH:()=>Io,MODEL_GLM_4_7_FLASHX:()=>yo,MODEL_GLM_5:()=>To,MODEL_GLM_5_2:()=>ie,MODEL_GLM_5_TURBO:()=>Po,MODEL_GOOGLE_GEMINI_2_5_FLASH:()=>zt,MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:()=>$t,MODEL_GOOGLE_GEMINI_2_5_PRO:()=>Wt,MODEL_GOOGLE_GEMINI_FLASH_LATEST:()=>Bt,MODEL_GOOGLE_GEMINI_PRO_LATEST:()=>Ht,MODEL_GPT_4O:()=>lt,MODEL_GPT_4O_MINI:()=>$,MODEL_GPT_4_1:()=>nt,MODEL_GPT_4_1_MINI:()=>st,MODEL_GPT_4_1_NANO:()=>at,MODEL_GPT_5:()=>ee,MODEL_GPT_5_1:()=>te,MODEL_GPT_5_4:()=>H,MODEL_GPT_5_4_MINI:()=>W,MODEL_GPT_5_4_NANO:()=>z,MODEL_GPT_5_4_PRO:()=>G,MODEL_GPT_5_5:()=>B,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:()=>Yt,MODEL_GROK_4_20_NON_REASONING:()=>Zt,MODEL_GROK_4_20_REASONING:()=>Jt,MODEL_GROK_4_3:()=>ae,MODEL_GROK_4_5:()=>se,MODEL_KIMI_K2_5:()=>to,MODEL_KIMI_K2_6:()=>w,MODEL_KIMI_K2_7_CODE:()=>Je,MODEL_KIMI_K2_7_CODE_HIGHSPEED:()=>Ze,MODEL_MISTRAL_LARGE_2512:()=>Vo,MODEL_MISTRAL_LARGE_LATEST:()=>wo,MODEL_MISTRAL_MEDIUM_2508:()=>No,MODEL_MISTRAL_MEDIUM_3_5:()=>oo,MODEL_MISTRAL_SMALL_2603:()=>bo,MODEL_MISTRAL_SMALL_LATEST:()=>V,MODEL_MOONSHOTAI_KIMI_K2_5:()=>Ct,MODEL_MOONSHOTAI_KIMI_K2_7_CODE:()=>St,MODEL_MOONSHOTAI_KIMI_LATEST:()=>Tt,MODEL_O1:()=>uo,MODEL_O1_MINI:()=>co,MODEL_O3_MINI:()=>po,MODEL_OPENAI_GPT_4O:()=>bt,MODEL_OPENAI_GPT_4_1_MINI:()=>Nt,MODEL_OPENAI_GPT_4_1_NANO:()=>wt,MODEL_OPENAI_GPT_5_1_CHAT:()=>xt,MODEL_OPENAI_GPT_5_1_CODEX:()=>Dt,MODEL_OPENAI_GPT_5_5:()=>It,MODEL_OPENAI_GPT_5_5_PRO:()=>yt,MODEL_OPENAI_GPT_5_MINI:()=>At,MODEL_OPENAI_GPT_5_NANO:()=>Rt,MODEL_OPENAI_GPT_LATEST:()=>Pt,MODEL_OPENAI_GPT_MINI_LATEST:()=>Lt,MODEL_OPENROUTER_AUTO:()=>fo,MODEL_OPENROUTER_FUSION:()=>Mo,MODEL_PLAMO_2_2_PRIME:()=>Cr,MODEL_PLAMO_3_0_PRIME:()=>me,MODEL_ZAI_GLM_4_5_AIR:()=>Eo,MODEL_ZAI_GLM_4_5_AIR_FREE:()=>qt,MODEL_ZAI_GLM_4_7_FLASH:()=>Oo,MODEL_ZAI_GLM_5_2:()=>oe,MistralChatService:()=>Pe,MistralChatServiceProvider:()=>Le,OPENROUTER_CREDITS_THRESHOLD:()=>si,OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS:()=>ni,OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS:()=>ii,OPENROUTER_FREE_MODELS:()=>So,OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE:()=>Co,OPENROUTER_VISION_SUPPORTED_MODELS:()=>ar,OpenAIChatService:()=>C,OpenAIChatServiceProvider:()=>Ie,OpenAICompatibleChatServiceProvider:()=>ye,OpenRouterChatService:()=>xe,OpenRouterChatServiceProvider:()=>De,PLAMO_API_BASE_URL:()=>Sr,PLAMO_SUPPORTED_MODELS:()=>Ko,PlamoChatService:()=>Ae,PlamoChatServiceProvider:()=>Re,SAKANA_API_BASE_URL:()=>vr,SAKANA_SUPPORTED_MODELS:()=>Uo,SakanaChatService:()=>be,SakanaChatServiceProvider:()=>Ne,StreamTextAccumulator:()=>v,VISION_SUPPORTED_MODELS:()=>Ue,XAIChatService:()=>we,XAIChatServiceProvider:()=>Ve,XAI_VISION_SUPPORTED_MODELS:()=>pr,ZAIChatService:()=>ke,ZAIChatServiceProvider:()=>Ge,ZAI_VISION_SUPPORTED_MODELS:()=>lr,allowsReasoningLow:()=>pt,allowsReasoningMinimal:()=>He,allowsReasoningNone:()=>Ke,allowsReasoningXHigh:()=>mo,buildOpenAICompatibleTools:()=>x,getDefaultReasoningEffortForGPT5Model:()=>Be,getDefaultXaiReasoningEffort:()=>eo,getMaxTokensForResponseLength:()=>S,installGASFetch:()=>qr,isGPT5Model:()=>q,isKimiThinkingRequiredModel:()=>Ye,isKimiVisionModel:()=>ce,isMistralReasoningEffort:()=>Go,isMistralReasoningEffortModel:()=>tt,isMistralVisionModel:()=>Fo,isOpenRouterFreeModel:()=>X,isOpenRouterVisionModel:()=>re,isResponsesOnlyGPT5Model:()=>ho,isXaiReasoningEffortModel:()=>Qt,isXaiReasoningEffortNoneModel:()=>Ao,isXaiVisionModel:()=>le,isZaiToolStreamModel:()=>Do,isZaiVisionModel:()=>ne,normalizeXaiReasoningEffort:()=>Xe,parseOpenAICompatibleOneShot:()=>I,parseOpenAICompatibleTextStream:()=>L,parseOpenAICompatibleToolStream:()=>y,processChatWithOptionalTools:()=>M,refreshOpenRouterFreeModels:()=>Ci,resolveVisionModel:()=>E,runOnceText:()=>mi,safeJsonParse:()=>Lr,safeParseToolCallInput:()=>Y,screenplayToText:()=>hi,textToScreenplay:()=>Pr,textsToScreenplay:()=>ui});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",B="gpt-5.5",W="gpt-5.4-mini",z="gpt-5.4-nano",G="gpt-5.4-pro",nt="gpt-4.1",st="gpt-4.1-mini",at="gpt-4.1-nano",$="gpt-4o-mini",lt="gpt-4o",po="o3-mini",co="o1-mini",uo="o1",Ue=[K,Q,ee,te,H,B,W,z,G,nt,st,at,$,lt,"o1"],Xo=[K,Q,ee,te,H,B,W,z,G];function q(r){return Xo.includes(r)}function ho(r){return r===G}function mo(r){return r===B||r===H||r===W||r===z||r===G}function Ke(r){return r===te||r===H||r===B||r===W||r===z}function He(r){return r===K||r===Q||r===ee}function pt(r){return r!==G}function Be(r){return Ke(r)?"none":He(r)?"minimal":"medium"}var go="https://generativelanguage.googleapis.com",Jo="gemma-4-31b-it",Zo="gemma-4-26b-a4b-it",ct="gemini-3.5-flash",Yo="gemini-3.1-pro-preview",j="gemini-3.1-flash-lite",Qo="gemini-3.1-flash-lite-preview",er="gemini-3-pro-preview",tr="gemini-3-flash-preview",or="gemini-2.5-pro",rr="gemini-2.5-flash",ir="gemini-2.5-flash-lite",nr="gemini-2.5-flash-lite-preview-06-17",ut=[ct,j,Yo,tr,or,rr,ir,Jo,Zo],sr=[Qo,er,nr],We=[...ut,...sr];var _o="https://api.anthropic.com/v1/messages",ht="claude-3-haiku-20240307",ti="claude-3-5-haiku-20241022",oi="claude-3-5-sonnet-20241022",ri="claude-3-7-sonnet-20250219",mt="claude-sonnet-4-20250514",dt="claude-opus-4-20250514",gt="claude-sonnet-4-5-20250929",R="claude-haiku-4-5-20251001",_t="claude-opus-4-5-20251101",ft="claude-sonnet-4-6",Mt="claude-opus-4-6",vt="claude-opus-4-7",Ot="claude-opus-4-8",Et="claude-sonnet-5",ze=[ht,mt,dt,gt,R,_t,ft,Mt,vt,Ot,Et];var $e="https://openrouter.ai/api/v1/chat/completions",fo="openrouter/auto",Mo="openrouter/fusion",b="openai/gpt-oss-20b:free",St="moonshotai/kimi-k2.7-code",Ct="moonshotai/kimi-k2.5",Tt="~moonshotai/kimi-latest",Pt="~openai/gpt-latest",Lt="~openai/gpt-mini-latest",yt="openai/gpt-5.5-pro",It="openai/gpt-5.5",xt="openai/gpt-5.1-chat",Dt="openai/gpt-5.1-codex",At="openai/gpt-5-mini",Rt="openai/gpt-5-nano",bt="openai/gpt-4o",Nt="openai/gpt-4.1-mini",wt="openai/gpt-4.1-nano",Vt="~anthropic/claude-sonnet-latest",kt="~anthropic/claude-haiku-latest",Gt="anthropic/claude-opus-4",Ft="anthropic/claude-sonnet-4",Ut="anthropic/claude-3.7-sonnet",vo="anthropic/claude-3.5-sonnet",Kt="anthropic/claude-haiku-4.5",Ht="~google/gemini-pro-latest",Bt="~google/gemini-flash-latest",Wt="google/gemini-2.5-pro",zt="google/gemini-2.5-flash",$t="google/gemini-2.5-flash-lite-preview-09-2025",oe="z-ai/glm-5.2",Oo="z-ai/glm-4.7-flash",Eo="z-ai/glm-4.5-air",qt="z-ai/glm-4.5-air:free",So=[b,qt],ar=[Tt,Pt,Lt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,Ft,Ut,Kt,Ht,Bt,Wt,zt,$t,St,Ct],Co=20,ii=50,ni=1e3,si=10;function X(r){return r.trim().endsWith(":free")}function re(r){return ar.some(e=>r.includes(e))}var qe="https://api.z.ai/api/paas/v4/chat/completions",ie="glm-5.2",To="glm-5",Po="glm-5-turbo",Lo="glm-4.7",yo="glm-4.7-FlashX",Io="glm-4.7-Flash",xo="glm-4.6",jt="glm-4.6V",Xt="glm-4.6V-FlashX",J="glm-4.6V-Flash",lr=[jt,Xt,J];function ne(r){return lr.includes(r)}function Do(r){return r.toLowerCase().startsWith("glm-4.6")}var je="https://api.x.ai/v1/chat/completions",se="grok-4.5",ae="grok-4.3",Jt="grok-4.20-0309-reasoning",Zt="grok-4.20-0309-non-reasoning",Yt="grok-4-1-fast-reasoning",N="grok-4-1-fast-non-reasoning",pr=[se,ae,Jt,Zt,Yt,N];function le(r){return pr.includes(r)}function Qt(r){return r===se||r===ae}function Ao(r){return r===ae}function eo(r){return r===se?"low":Ao(r)?"none":void 0}function Xe(r,e){if(Qt(r))return e==="none"&&!Ao(r)?"low":e??eo(r)}var pe="https://api.moonshot.ai/v1/chat/completions",Je="kimi-k2.7-code",Ze="kimi-k2.7-code-highspeed",w="kimi-k2.6",to="kimi-k2.5",cr=[Je,Ze,w,to],ur=[Je,Ze];function ce(r){return cr.includes(r)}function Ye(r){return ur.includes(r)}var hr="https://api.deepseek.com",Qe=`${hr}/chat/completions`,ue="deepseek-v4-flash",mr="deepseek-v4-pro",dr="deepseek-chat",gr="deepseek-reasoner",Ro=[ue,mr],ai=[dr,gr];var _r="https://api.mistral.ai/v1",et=`${_r}/chat/completions`,V="mistral-small-latest",bo="mistral-small-2603",oo="mistral-medium-3-5",No="mistral-medium-2508",wo="mistral-large-latest",Vo="mistral-large-2512",ko=[V,oo,wo,Vo,bo,No],fr=[V,oo],Mr=[V,bo,oo,No,wo,Vo];function tt(r){return fr.includes(r)}function Go(r){return r==="none"||r==="high"}function Fo(r){return Mr.includes(r)}var vr="https://api.sakana.ai/v1",ot=`${vr}/chat/completions`,he="fugu",Or="fugu-ultra",Er="fugu-ultra-20260615",Uo=[he,Or,Er];var Sr="https://api.platform.preferredai.jp/v1",rt=`${Sr}/chat/completions`,me="plamo-3.0-prime",Cr="plamo-2.2-prime",Ko=[me,Cr];var T={VERY_SHORT:"veryShort",SHORT:"short",MEDIUM:"medium",LONG:"long",VERY_LONG:"veryLong",DEEP:"deep"},ro={[T.VERY_SHORT]:40,[T.SHORT]:100,[T.MEDIUM]:200,[T.LONG]:300,[T.VERY_LONG]:1e3,[T.DEEP]:5e3},Ho=5e3,Bo={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 S(r){return r?ro[r]??Ho:Ho}var li="You are a friendly AI avatar. Comment on the situation based on the broadcast screen.",pi=`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",
|
|
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 L(r,e,t={}){let o="";return await
|
|
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 h=JSON.parse(m);if(h.type==="content_block_delta"&&h.delta?.text&&(t(h.delta.text),n.push({type:"text",text:h.delta.text})),h.type==="content_block_start"&&h.content_block?.type==="tool_use"?s.set(h.index,{id:h.content_block.id,name:h.content_block.name,args:""}):h.type==="content_block_start"&&h.content_block?.type==="mcp_tool_use"?s.set(h.index,{id:h.content_block.id,name:h.content_block.name,args:"",server_name:h.content_block.server_name}):h.type==="content_block_start"&&h.content_block?.type==="tool_result"?n.push({type:"tool_result",tool_use_id:h.content_block.tool_use_id,content:h.content_block.content??""}):h.type==="content_block_start"&&h.content_block?.type==="mcp_tool_result"&&n.push({type:"mcp_tool_result",tool_use_id:h.content_block.tool_use_id,is_error:h.content_block.is_error??!1,content:h.content_block.content??[]}),h.type==="content_block_delta"&&h.delta?.type==="input_json_delta"){let p=s.get(h.index);p&&(p.args+=h.delta.partial_json||"")}if(h.type==="content_block_stop"&&s.has(h.index)){let{id:p,name:g,args:O,server_name:k}=s.get(h.index);k?n.push({type:"mcp_tool_use",id:p,name:g,server_name:k,input:JSON.parse(O||"{}")}):n.push({type:"tool_use",id:p,name:g,input:JSON.parse(O||"{}")}),s.delete(h.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
|
|
13
|
-
`);d=O.pop()||"";for(let k=0;k<O.length;k++){let _=O[k].trim();if(_.startsWith("event:"))p=_.slice(6).trim();else if(_.startsWith("data:"))g=_.slice(5).trim();else if(_===""&&p&&g){try{let D=JSON.parse(g);Si(p,D,e,n,s,t,P=>{P.responseStatus!==void 0&&(a=P.responseStatus),P.incompleteDetails!==void 0&&(l=P.incompleteDetails),P.usage!==void 0&&(c=P.usage)})}catch(D){t.onJsonError?.(g,D),console.warn("Failed to parse SSE data:",g)}p="",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 Si(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(Dr(e,"completed"));break;case"response.incomplete":s(Dr(e,"incomplete"));break;default:break}}function Dr(r,e){let t=r?.response??r;return{responseStatus:t?.status??e,incompleteDetails:t?.incomplete_details??null,usage:t?.usage}}function Ar(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 Rr({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(...Ci(e)),o}function Ci(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 Ti={[T.VERY_SHORT]:800,[T.SHORT]:1200,[T.MEDIUM]:2e3,[T.LONG]:3e3,[T.VERY_LONG]:8e3,[T.DEEP]:25e3},Pi={none:1200,minimal:1600,low:2500,medium:4e3,high:8e3,xhigh:12e3},Li=new Set(["openai-compatible","deepseek","mistral","sakana","plamo"]);function yi(r){return r.type!=="json_schema"?r:{type:r.type,...r.json_schema}}function br({provider:r,endpoint:e,messages:t,model:o,stream:i,tools:n,mcpServers:s,responseLength:a,verbosity:l,reasoning_effort:c,enableReasoningSummary:d,responseFormat:u,maxTokens:m}){let h=e===A;xi(e,s);let p={model:o,stream:i},g=Ii({provider:r,model:o,responseLength:a,reasoning_effort:c,maxTokens:m});h?g!==void 0&&(p.max_output_tokens=g):g!==void 0&&(Nr(r)?p.max_tokens=g:p.max_completion_tokens=g),h?p.input=Di(t):p.messages=r==="mistral"?Ai(t):t,q(o)&&(h?(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))),u&&(h?p.text={...p.text,format:yi(u)}:p.response_format=u),r==="mistral"&&Qe(o)&&c&&wo(c)&&(p.reasoning_effort=c),r==="plamo"&&c&&(p.reasoning_effort=c);let O=Rr({tools:n,mcpServers:s,isResponsesAPI:h});return O.length>0&&(p.tools=O,h||(p.tool_choice="auto")),p}function Ii({provider:r,model:e,responseLength:t,reasoning_effort:o,maxTokens:i}){if(i!==void 0)return i;let n=Nr(r)?t!==void 0?S(t):void 0:S(t);if(r!=="openai"||!q(e)||t===void 0)return n;let s=o??Ke(e);return Math.max(n??0,Ti[t],Pi[s])}function xi(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 Di(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 Ai(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 Nr(r){return Li.has(r)}var C=class{constructor(e,t=z,o=z,i,n=U,s=[],a,l,c,d=!1,u="openai",m=!0,h){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,this.responseFormat=h,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 ro(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 ro(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?ro(e,o):Ar(await e.json()):t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callOpenAI(e,t,o=!1,i){let n=br({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,responseFormat:this.responseFormat,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 L(e,t)}async parseStream(e,t){return y(e,t,{appendTextBlock:v.addTextBlock})}parseOneShot(e){return I(e)}};var ge=class extends C{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[...xo]}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 wr=(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"]}}),io=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:[wr(e)],failures:[]}}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),{schemas:[wr(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 Vr(r){switch(r){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}function kr(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=Vr(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:Ur(Fr(s.content))}}]});continue}a!==o&&n(),o=a,i.push({text:s.content})}return n(),t}async function Gr(r,e={}){let t=e.imageFetcher??f.get,o=e.blobToBase64??Ri,i=[],n=null,s=[];for(let a of r){let l=Vr(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:Ur(Fr(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 Fr(r){try{return JSON.parse(r)}catch{return r}}function Ur(r){return r===null?{content:null}:typeof r=="object"?r:{content:r}}function Ri(r){return new Promise((e,t)=>{let o=new FileReader;o.onloadend=()=>e(o.result),o.onerror=t,o.readAsDataURL(r)})}function bi(r,e){return[...r,...e].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}function Kr(r,e){let t=bi(r,e);if(t.length!==0)return{tools:[{functionDeclarations:t}],toolConfig:{functionCallingConfig:{mode:"AUTO"}}}}function Hr(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=io.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=Hr(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 Gr(e,{callIdMap:this.callIdMap}):kr(e,{callIdMap:this.callIdMap}),generationConfig:{maxOutputTokens:i!==void 0?i:S(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=Kr(this.tools,l);c&&Object.assign(a,c);let d=async(_,D)=>{let P=o?"streamGenerateContent":"generateContent",$o=o?"?alt=sse":"",$r=`${uo}/${_}/models/${t}:${P}${$o}${$o?"&":"?"}key=${this.apiKey}`;return f.post($r,D)},u=/flash[-_]lite/.test(t),m=this.isGemma4Model(t),h=/gemini-2\.5/.test(t),p=/^gemini-3(?:\.[0-9]+)?-/.test(t),g=u||m||h||p,O=g?"v1beta":"v1",k=async()=>{try{let _=O==="v1"?a:this.adaptKeysForApi(a);return await d(O,_)}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(P){throw P instanceof Error&&(P.cause=_),P}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 h of m.candidates??[])for(let p of h.content?.parts??[])this.shouldExposeTextPart(p,o)&&(t(p.text),v.addTextBlock(s,p.text)),p.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:p.functionCall.name,input:p.functionCall.args??{}}),p.functionResponse&&a.push({type:"tool_result",tool_use_id:p.functionResponse.name,content:JSON.stringify(p.functionResponse.response)})};for(;;){let{done:u,value:m}=await i.read();if(u)break;l+=n.decode(m,{stream:!0});let h;for(;(h=l.indexOf(`
|
|
14
|
-
`))!==-1;){let p=l.slice(0,h);if(l=l.slice(h+1),p.endsWith("\r")&&(p=p.slice(0,-1)),!p.trim()){c("");continue}p.startsWith("data:")&&(p=p.slice(5).trim()),p&&c(p)}}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
|
|
10
|
+
`;var Z="gemini-nano",Wo=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"}},it=class it{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",h=m?new AbortController:void 0,p=m?setTimeout(()=>h.abort(),n):void 0,g=await it.fetchImpl(e,{method:"POST",headers:c,body:typeof t=="string"?t:JSON.stringify(t),...h?{signal:h.signal}:{}});if(p&&clearTimeout(p),!g.ok){let O=await g.text();throw new F(g.status,g.statusText,O)}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(h=>setTimeout(h,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 it.fetchImpl(e,{method:"GET",headers:t,...d?{signal:d.signal}:{}});if(u&&clearTimeout(u),!m.ok){let h=await m.text();throw new F(m.status,m.statusText,h)}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")}};it.fetchImpl=(e,t)=>fetch(e,t);var f=it;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 ci=["happy","sad","angry","surprised","neutral"],Tr=/\[([a-z]+)\]/i,zo=/\[[a-z]+\]\s*/gi,de=class{static extractEmotion(e){let t=e.match(Tr);if(t){let o=t[1].toLowerCase(),i=e.replace(zo,"").trim();return{emotion:o,cleanText:i}}return{cleanText:e}}static isValidEmotion(e){return ci.includes(e)}static cleanEmotionTags(e){return e.replace(zo,"").trim()}static addEmotionTag(e,t){return`[${e}] ${t}`}};function Pr(r){let{emotion:e,cleanText:t}=de.extractEmotion(r);return e?{emotion:e,text:t}:{text:t}}function ui(r){return r.map(e=>Pr(e))}function hi(r){return r.emotion?de.addEmotionTag(r.emotion,r.text):r.text}async function mi(r,e){let{blocks:t}=await r.chatOnce(e,!1,()=>{});return v.getFullText(t)}var Lr=(r,e,t)=>{try{return JSON.parse(r)}catch(o){return t?.(r,o),e}},Y=(r,e)=>r?Lr(r,{},e):{};var yr=(r,e)=>{try{return JSON.parse(r)}catch(t){if(e){e(r,t);return}throw t}},$o=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(""):"",Ir=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 L(r,e,t={}){let o="";return await Ir(r,i=>{let n=yr(i,t.onJsonError);if(!n)return;let s=$o(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 Ir(r,d=>{let u=yr(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 h=m?.delta,p=$o(h?.content);p&&(e(p),a(o,p)),h?.tool_calls&&h.tool_calls.forEach(g=>{let O=i.get(g.index)??{id:g.id,name:g.function?.name,args:""};O.args+=g.function?.arguments||"",i.set(g.index,O)})});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=$o(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 E=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 di="https://openrouter.ai/api/v1/models",gi=2,_i=12e3,fi=1,Mi=10;function qo(r){return r instanceof Error?r.message:String(r)}function io(r,e){return typeof r!="number"||!Number.isFinite(r)?e:Math.max(1,Math.floor(r))}function vi(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 xr(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 Dr(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 Oi(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 vi(o)}async function Ei({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 xr(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 Dr(a)};try{await a.json()}catch(l){return{id:r,ok:!1,reason:`JSON parse failed: ${qo(l)}`}}return{id:r,ok:!0}}catch(a){return{id:r,ok:!1,reason:qo(a)}}}async function Si(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 Ci(r){let e=r.apiKey.trim();if(!e)throw new Error("OpenRouter API key is required.");let t=r.modelsEndpoint||di,o=r.endpoint||$e,i=io(r.timeoutMs,_i),n=io(r.concurrency,gi),s=io(r.maxCandidates,fi),a=io(r.maxWorking,Mi),l=await xr(t,{method:"GET"},i);if(!l.ok)throw new Error(await Dr(l));let c;try{c=await l.json()}catch(p){throw new Error(`JSON parse failed: ${qo(p)}`)}let d=Oi(c).filter(p=>X(p)).slice(0,s),u=await Si(d,n,p=>Ei({modelId:p,apiKey:e,endpoint:o,timeoutMs:i,appName:r.appName,appUrl:r.appUrl})),m=u.filter(p=>p.ok).map(p=>p.id).slice(0,a),h=u.filter(p=>!p.ok).map(p=>({id:p.id,reason:p.reason||"Unknown error"}));return{working:m,failed:h,fetchedAt:Date.now()}}function Ar(r){return r.map(e=>({role:no(e.role),content:e.content}))}function Rr(r){return r.map(e=>{if(typeof e.content=="string")return{role:no(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:Ti(o.image_url.url)}}}return o}).filter(o=>o);return{role:no(e.role),content:t}}return{role:no(e.role),content:[]}})}function no(r){switch(r){case"system":return"system";case"user":return"user";case"assistant":return"assistant";default:return"user"}}function Ti(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 ge=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,!ze.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?Rr(s):Ar(s),stream:o,max_tokens:i!==void 0?i:S(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(_o,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 h=JSON.parse(m);if(h.type==="content_block_delta"&&h.delta?.text&&(t(h.delta.text),n.push({type:"text",text:h.delta.text})),h.type==="content_block_start"&&h.content_block?.type==="tool_use"?s.set(h.index,{id:h.content_block.id,name:h.content_block.name,args:""}):h.type==="content_block_start"&&h.content_block?.type==="mcp_tool_use"?s.set(h.index,{id:h.content_block.id,name:h.content_block.name,args:"",server_name:h.content_block.server_name}):h.type==="content_block_start"&&h.content_block?.type==="tool_result"?n.push({type:"tool_result",tool_use_id:h.content_block.tool_use_id,content:h.content_block.content??""}):h.type==="content_block_start"&&h.content_block?.type==="mcp_tool_result"&&n.push({type:"mcp_tool_result",tool_use_id:h.content_block.tool_use_id,is_error:h.content_block.is_error??!1,content:h.content_block.content??[]}),h.type==="content_block_delta"&&h.delta?.type==="input_json_delta"){let p=s.get(h.index);p&&(p.args+=h.delta.partial_json||"")}if(h.type==="content_block_stop"&&s.has(h.index)){let{id:p,name:g,args:O,server_name:k}=s.get(h.index);k?n.push({type:"mcp_tool_use",id:p,name:g,server_name:k,input:JSON.parse(O||"{}")}):n.push({type:"tool_use",id:p,name:g,input:JSON.parse(O||"{}")}),s.delete(h.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 _e=class{createChatService(e){let t=E({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new ge(e.apiKey,e.model||this.getDefaultModel(),t,e.tools??[],e.mcpServers??[],e.responseLength)}getProviderName(){return"claude"}getSupportedModels(){return[mt,dt,gt,R,_t,ft,Mt,vt,Ot,Et,ht]}getDefaultModel(){return R}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ze.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};async function so(r,e,t={}){let o=r.body.getReader(),i=new TextDecoder,n=[],s=new Map,a,l,c,d="";for(;;){let{done:m,value:h}=await o.read();if(m)break;d+=i.decode(h,{stream:!0});let p="",g="",O=d.split(`
|
|
13
|
+
`);d=O.pop()||"";for(let k=0;k<O.length;k++){let _=O[k].trim();if(_.startsWith("event:"))p=_.slice(6).trim();else if(_.startsWith("data:"))g=_.slice(5).trim();else if(_===""&&p&&g){try{let D=JSON.parse(g);Pi(p,D,e,n,s,t,P=>{P.responseStatus!==void 0&&(a=P.responseStatus),P.incompleteDetails!==void 0&&(l=P.incompleteDetails),P.usage!==void 0&&(c=P.usage)})}catch(D){t.onJsonError?.(g,D),console.warn("Failed to parse SSE data:",g)}p="",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 Pi(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(br(e,"completed"));break;case"response.incomplete":s(br(e,"incomplete"));break;default:break}}function br(r,e){let t=r?.response??r;return{responseStatus:t?.status??e,incompleteDetails:t?.incomplete_details??null,usage:t?.usage}}function Nr(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 wr({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(...Li(e)),o}function Li(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 yi={[T.VERY_SHORT]:800,[T.SHORT]:1200,[T.MEDIUM]:2e3,[T.LONG]:3e3,[T.VERY_LONG]:8e3,[T.DEEP]:25e3},Ii={none:1200,minimal:1600,low:2500,medium:4e3,high:8e3,xhigh:12e3},xi=new Set(["openai-compatible","deepseek","mistral","sakana","plamo"]);function Di(r){return r.type!=="json_schema"?r:{type:r.type,...r.json_schema}}function Vr({provider:r,endpoint:e,messages:t,model:o,stream:i,tools:n,mcpServers:s,responseLength:a,verbosity:l,reasoning_effort:c,enableReasoningSummary:d,responseFormat:u,maxTokens:m}){let h=e===A;Ri(e,s);let p={model:o,stream:i},g=Ai({provider:r,model:o,responseLength:a,reasoning_effort:c,maxTokens:m});h?g!==void 0&&(p.max_output_tokens=g):g!==void 0&&(kr(r)?p.max_tokens=g:p.max_completion_tokens=g),h?p.input=bi(t):p.messages=r==="mistral"?Ni(t):t,q(o)&&(h?(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))),u&&(h?p.text={...p.text,format:Di(u)}:p.response_format=u),r==="mistral"&&tt(o)&&c&&Go(c)&&(p.reasoning_effort=c),r==="plamo"&&c&&(p.reasoning_effort=c);let O=wr({tools:n,mcpServers:s,isResponsesAPI:h});return O.length>0&&(p.tools=O,h||(p.tool_choice="auto")),p}function Ai({provider:r,model:e,responseLength:t,reasoning_effort:o,maxTokens:i}){if(i!==void 0)return i;let n=kr(r)?t!==void 0?S(t):void 0:S(t);if(r!=="openai"||!q(e)||t===void 0)return n;let s=o??Be(e);return Math.max(n??0,yi[t],Ii[s])}function Ri(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 bi(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 Ni(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 kr(r){return xi.has(r)}var C=class{constructor(e,t=$,o=$,i,n=U,s=[],a,l,c,d=!1,u="openai",m=!0,h){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,this.responseFormat=h,m&&!Ue.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 so(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 so(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?so(e,o):Nr(await e.json()):t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callOpenAI(e,t,o=!1,i){let n=Vr({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,responseFormat:this.responseFormat,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 L(e,t)}async parseStream(e,t){return y(e,t,{appendTextBlock:v.addTextBlock})}parseOneShot(e){return I(e)}};var fe=class extends C{constructor(e,t=ue,o=t,i,n=Qe,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"deepseek",!1)}};var Me=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new fe(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"deepseek"}getSupportedModels(){return[...Ro]}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("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 Qe}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var Gr=(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"]}}),ao=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:[Gr(e)],failures:[]}}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),{schemas:[Gr(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 Fr(r){switch(r){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}function Ur(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=Fr(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:Br(Hr(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??wi,i=[],n=null,s=[];for(let a of r){let l=Fr(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:Br(Hr(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 Hr(r){try{return JSON.parse(r)}catch{return r}}function Br(r){return r===null?{content:null}:typeof r=="object"?r:{content:r}}function wi(r){return new Promise((e,t)=>{let o=new FileReader;o.onloadend=()=>e(o.result),o.onerror=t,o.readAsDataURL(r)})}function Vi(r,e){return[...r,...e].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}function Wr(r,e){let t=Vi(r,e);if(t.length!==0)return{tools:[{functionDeclarations:t}],toolConfig:{functionCallingConfig:{mode:"AUTO"}}}}function zr(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 ve=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,!We.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===ct||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=ao.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=zr(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}):Ur(e,{callIdMap:this.callIdMap}),generationConfig:{maxOutputTokens:i!==void 0?i:S(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=Wr(this.tools,l);c&&Object.assign(a,c);let d=async(_,D)=>{let P=o?"streamGenerateContent":"generateContent",jo=o?"?alt=sse":"",jr=`${go}/${_}/models/${t}:${P}${jo}${jo?"&":"?"}key=${this.apiKey}`;return f.post(jr,D)},u=/flash[-_]lite/.test(t),m=this.isGemma4Model(t),h=/gemini-2\.5/.test(t),p=/^gemini-3(?:\.[0-9]+)?-/.test(t),g=u||m||h||p,O=g?"v1beta":"v1",k=async()=>{try{let _=O==="v1"?a:this.adaptKeysForApi(a);return await d(O,_)}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(P){throw P instanceof Error&&(P.cause=_),P}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 h of m.candidates??[])for(let p of h.content?.parts??[])this.shouldExposeTextPart(p,o)&&(t(p.text),v.addTextBlock(s,p.text)),p.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:p.functionCall.name,input:p.functionCall.args??{}}),p.functionResponse&&a.push({type:"tool_result",tool_use_id:p.functionResponse.name,content:JSON.stringify(p.functionResponse.response)})};for(;;){let{done:u,value:m}=await i.read();if(u)break;l+=n.decode(m,{stream:!0});let h;for(;(h=l.indexOf(`
|
|
14
|
+
`))!==-1;){let p=l.slice(0,h);if(l=l.slice(h+1),p.endsWith("\r")&&(p=p.slice(0,-1)),!p.trim()){c("");continue}p.startsWith("data:")&&(p=p.slice(5).trim()),p&&c(p)}}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 Oe=class{createChatService(e){let t=E({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:o=>this.supportsVisionForModel(o),validate:"resolved"});return new ve(e.apiKey,e.model||this.getDefaultModel(),t,e.tools||[],e.mcpServers||[],e.responseLength)}getProviderName(){return"gemini"}getSupportedModels(){return[...ut]}getDefaultModel(){return j}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return We.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};function ki(){if(typeof globalThis<"u"&&"LanguageModel"in globalThis)return globalThis.LanguageModel}var Ee=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=ki();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=eo[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:S(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(Xe(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 L(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=E({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,Je,w,Yt]}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(Xe(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 C{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=E({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[...No]}getDefaultModel(){return V}getDefaultVisionModel(){return V}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Vo(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 Pe=class{createChatService(e){this.validateRequiredOptions(e);let t=[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];return e.responseFormat!==void 0&&t.push(e.responseFormat),new C(...t)}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 Le=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=E({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:d=>this.supportsVisionForModel(d),validate:"resolved"}),i=t.tools,n=t.mcpServers??[],s=t.model||this.getDefaultModel(),a=!1;n.length>0||po(s)?a=!0:q(s)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?A:U),c=[t.apiKey,s,o,i,l,n,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName()];return t.responseFormat!==void 0&&c.push(!0,t.responseFormat),new C(...c)}getProviderName(){return"openai"}getSupportedModels(){return[K,Q,ee,te,H,B,W,$,G,rt,it,nt,z,st,so,ao,"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=Uo[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"&&!co(e)?"high":t}};var wi=r=>[b,oe].includes(r.trim()),Vi=r=>r.trim()===oe?"none":void 0,ye=class{constructor(e,t=b,o=b,i,n=We,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>=Oo){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:S(this.responseLength);s&&wi(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=Vi(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 L(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=E({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[mo,go,b,$t,Ct,Tt,Pt,Lt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,_o,Ft,Ut,Kt,Ht,Bt,Wt,oe,fo,Mo,St,Ot,Et]}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 vo}isModelFree(e){return J(e)}};var xe=class extends C{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[...Go]}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 C{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[...ko]}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:S(this.responseLength);s!==void 0&&(n.max_tokens=s),this.reasoningEffort&&Zt(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 L(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=E({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??Io(t))}getProviderName(){return"xai"}getSupportedModels(){return[qe,jt,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=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:S(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&&yo(t)&&(n.tool_stream=!0)),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return L(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=E({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,Eo,So,Co,To,Po,Lo,zt,qt,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 Br=[new Le,new Pe,new Me,new Oe,new de,new Ie,new Ve,new Ne,new Se,new _e,new Te,new Re,new De];var ki=new Set(["openai","openai-compatible","openrouter","gemini","claude","zai","xai","kimi","deepseek","mistral","sakana","plamo"]),Gi=new Set(["openai","gemini","claude"]),Fi=new Set(["openai","openai-compatible","zai","kimi"]),Ui={openai:["none","minimal","low","medium","high","xhigh"],openrouter:["none","minimal","low","medium","high"],mistral:["low","medium","high"],plamo:["none","medium"],xai:["low","high"]},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 getProviderCapabilities(e,t){let o=this.providers.get(e);if(!o)return;let i=t?this.getVisionSupportLevelForModel(e,t):o.getVisionSupportLevel();return{provider:e,models:o.getSupportedModels(),defaultModel:typeof o.getDefaultModel=="function"?o.getDefaultModel():void 0,text:!0,streaming:!0,vision:i,tools:ki.has(e),mcp:Gi.has(e),jsonMode:Fi.has(e),responseLength:!0,reasoningEffort:Ui[e]??[]}}static getAllProviderCapabilities(){return this.getAvailableProviders().map(e=>this.getProviderCapabilities(e)).filter(e=>e!==void 0)}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;Br.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 Zr(Ki);})();
|
|
21
|
+
`)}getResponseLengthInstruction(){if(!this._responseLength)return;let e=ro[this._responseLength];if(e)return`Please keep your response concise, within approximately ${e} tokens.`}};var Se=class{createChatService(e){return new Ee({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 Ce=class{constructor(e,t=w,o=w,i,n=pe,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(!ce(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(!ce(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:S(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(pe)}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveEffectiveThinking(e){if(Ye(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 L(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 Te=class{constructor(){this.defaultThinking={type:"enabled"}}createChatService(e){let t=this.resolveEndpoint(e),o=e.model||this.getDefaultModel(),i=E({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 Ce(e.apiKey,o,i,n,t,e.responseLength,e.responseFormat,s)}getProviderName(){return"kimi"}getSupportedModels(){return[Je,Ze,w,to]}getDefaultModel(){return w}getDefaultVisionModel(){return w}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ce(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 pe}normalizeEndpoint(e){return e.replace(/\/+$/,"")}resolveThinking(e,t,o){if(Ye(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 Pe=class extends C{constructor(e,t=V,o=t,i,n=et,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"mistral",!1)}};var Le=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=E({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:s=>this.supportsVisionForModel(s),validate:"explicit"}),i=e.tools,n=tt(t)?e.reasoning_effort:void 0;return new Pe(e.apiKey,t,o,i,this.resolveEndpoint(e),e.responseLength,n)}getProviderName(){return"mistral"}getSupportedModels(){return[...ko]}getDefaultModel(){return V}getDefaultVisionModel(){return V}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Fo(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 et}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var ye=class{createChatService(e){this.validateRequiredOptions(e);let t=[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];return e.responseFormat!==void 0&&t.push(e.responseFormat),new C(...t)}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 Ie=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=E({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:d=>this.supportsVisionForModel(d),validate:"resolved"}),i=t.tools,n=t.mcpServers??[],s=t.model||this.getDefaultModel(),a=!1;n.length>0||ho(s)?a=!0:q(s)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?A:U),c=[t.apiKey,s,o,i,l,n,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName()];return t.responseFormat!==void 0&&c.push(!0,t.responseFormat),new C(...c)}getProviderName(){return"openai"}getSupportedModels(){return[K,Q,ee,te,H,B,W,z,G,nt,st,at,$,lt,po,co,"o1"]}getDefaultModel(){return K}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Ue.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=Bo[e.gpt5Preset];o.reasoning_effort=i.reasoning_effort,o.verbosity=i.verbosity}else e.reasoning_effort||(o.reasoning_effort=Be(t));return o.reasoning_effort=this.normalizeReasoningEffort(t,o.reasoning_effort),o}normalizeReasoningEffort(e,t){if(t)return t==="none"&&!Ke(e)||t==="minimal"&&!He(e)?t==="minimal"&&Ke(e)?"none":t==="none"&&He(e)?"minimal":pt(e)?"low":"medium":t==="low"&&!pt(e)?"medium":t==="xhigh"&&!mo(e)?"high":t}};var Gi=r=>[b,oe].includes(r.trim()),Fi=r=>r.trim()===oe?"none":void 0,xe=class{constructor(e,t=b,o=b,i,n=$e,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>=Co){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:S(this.responseLength);s&&Gi(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=Fi(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 L(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 De=class{createChatService(e){let t=E({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 xe(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[fo,Mo,b,qt,Pt,Lt,yt,It,xt,Dt,At,Rt,bt,Nt,wt,Vt,kt,Gt,Ft,Ut,vo,Kt,Ht,Bt,Wt,zt,$t,oe,Oo,Eo,Tt,St,Ct]}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 So}isModelFree(e){return X(e)}};var Ae=class extends C{constructor(e,t=me,o=t,i,n=rt,s,a){super(e,t,o,i,n,[],s,void 0,a,!1,"plamo",!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,e.reasoning_effort)}getProviderName(){return"plamo"}getSupportedModels(){return[...Ko]}getDefaultModel(){return me}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 rt}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var be=class extends C{constructor(e,t=he,o=t,i,n=ot,s){super(e,t,o,i,n,[],s,void 0,void 0,!1,"sakana",!1)}};var Ne=class{createChatService(e){this.validateRequiredOptions(e);let t=e.model||this.getDefaultModel(),o=e.tools;return new be(e.apiKey,t,e.visionModel??t,o,this.resolveEndpoint(e),e.responseLength)}getProviderName(){return"sakana"}getSupportedModels(){return[...Uo]}getDefaultModel(){return he}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 ot}normalizeUrl(e){return e.trim().replace(/\/+$/,"")}};var we=class{constructor(e,t=N,o=N,i,n=je,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(!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.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(!le(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:S(this.responseLength);s!==void 0&&(n.max_tokens=s),this.reasoningEffort&&Qt(t)&&(n.reasoning_effort=Xe(t,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 L(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=E({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:n=>this.supportsVisionForModel(n),validate:"explicit"}),i=e.tools;return new we(e.apiKey,t,o,i,e.endpoint||je,e.responseLength,Xe(t,e.reasoning_effort??eo(t)))}getProviderName(){return"xai"}getSupportedModels(){return[se,ae,Jt,Zt,Yt,N]}getDefaultModel(){return N}getDefaultVisionModel(){return N}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return le(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var ke=class{constructor(e,t=ie,o=J,i,n=qe,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:S(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&&Do(t)&&(n.tool_stream=!0)),n}buildToolsDefinition(){return x(this.tools,"chat-completions")}async handleStream(e,t){return L(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 Ge=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=E({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 ke(e.apiKey,t,o,i,e.endpoint||qe,e.responseLength,e.responseFormat,n)}getProviderName(){return"zai"}getSupportedModels(){return[ie,To,Po,Lo,yo,Io,xo,jt,Xt,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 $r=[new Ie,new ye,new Oe,new Se,new _e,new De,new Ge,new Ve,new Te,new Me,new Le,new Ne,new Re];var Ui=new Set(["openai","openai-compatible","openrouter","gemini","claude","zai","xai","kimi","deepseek","mistral","sakana","plamo"]),Ki=new Set(["openai","gemini","claude"]),Hi=new Set(["openai","openai-compatible","zai","kimi"]),Bi={openai:["none","minimal","low","medium","high","xhigh"],openrouter:["none","minimal","low","medium","high"],mistral:["low","medium","high"],plamo:["none","medium"],xai:["none","low","medium","high"]},Fe=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 getProviderCapabilities(e,t){let o=this.providers.get(e);if(!o)return;let i=t?this.getVisionSupportLevelForModel(e,t):o.getVisionSupportLevel();return{provider:e,models:o.getSupportedModels(),defaultModel:typeof o.getDefaultModel=="function"?o.getDefaultModel():void 0,text:!0,streaming:!0,vision:i,tools:Ui.has(e),mcp:Ki.has(e),jsonMode:Hi.has(e),responseLength:!0,reasoningEffort:Bi[e]??[]}}static getAllProviderCapabilities(){return this.getAvailableProviders().map(e=>this.getProviderCapabilities(e)).filter(e=>e!==void 0)}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"}};Fe.providers=new Map;$r.forEach(r=>Fe.registerProvider(r));function qr(){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 ei(Wi);})();
|