@aituber-onair/chat 0.28.0 → 0.29.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 +5 -1
- package/README.md +5 -1
- package/dist/cjs/constants/openrouter.d.ts +10 -0
- package/dist/cjs/constants/openrouter.d.ts.map +1 -1
- package/dist/cjs/constants/openrouter.js +20 -1
- package/dist/cjs/constants/openrouter.js.map +1 -1
- package/dist/cjs/services/providers/openrouter/OpenRouterChatServiceProvider.d.ts.map +1 -1
- package/dist/cjs/services/providers/openrouter/OpenRouterChatServiceProvider.js +11 -0
- package/dist/cjs/services/providers/openrouter/OpenRouterChatServiceProvider.js.map +1 -1
- package/dist/esm/constants/openrouter.d.ts +10 -0
- package/dist/esm/constants/openrouter.d.ts.map +1 -1
- package/dist/esm/constants/openrouter.js +19 -0
- package/dist/esm/constants/openrouter.js.map +1 -1
- package/dist/esm/services/providers/openrouter/OpenRouterChatServiceProvider.d.ts.map +1 -1
- package/dist/esm/services/providers/openrouter/OpenRouterChatServiceProvider.js +12 -1
- package/dist/esm/services/providers/openrouter/OpenRouterChatServiceProvider.js.map +1 -1
- package/dist/umd/aituber-onair-chat.js +40 -0
- package/dist/umd/aituber-onair-chat.min.js +7 -7
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -289,14 +289,18 @@ const openRouterService = ChatServiceFactory.createChatService('openrouter', {
|
|
|
289
289
|
- 無料階層にはレート制限があります(20リクエスト/分)
|
|
290
290
|
- 無料モデル判定はモデルID末尾の `:free` で行います(動的取得した `:free` も同様にレート制限対象)
|
|
291
291
|
- サポート対象モデル(キュレーション済み):
|
|
292
|
+
- `openrouter/auto`
|
|
292
293
|
- `openai/gpt-oss-20b:free`
|
|
294
|
+
- `~openai/gpt-latest`, `~openai/gpt-mini-latest`, `openai/gpt-5.5-pro`, `openai/gpt-5.5`
|
|
293
295
|
- `openai/gpt-5.1-chat`, `openai/gpt-5.1-codex`, `openai/gpt-5-mini`, `openai/gpt-5-nano`
|
|
294
296
|
- `openai/gpt-4o`, `openai/gpt-4.1-mini`, `openai/gpt-4.1-nano`
|
|
297
|
+
- `~anthropic/claude-sonnet-latest`, `~anthropic/claude-haiku-latest`
|
|
295
298
|
- `anthropic/claude-opus-4`, `anthropic/claude-sonnet-4`
|
|
296
299
|
- `anthropic/claude-3.7-sonnet`, `anthropic/claude-3.5-sonnet`, `anthropic/claude-haiku-4.5`
|
|
300
|
+
- `~google/gemini-pro-latest`, `~google/gemini-flash-latest`
|
|
297
301
|
- `google/gemini-2.5-pro`, `google/gemini-2.5-flash`, `google/gemini-2.5-flash-lite-preview-09-2025`
|
|
298
302
|
- `z-ai/glm-4.7-flash`, `z-ai/glm-4.5-air`, `z-ai/glm-4.5-air:free`
|
|
299
|
-
- `moonshotai/kimi-k2.5`
|
|
303
|
+
- `~moonshotai/kimi-latest`, `moonshotai/kimi-k2.5`
|
|
300
304
|
|
|
301
305
|
**OpenRouter freeモデルの動的リフレッシュ**
|
|
302
306
|
|
package/README.md
CHANGED
|
@@ -286,14 +286,18 @@ const openRouterService = ChatServiceFactory.createChatService('openrouter', {
|
|
|
286
286
|
- Free tier has rate limits (20 requests/minute)
|
|
287
287
|
- Free tier detection is based on the model ID suffix `:free` (dynamic `:free` IDs are also rate-limited)
|
|
288
288
|
- Supported models (curated list):
|
|
289
|
+
- `openrouter/auto`
|
|
289
290
|
- `openai/gpt-oss-20b:free`
|
|
291
|
+
- `~openai/gpt-latest`, `~openai/gpt-mini-latest`, `openai/gpt-5.5-pro`, `openai/gpt-5.5`
|
|
290
292
|
- `openai/gpt-5.1-chat`, `openai/gpt-5.1-codex`, `openai/gpt-5-mini`, `openai/gpt-5-nano`
|
|
291
293
|
- `openai/gpt-4o`, `openai/gpt-4.1-mini`, `openai/gpt-4.1-nano`
|
|
294
|
+
- `~anthropic/claude-sonnet-latest`, `~anthropic/claude-haiku-latest`
|
|
292
295
|
- `anthropic/claude-opus-4`, `anthropic/claude-sonnet-4`
|
|
293
296
|
- `anthropic/claude-3.7-sonnet`, `anthropic/claude-3.5-sonnet`, `anthropic/claude-haiku-4.5`
|
|
297
|
+
- `~google/gemini-pro-latest`, `~google/gemini-flash-latest`
|
|
294
298
|
- `google/gemini-2.5-pro`, `google/gemini-2.5-flash`, `google/gemini-2.5-flash-lite-preview-09-2025`
|
|
295
299
|
- `z-ai/glm-4.7-flash`, `z-ai/glm-4.5-air`, `z-ai/glm-4.5-air:free`
|
|
296
|
-
- `moonshotai/kimi-k2.5`
|
|
300
|
+
- `~moonshotai/kimi-latest`, `moonshotai/kimi-k2.5`
|
|
297
301
|
|
|
298
302
|
**Dynamic OpenRouter free model refresh**
|
|
299
303
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export declare const ENDPOINT_OPENROUTER_API = "https://openrouter.ai/api/v1/chat/completions";
|
|
2
|
+
export declare const MODEL_OPENROUTER_AUTO = "openrouter/auto";
|
|
2
3
|
export declare const MODEL_GPT_OSS_20B_FREE = "openai/gpt-oss-20b:free";
|
|
3
4
|
export declare const MODEL_MOONSHOTAI_KIMI_K2_5 = "moonshotai/kimi-k2.5";
|
|
5
|
+
export declare const MODEL_MOONSHOTAI_KIMI_LATEST = "~moonshotai/kimi-latest";
|
|
6
|
+
export declare const MODEL_OPENAI_GPT_LATEST = "~openai/gpt-latest";
|
|
7
|
+
export declare const MODEL_OPENAI_GPT_MINI_LATEST = "~openai/gpt-mini-latest";
|
|
8
|
+
export declare const MODEL_OPENAI_GPT_5_5_PRO = "openai/gpt-5.5-pro";
|
|
9
|
+
export declare const MODEL_OPENAI_GPT_5_5 = "openai/gpt-5.5";
|
|
4
10
|
export declare const MODEL_OPENAI_GPT_5_1_CHAT = "openai/gpt-5.1-chat";
|
|
5
11
|
export declare const MODEL_OPENAI_GPT_5_1_CODEX = "openai/gpt-5.1-codex";
|
|
6
12
|
export declare const MODEL_OPENAI_GPT_5_MINI = "openai/gpt-5-mini";
|
|
@@ -8,11 +14,15 @@ export declare const MODEL_OPENAI_GPT_5_NANO = "openai/gpt-5-nano";
|
|
|
8
14
|
export declare const MODEL_OPENAI_GPT_4O = "openai/gpt-4o";
|
|
9
15
|
export declare const MODEL_OPENAI_GPT_4_1_MINI = "openai/gpt-4.1-mini";
|
|
10
16
|
export declare const MODEL_OPENAI_GPT_4_1_NANO = "openai/gpt-4.1-nano";
|
|
17
|
+
export declare const MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = "~anthropic/claude-sonnet-latest";
|
|
18
|
+
export declare const MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = "~anthropic/claude-haiku-latest";
|
|
11
19
|
export declare const MODEL_ANTHROPIC_CLAUDE_OPUS_4 = "anthropic/claude-opus-4";
|
|
12
20
|
export declare const MODEL_ANTHROPIC_CLAUDE_SONNET_4 = "anthropic/claude-sonnet-4";
|
|
13
21
|
export declare const MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = "anthropic/claude-3.7-sonnet";
|
|
14
22
|
export declare const MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic/claude-3.5-sonnet";
|
|
15
23
|
export declare const MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = "anthropic/claude-haiku-4.5";
|
|
24
|
+
export declare const MODEL_GOOGLE_GEMINI_PRO_LATEST = "~google/gemini-pro-latest";
|
|
25
|
+
export declare const MODEL_GOOGLE_GEMINI_FLASH_LATEST = "~google/gemini-flash-latest";
|
|
16
26
|
export declare const MODEL_GOOGLE_GEMINI_2_5_PRO = "google/gemini-2.5-pro";
|
|
17
27
|
export declare const MODEL_GOOGLE_GEMINI_2_5_FLASH = "google/gemini-2.5-flash";
|
|
18
28
|
export declare const MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = "google/gemini-2.5-flash-lite-preview-09-2025";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../../../src/constants/openrouter.ts"],"names":[],"mappings":"AAAA,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MAAM,wCAAwC,OAAO,CAAC;AAC7D,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI9D"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPENROUTER_CREDITS_THRESHOLD = exports.OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS = exports.OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS = exports.OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE = exports.OPENROUTER_VISION_SUPPORTED_MODELS = exports.OPENROUTER_FREE_MODELS = exports.MODEL_ZAI_GLM_4_5_AIR_FREE = exports.MODEL_ZAI_GLM_4_5_AIR = exports.MODEL_ZAI_GLM_4_7_FLASH = exports.MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = exports.MODEL_GOOGLE_GEMINI_2_5_FLASH = exports.MODEL_GOOGLE_GEMINI_2_5_PRO = exports.MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = exports.MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = exports.MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = exports.MODEL_ANTHROPIC_CLAUDE_SONNET_4 = exports.MODEL_ANTHROPIC_CLAUDE_OPUS_4 = exports.MODEL_OPENAI_GPT_4_1_NANO = exports.MODEL_OPENAI_GPT_4_1_MINI = exports.MODEL_OPENAI_GPT_4O = exports.MODEL_OPENAI_GPT_5_NANO = exports.MODEL_OPENAI_GPT_5_MINI = exports.MODEL_OPENAI_GPT_5_1_CODEX = exports.MODEL_OPENAI_GPT_5_1_CHAT = exports.MODEL_MOONSHOTAI_KIMI_K2_5 = exports.MODEL_GPT_OSS_20B_FREE = exports.ENDPOINT_OPENROUTER_API = void 0;
|
|
3
|
+
exports.OPENROUTER_CREDITS_THRESHOLD = exports.OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS = exports.OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS = exports.OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE = exports.OPENROUTER_VISION_SUPPORTED_MODELS = exports.OPENROUTER_FREE_MODELS = exports.MODEL_ZAI_GLM_4_5_AIR_FREE = exports.MODEL_ZAI_GLM_4_5_AIR = exports.MODEL_ZAI_GLM_4_7_FLASH = exports.MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = exports.MODEL_GOOGLE_GEMINI_2_5_FLASH = exports.MODEL_GOOGLE_GEMINI_2_5_PRO = exports.MODEL_GOOGLE_GEMINI_FLASH_LATEST = exports.MODEL_GOOGLE_GEMINI_PRO_LATEST = exports.MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = exports.MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = exports.MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = exports.MODEL_ANTHROPIC_CLAUDE_SONNET_4 = exports.MODEL_ANTHROPIC_CLAUDE_OPUS_4 = exports.MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = exports.MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = exports.MODEL_OPENAI_GPT_4_1_NANO = exports.MODEL_OPENAI_GPT_4_1_MINI = exports.MODEL_OPENAI_GPT_4O = exports.MODEL_OPENAI_GPT_5_NANO = exports.MODEL_OPENAI_GPT_5_MINI = exports.MODEL_OPENAI_GPT_5_1_CODEX = exports.MODEL_OPENAI_GPT_5_1_CHAT = exports.MODEL_OPENAI_GPT_5_5 = exports.MODEL_OPENAI_GPT_5_5_PRO = exports.MODEL_OPENAI_GPT_MINI_LATEST = exports.MODEL_OPENAI_GPT_LATEST = exports.MODEL_MOONSHOTAI_KIMI_LATEST = exports.MODEL_MOONSHOTAI_KIMI_K2_5 = exports.MODEL_GPT_OSS_20B_FREE = exports.MODEL_OPENROUTER_AUTO = exports.ENDPOINT_OPENROUTER_API = void 0;
|
|
4
4
|
exports.isOpenRouterFreeModel = isOpenRouterFreeModel;
|
|
5
5
|
exports.isOpenRouterVisionModel = isOpenRouterVisionModel;
|
|
6
6
|
exports.ENDPOINT_OPENROUTER_API = 'https://openrouter.ai/api/v1/chat/completions';
|
|
7
7
|
// OpenRouter models
|
|
8
|
+
exports.MODEL_OPENROUTER_AUTO = 'openrouter/auto';
|
|
8
9
|
exports.MODEL_GPT_OSS_20B_FREE = 'openai/gpt-oss-20b:free';
|
|
9
10
|
exports.MODEL_MOONSHOTAI_KIMI_K2_5 = 'moonshotai/kimi-k2.5';
|
|
11
|
+
exports.MODEL_MOONSHOTAI_KIMI_LATEST = '~moonshotai/kimi-latest';
|
|
12
|
+
exports.MODEL_OPENAI_GPT_LATEST = '~openai/gpt-latest';
|
|
13
|
+
exports.MODEL_OPENAI_GPT_MINI_LATEST = '~openai/gpt-mini-latest';
|
|
14
|
+
exports.MODEL_OPENAI_GPT_5_5_PRO = 'openai/gpt-5.5-pro';
|
|
15
|
+
exports.MODEL_OPENAI_GPT_5_5 = 'openai/gpt-5.5';
|
|
10
16
|
exports.MODEL_OPENAI_GPT_5_1_CHAT = 'openai/gpt-5.1-chat';
|
|
11
17
|
exports.MODEL_OPENAI_GPT_5_1_CODEX = 'openai/gpt-5.1-codex';
|
|
12
18
|
exports.MODEL_OPENAI_GPT_5_MINI = 'openai/gpt-5-mini';
|
|
@@ -14,11 +20,15 @@ exports.MODEL_OPENAI_GPT_5_NANO = 'openai/gpt-5-nano';
|
|
|
14
20
|
exports.MODEL_OPENAI_GPT_4O = 'openai/gpt-4o';
|
|
15
21
|
exports.MODEL_OPENAI_GPT_4_1_MINI = 'openai/gpt-4.1-mini';
|
|
16
22
|
exports.MODEL_OPENAI_GPT_4_1_NANO = 'openai/gpt-4.1-nano';
|
|
23
|
+
exports.MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = '~anthropic/claude-sonnet-latest';
|
|
24
|
+
exports.MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = '~anthropic/claude-haiku-latest';
|
|
17
25
|
exports.MODEL_ANTHROPIC_CLAUDE_OPUS_4 = 'anthropic/claude-opus-4';
|
|
18
26
|
exports.MODEL_ANTHROPIC_CLAUDE_SONNET_4 = 'anthropic/claude-sonnet-4';
|
|
19
27
|
exports.MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = 'anthropic/claude-3.7-sonnet';
|
|
20
28
|
exports.MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = 'anthropic/claude-3.5-sonnet';
|
|
21
29
|
exports.MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = 'anthropic/claude-haiku-4.5';
|
|
30
|
+
exports.MODEL_GOOGLE_GEMINI_PRO_LATEST = '~google/gemini-pro-latest';
|
|
31
|
+
exports.MODEL_GOOGLE_GEMINI_FLASH_LATEST = '~google/gemini-flash-latest';
|
|
22
32
|
exports.MODEL_GOOGLE_GEMINI_2_5_PRO = 'google/gemini-2.5-pro';
|
|
23
33
|
exports.MODEL_GOOGLE_GEMINI_2_5_FLASH = 'google/gemini-2.5-flash';
|
|
24
34
|
exports.MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = 'google/gemini-2.5-flash-lite-preview-09-2025';
|
|
@@ -32,6 +42,11 @@ exports.OPENROUTER_FREE_MODELS = [
|
|
|
32
42
|
];
|
|
33
43
|
// Vision supported models on OpenRouter
|
|
34
44
|
exports.OPENROUTER_VISION_SUPPORTED_MODELS = [
|
|
45
|
+
exports.MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
46
|
+
exports.MODEL_OPENAI_GPT_LATEST,
|
|
47
|
+
exports.MODEL_OPENAI_GPT_MINI_LATEST,
|
|
48
|
+
exports.MODEL_OPENAI_GPT_5_5_PRO,
|
|
49
|
+
exports.MODEL_OPENAI_GPT_5_5,
|
|
35
50
|
exports.MODEL_OPENAI_GPT_5_1_CHAT,
|
|
36
51
|
exports.MODEL_OPENAI_GPT_5_1_CODEX,
|
|
37
52
|
exports.MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -39,10 +54,14 @@ exports.OPENROUTER_VISION_SUPPORTED_MODELS = [
|
|
|
39
54
|
exports.MODEL_OPENAI_GPT_4O,
|
|
40
55
|
exports.MODEL_OPENAI_GPT_4_1_MINI,
|
|
41
56
|
exports.MODEL_OPENAI_GPT_4_1_NANO,
|
|
57
|
+
exports.MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
58
|
+
exports.MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
42
59
|
exports.MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
43
60
|
exports.MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
44
61
|
exports.MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
45
62
|
exports.MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
63
|
+
exports.MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
64
|
+
exports.MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
46
65
|
exports.MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
47
66
|
exports.MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
48
67
|
exports.MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../../src/constants/openrouter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../../src/constants/openrouter.ts"],"names":[],"mappings":";;;AAmFA,sDAEC;AAOD,0DAIC;AAhGY,QAAA,uBAAuB,GAClC,+CAA+C,CAAC;AAElD,oBAAoB;AACP,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAC1C,QAAA,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8BAAsB;IACtB,kCAA0B;CAC3B,CAAC;AAEF,wCAAwC;AAC3B,QAAA,kCAAkC,GAAG;IAChD,oCAA4B;IAC5B,+BAAuB;IACvB,oCAA4B;IAC5B,gCAAwB;IACxB,4BAAoB;IACpB,iCAAyB;IACzB,kCAA0B;IAC1B,+BAAuB;IACvB,+BAAuB;IACvB,2BAAmB;IACnB,iCAAyB;IACzB,iCAAyB;IACzB,4CAAoC;IACpC,2CAAmC;IACnC,qCAA6B;IAC7B,uCAA+B;IAC/B,yCAAiC;IACjC,wCAAgC;IAChC,sCAA8B;IAC9B,wCAAgC;IAChC,mCAA2B;IAC3B,qCAA6B;IAC7B,0DAAkD;IAClD,kCAA0B;CAC3B,CAAC;AAEF,4BAA4B;AACf,QAAA,qCAAqC,GAAG,EAAE,CAAC;AAC3C,QAAA,uCAAuC,GAAG,EAAE,CAAC;AAC7C,QAAA,wCAAwC,GAAG,IAAI,CAAC;AAChD,QAAA,4BAA4B,GAAG,EAAE,CAAC;AAE/C;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,OAAO,0CAAkC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAC7D,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenRouterChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;;GAGG;AACH,qBAAa,6BACX,YAAW,mBAAmB,CAAC,4BAA4B,CAAC;IAE5D;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,4BAA4B,GAAG,WAAW;IAmCrE;;;OAGG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACH,kBAAkB,IAAI,MAAM,EAAE;IA0C9B;;;OAGG;IACH,eAAe,IAAI,MAAM;IAIzB;;;OAGG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAQ3C;;;;OAIG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAIhE;;;OAGG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGpC"}
|
|
@@ -46,10 +46,16 @@ class OpenRouterChatServiceProvider {
|
|
|
46
46
|
*/
|
|
47
47
|
getSupportedModels() {
|
|
48
48
|
return [
|
|
49
|
+
// OpenRouter routing
|
|
50
|
+
openrouter_1.MODEL_OPENROUTER_AUTO,
|
|
49
51
|
// Free models
|
|
50
52
|
openrouter_1.MODEL_GPT_OSS_20B_FREE,
|
|
51
53
|
openrouter_1.MODEL_ZAI_GLM_4_5_AIR_FREE,
|
|
52
54
|
// OpenAI models
|
|
55
|
+
openrouter_1.MODEL_OPENAI_GPT_LATEST,
|
|
56
|
+
openrouter_1.MODEL_OPENAI_GPT_MINI_LATEST,
|
|
57
|
+
openrouter_1.MODEL_OPENAI_GPT_5_5_PRO,
|
|
58
|
+
openrouter_1.MODEL_OPENAI_GPT_5_5,
|
|
53
59
|
openrouter_1.MODEL_OPENAI_GPT_5_1_CHAT,
|
|
54
60
|
openrouter_1.MODEL_OPENAI_GPT_5_1_CODEX,
|
|
55
61
|
openrouter_1.MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -58,12 +64,16 @@ class OpenRouterChatServiceProvider {
|
|
|
58
64
|
openrouter_1.MODEL_OPENAI_GPT_4_1_MINI,
|
|
59
65
|
openrouter_1.MODEL_OPENAI_GPT_4_1_NANO,
|
|
60
66
|
// Anthropic models
|
|
67
|
+
openrouter_1.MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
68
|
+
openrouter_1.MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
61
69
|
openrouter_1.MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
62
70
|
openrouter_1.MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
63
71
|
openrouter_1.MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
64
72
|
openrouter_1.MODEL_ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
65
73
|
openrouter_1.MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
66
74
|
// Gemini models
|
|
75
|
+
openrouter_1.MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
76
|
+
openrouter_1.MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
67
77
|
openrouter_1.MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
68
78
|
openrouter_1.MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
69
79
|
openrouter_1.MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -71,6 +81,7 @@ class OpenRouterChatServiceProvider {
|
|
|
71
81
|
openrouter_1.MODEL_ZAI_GLM_4_7_FLASH,
|
|
72
82
|
openrouter_1.MODEL_ZAI_GLM_4_5_AIR,
|
|
73
83
|
// Other models
|
|
84
|
+
openrouter_1.MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
74
85
|
openrouter_1.MODEL_MOONSHOTAI_KIMI_K2_5,
|
|
75
86
|
];
|
|
76
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"OpenRouterChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":";;;AAAA,8DAkCuC;AAEvC,mEAAgE;AAOhE,0CAAoD;AAEpD;;;GAGG;AACH,MAAa,6BAA6B;IAGxC;;;;OAIG;IACH,iBAAiB,CAAC,OAAqC;QACrD,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,WAAW,GAAG,IAAA,0BAAkB,EAAC;YACrC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,kBAAkB,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE;YAC3D,sBAAsB,EAAE,CAAC,WAAW,EAAE,EAAE,CACtC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC;YAC1C,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QAEH,mBAAmB;QACnB,MAAM,KAAK,GAAiC,OAAO,CAAC,KAAK,CAAC;QAE1D,sCAAsC;QACtC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,OAAO,IAAI,6CAAqB,CAC9B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE,EACvC,WAAW,EACX,KAAK,EACL,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,cAAc,EACtB,OAAO,EACP,MAAM,EACN,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC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,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,mCAAsB,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAa;QACvB,OAAO,IAAA,kCAAqB,EAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF;AAvJD,sEAuJC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export declare const ENDPOINT_OPENROUTER_API = "https://openrouter.ai/api/v1/chat/completions";
|
|
2
|
+
export declare const MODEL_OPENROUTER_AUTO = "openrouter/auto";
|
|
2
3
|
export declare const MODEL_GPT_OSS_20B_FREE = "openai/gpt-oss-20b:free";
|
|
3
4
|
export declare const MODEL_MOONSHOTAI_KIMI_K2_5 = "moonshotai/kimi-k2.5";
|
|
5
|
+
export declare const MODEL_MOONSHOTAI_KIMI_LATEST = "~moonshotai/kimi-latest";
|
|
6
|
+
export declare const MODEL_OPENAI_GPT_LATEST = "~openai/gpt-latest";
|
|
7
|
+
export declare const MODEL_OPENAI_GPT_MINI_LATEST = "~openai/gpt-mini-latest";
|
|
8
|
+
export declare const MODEL_OPENAI_GPT_5_5_PRO = "openai/gpt-5.5-pro";
|
|
9
|
+
export declare const MODEL_OPENAI_GPT_5_5 = "openai/gpt-5.5";
|
|
4
10
|
export declare const MODEL_OPENAI_GPT_5_1_CHAT = "openai/gpt-5.1-chat";
|
|
5
11
|
export declare const MODEL_OPENAI_GPT_5_1_CODEX = "openai/gpt-5.1-codex";
|
|
6
12
|
export declare const MODEL_OPENAI_GPT_5_MINI = "openai/gpt-5-mini";
|
|
@@ -8,11 +14,15 @@ export declare const MODEL_OPENAI_GPT_5_NANO = "openai/gpt-5-nano";
|
|
|
8
14
|
export declare const MODEL_OPENAI_GPT_4O = "openai/gpt-4o";
|
|
9
15
|
export declare const MODEL_OPENAI_GPT_4_1_MINI = "openai/gpt-4.1-mini";
|
|
10
16
|
export declare const MODEL_OPENAI_GPT_4_1_NANO = "openai/gpt-4.1-nano";
|
|
17
|
+
export declare const MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = "~anthropic/claude-sonnet-latest";
|
|
18
|
+
export declare const MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = "~anthropic/claude-haiku-latest";
|
|
11
19
|
export declare const MODEL_ANTHROPIC_CLAUDE_OPUS_4 = "anthropic/claude-opus-4";
|
|
12
20
|
export declare const MODEL_ANTHROPIC_CLAUDE_SONNET_4 = "anthropic/claude-sonnet-4";
|
|
13
21
|
export declare const MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = "anthropic/claude-3.7-sonnet";
|
|
14
22
|
export declare const MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic/claude-3.5-sonnet";
|
|
15
23
|
export declare const MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = "anthropic/claude-haiku-4.5";
|
|
24
|
+
export declare const MODEL_GOOGLE_GEMINI_PRO_LATEST = "~google/gemini-pro-latest";
|
|
25
|
+
export declare const MODEL_GOOGLE_GEMINI_FLASH_LATEST = "~google/gemini-flash-latest";
|
|
16
26
|
export declare const MODEL_GOOGLE_GEMINI_2_5_PRO = "google/gemini-2.5-pro";
|
|
17
27
|
export declare const MODEL_GOOGLE_GEMINI_2_5_FLASH = "google/gemini-2.5-flash";
|
|
18
28
|
export declare const MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = "google/gemini-2.5-flash-lite-preview-09-2025";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../../../src/constants/openrouter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,kDACa,CAAC;AAGlD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,yBAAyB,wBAAwB,CAA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;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI9D"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export const ENDPOINT_OPENROUTER_API = 'https://openrouter.ai/api/v1/chat/completions';
|
|
2
2
|
// OpenRouter models
|
|
3
|
+
export const MODEL_OPENROUTER_AUTO = 'openrouter/auto';
|
|
3
4
|
export const MODEL_GPT_OSS_20B_FREE = 'openai/gpt-oss-20b:free';
|
|
4
5
|
export const MODEL_MOONSHOTAI_KIMI_K2_5 = 'moonshotai/kimi-k2.5';
|
|
6
|
+
export const MODEL_MOONSHOTAI_KIMI_LATEST = '~moonshotai/kimi-latest';
|
|
7
|
+
export const MODEL_OPENAI_GPT_LATEST = '~openai/gpt-latest';
|
|
8
|
+
export const MODEL_OPENAI_GPT_MINI_LATEST = '~openai/gpt-mini-latest';
|
|
9
|
+
export const MODEL_OPENAI_GPT_5_5_PRO = 'openai/gpt-5.5-pro';
|
|
10
|
+
export const MODEL_OPENAI_GPT_5_5 = 'openai/gpt-5.5';
|
|
5
11
|
export const MODEL_OPENAI_GPT_5_1_CHAT = 'openai/gpt-5.1-chat';
|
|
6
12
|
export const MODEL_OPENAI_GPT_5_1_CODEX = 'openai/gpt-5.1-codex';
|
|
7
13
|
export const MODEL_OPENAI_GPT_5_MINI = 'openai/gpt-5-mini';
|
|
@@ -9,11 +15,15 @@ export const MODEL_OPENAI_GPT_5_NANO = 'openai/gpt-5-nano';
|
|
|
9
15
|
export const MODEL_OPENAI_GPT_4O = 'openai/gpt-4o';
|
|
10
16
|
export const MODEL_OPENAI_GPT_4_1_MINI = 'openai/gpt-4.1-mini';
|
|
11
17
|
export const MODEL_OPENAI_GPT_4_1_NANO = 'openai/gpt-4.1-nano';
|
|
18
|
+
export const MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = '~anthropic/claude-sonnet-latest';
|
|
19
|
+
export const MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = '~anthropic/claude-haiku-latest';
|
|
12
20
|
export const MODEL_ANTHROPIC_CLAUDE_OPUS_4 = 'anthropic/claude-opus-4';
|
|
13
21
|
export const MODEL_ANTHROPIC_CLAUDE_SONNET_4 = 'anthropic/claude-sonnet-4';
|
|
14
22
|
export const MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = 'anthropic/claude-3.7-sonnet';
|
|
15
23
|
export const MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = 'anthropic/claude-3.5-sonnet';
|
|
16
24
|
export const MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = 'anthropic/claude-haiku-4.5';
|
|
25
|
+
export const MODEL_GOOGLE_GEMINI_PRO_LATEST = '~google/gemini-pro-latest';
|
|
26
|
+
export const MODEL_GOOGLE_GEMINI_FLASH_LATEST = '~google/gemini-flash-latest';
|
|
17
27
|
export const MODEL_GOOGLE_GEMINI_2_5_PRO = 'google/gemini-2.5-pro';
|
|
18
28
|
export const MODEL_GOOGLE_GEMINI_2_5_FLASH = 'google/gemini-2.5-flash';
|
|
19
29
|
export const MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = 'google/gemini-2.5-flash-lite-preview-09-2025';
|
|
@@ -27,6 +37,11 @@ export const OPENROUTER_FREE_MODELS = [
|
|
|
27
37
|
];
|
|
28
38
|
// Vision supported models on OpenRouter
|
|
29
39
|
export const OPENROUTER_VISION_SUPPORTED_MODELS = [
|
|
40
|
+
MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
41
|
+
MODEL_OPENAI_GPT_LATEST,
|
|
42
|
+
MODEL_OPENAI_GPT_MINI_LATEST,
|
|
43
|
+
MODEL_OPENAI_GPT_5_5_PRO,
|
|
44
|
+
MODEL_OPENAI_GPT_5_5,
|
|
30
45
|
MODEL_OPENAI_GPT_5_1_CHAT,
|
|
31
46
|
MODEL_OPENAI_GPT_5_1_CODEX,
|
|
32
47
|
MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -34,10 +49,14 @@ export const OPENROUTER_VISION_SUPPORTED_MODELS = [
|
|
|
34
49
|
MODEL_OPENAI_GPT_4O,
|
|
35
50
|
MODEL_OPENAI_GPT_4_1_MINI,
|
|
36
51
|
MODEL_OPENAI_GPT_4_1_NANO,
|
|
52
|
+
MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
53
|
+
MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
37
54
|
MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
38
55
|
MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
39
56
|
MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
40
57
|
MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
58
|
+
MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
59
|
+
MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
41
60
|
MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
42
61
|
MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
43
62
|
MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../../src/constants/openrouter.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAClC,+CAA+C,CAAC;AAElD,oBAAoB;AACpB,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAA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AAyB;IACzB,yBAAyB;IACzB,oCAAoC;IACpC,mCAAmC;IACnC,6BAA6B;IAC7B,+BAA+B;IAC/B,iCAAiC;IACjC,gCAAgC;IAChC,8BAA8B;IAC9B,gCAAgC;IAChC,2BAA2B;IAC3B,6BAA6B;IAC7B,kDAAkD;IAClD,0BAA0B;CAC3B,CAAC;AAEF,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,uCAAuC,GAAG,EAAE,CAAC;AAC1D,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,CAAC;AAC7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,kCAAkC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAC7D,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenRouterChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAIhC;;;GAGG;AACH,qBAAa,6BACX,YAAW,mBAAmB,CAAC,4BAA4B,CAAC;IAE5D;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,4BAA4B,GAAG,WAAW;IAmCrE;;;OAGG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACH,kBAAkB,IAAI,MAAM,EAAE;IA0C9B;;;OAGG;IACH,eAAe,IAAI,MAAM;IAIzB;;;OAGG;IACH,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;IAQ3C;;;;OAIG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI9C,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAIhE;;;OAGG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MODEL_GPT_OSS_20B_FREE, MODEL_MOONSHOTAI_KIMI_K2_5, MODEL_OPENAI_GPT_5_1_CHAT, MODEL_OPENAI_GPT_5_1_CODEX, MODEL_OPENAI_GPT_5_MINI, MODEL_OPENAI_GPT_5_NANO, MODEL_OPENAI_GPT_4O, MODEL_OPENAI_GPT_4_1_MINI, MODEL_OPENAI_GPT_4_1_NANO, MODEL_ANTHROPIC_CLAUDE_OPUS_4, MODEL_ANTHROPIC_CLAUDE_SONNET_4, MODEL_ANTHROPIC_CLAUDE_3_7_SONNET, MODEL_ANTHROPIC_CLAUDE_3_5_SONNET, MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU, MODEL_GOOGLE_GEMINI_2_5_PRO, MODEL_GOOGLE_GEMINI_2_5_FLASH, MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025, MODEL_ZAI_GLM_4_7_FLASH, MODEL_ZAI_GLM_4_5_AIR, MODEL_ZAI_GLM_4_5_AIR_FREE, OPENROUTER_FREE_MODELS, isOpenRouterFreeModel, isOpenRouterVisionModel, } from '../../../constants/openrouter';
|
|
1
|
+
import { MODEL_GPT_OSS_20B_FREE, MODEL_MOONSHOTAI_KIMI_K2_5, MODEL_MOONSHOTAI_KIMI_LATEST, MODEL_OPENROUTER_AUTO, MODEL_OPENAI_GPT_LATEST, MODEL_OPENAI_GPT_MINI_LATEST, MODEL_OPENAI_GPT_5_5_PRO, MODEL_OPENAI_GPT_5_5, MODEL_OPENAI_GPT_5_1_CHAT, MODEL_OPENAI_GPT_5_1_CODEX, MODEL_OPENAI_GPT_5_MINI, MODEL_OPENAI_GPT_5_NANO, MODEL_OPENAI_GPT_4O, MODEL_OPENAI_GPT_4_1_MINI, MODEL_OPENAI_GPT_4_1_NANO, MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST, MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST, MODEL_ANTHROPIC_CLAUDE_OPUS_4, MODEL_ANTHROPIC_CLAUDE_SONNET_4, MODEL_ANTHROPIC_CLAUDE_3_7_SONNET, MODEL_ANTHROPIC_CLAUDE_3_5_SONNET, MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU, MODEL_GOOGLE_GEMINI_PRO_LATEST, MODEL_GOOGLE_GEMINI_FLASH_LATEST, MODEL_GOOGLE_GEMINI_2_5_PRO, MODEL_GOOGLE_GEMINI_2_5_FLASH, MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025, MODEL_ZAI_GLM_4_7_FLASH, MODEL_ZAI_GLM_4_5_AIR, MODEL_ZAI_GLM_4_5_AIR_FREE, OPENROUTER_FREE_MODELS, isOpenRouterFreeModel, isOpenRouterVisionModel, } from '../../../constants/openrouter';
|
|
2
2
|
import { OpenRouterChatService } from './OpenRouterChatService';
|
|
3
3
|
import { resolveVisionModel } from '../../../utils';
|
|
4
4
|
/**
|
|
@@ -43,10 +43,16 @@ export class OpenRouterChatServiceProvider {
|
|
|
43
43
|
*/
|
|
44
44
|
getSupportedModels() {
|
|
45
45
|
return [
|
|
46
|
+
// OpenRouter routing
|
|
47
|
+
MODEL_OPENROUTER_AUTO,
|
|
46
48
|
// Free models
|
|
47
49
|
MODEL_GPT_OSS_20B_FREE,
|
|
48
50
|
MODEL_ZAI_GLM_4_5_AIR_FREE,
|
|
49
51
|
// OpenAI models
|
|
52
|
+
MODEL_OPENAI_GPT_LATEST,
|
|
53
|
+
MODEL_OPENAI_GPT_MINI_LATEST,
|
|
54
|
+
MODEL_OPENAI_GPT_5_5_PRO,
|
|
55
|
+
MODEL_OPENAI_GPT_5_5,
|
|
50
56
|
MODEL_OPENAI_GPT_5_1_CHAT,
|
|
51
57
|
MODEL_OPENAI_GPT_5_1_CODEX,
|
|
52
58
|
MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -55,12 +61,16 @@ export class OpenRouterChatServiceProvider {
|
|
|
55
61
|
MODEL_OPENAI_GPT_4_1_MINI,
|
|
56
62
|
MODEL_OPENAI_GPT_4_1_NANO,
|
|
57
63
|
// Anthropic models
|
|
64
|
+
MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
65
|
+
MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
58
66
|
MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
59
67
|
MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
60
68
|
MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
61
69
|
MODEL_ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
62
70
|
MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
63
71
|
// Gemini models
|
|
72
|
+
MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
73
|
+
MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
64
74
|
MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
65
75
|
MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
66
76
|
MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -68,6 +78,7 @@ export class OpenRouterChatServiceProvider {
|
|
|
68
78
|
MODEL_ZAI_GLM_4_7_FLASH,
|
|
69
79
|
MODEL_ZAI_GLM_4_5_AIR,
|
|
70
80
|
// Other models
|
|
81
|
+
MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
71
82
|
MODEL_MOONSHOTAI_KIMI_K2_5,
|
|
72
83
|
];
|
|
73
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenRouterChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,+BAA+B,EAC/B,iCAAiC,EACjC,iCAAiC,EACjC,gCAAgC,EAChC,2BAA2B,EAC3B,6BAA6B,EAC7B,kDAAkD,EAClD,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IAGxC;;;;OAIG;IACH,iBAAiB,CAAC,OAAqC;QACrD,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,WAAW,GAAG,kBAAkB,CAAC;YACrC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,kBAAkB,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE;YAC3D,sBAAsB,EAAE,CAAC,WAAW,EAAE,EAAE,CACtC,IAAI,CA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,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9C,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CACnC;YACC,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,aAAa,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,sBAAsB,CAAC,KAAa;QAClC,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,6BAA6B,CAAC,KAAa;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,sBAAsB,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAa;QACvB,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"OpenRouterChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/openrouter/OpenRouterChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,oCAAoC,EACpC,mCAAmC,EACnC,6BAA6B,EAC7B,+BAA+B,EAC/B,iCAAiC,EACjC,iCAAiC,EACjC,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,2BAA2B,EAC3B,6BAA6B,EAC7B,kDAAkD,EAClD,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AAEvC,O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ACF"}
|
|
@@ -57,8 +57,10 @@ var AITuberOnAirChat = (() => {
|
|
|
57
57
|
MODEL_ANTHROPIC_CLAUDE_3_5_SONNET: () => MODEL_ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
58
58
|
MODEL_ANTHROPIC_CLAUDE_3_7_SONNET: () => MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
59
59
|
MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU: () => MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
60
|
+
MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST: () => MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
60
61
|
MODEL_ANTHROPIC_CLAUDE_OPUS_4: () => MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
61
62
|
MODEL_ANTHROPIC_CLAUDE_SONNET_4: () => MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
63
|
+
MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST: () => MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
62
64
|
MODEL_CLAUDE_3_5_HAIKU: () => MODEL_CLAUDE_3_5_HAIKU,
|
|
63
65
|
MODEL_CLAUDE_3_5_SONNET: () => MODEL_CLAUDE_3_5_SONNET,
|
|
64
66
|
MODEL_CLAUDE_3_7_SONNET: () => MODEL_CLAUDE_3_7_SONNET,
|
|
@@ -96,6 +98,8 @@ var AITuberOnAirChat = (() => {
|
|
|
96
98
|
MODEL_GOOGLE_GEMINI_2_5_FLASH: () => MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
97
99
|
MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025: () => MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
98
100
|
MODEL_GOOGLE_GEMINI_2_5_PRO: () => MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
101
|
+
MODEL_GOOGLE_GEMINI_FLASH_LATEST: () => MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
102
|
+
MODEL_GOOGLE_GEMINI_PRO_LATEST: () => MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
99
103
|
MODEL_GPT_4O: () => MODEL_GPT_4O,
|
|
100
104
|
MODEL_GPT_4O_MINI: () => MODEL_GPT_4O_MINI,
|
|
101
105
|
MODEL_GPT_4_1: () => MODEL_GPT_4_1,
|
|
@@ -118,6 +122,7 @@ var AITuberOnAirChat = (() => {
|
|
|
118
122
|
MODEL_KIMI_K2_5: () => MODEL_KIMI_K2_5,
|
|
119
123
|
MODEL_KIMI_K2_6: () => MODEL_KIMI_K2_6,
|
|
120
124
|
MODEL_MOONSHOTAI_KIMI_K2_5: () => MODEL_MOONSHOTAI_KIMI_K2_5,
|
|
125
|
+
MODEL_MOONSHOTAI_KIMI_LATEST: () => MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
121
126
|
MODEL_O1: () => MODEL_O1,
|
|
122
127
|
MODEL_O1_MINI: () => MODEL_O1_MINI,
|
|
123
128
|
MODEL_O3_MINI: () => MODEL_O3_MINI,
|
|
@@ -126,8 +131,13 @@ var AITuberOnAirChat = (() => {
|
|
|
126
131
|
MODEL_OPENAI_GPT_4_1_NANO: () => MODEL_OPENAI_GPT_4_1_NANO,
|
|
127
132
|
MODEL_OPENAI_GPT_5_1_CHAT: () => MODEL_OPENAI_GPT_5_1_CHAT,
|
|
128
133
|
MODEL_OPENAI_GPT_5_1_CODEX: () => MODEL_OPENAI_GPT_5_1_CODEX,
|
|
134
|
+
MODEL_OPENAI_GPT_5_5: () => MODEL_OPENAI_GPT_5_5,
|
|
135
|
+
MODEL_OPENAI_GPT_5_5_PRO: () => MODEL_OPENAI_GPT_5_5_PRO,
|
|
129
136
|
MODEL_OPENAI_GPT_5_MINI: () => MODEL_OPENAI_GPT_5_MINI,
|
|
130
137
|
MODEL_OPENAI_GPT_5_NANO: () => MODEL_OPENAI_GPT_5_NANO,
|
|
138
|
+
MODEL_OPENAI_GPT_LATEST: () => MODEL_OPENAI_GPT_LATEST,
|
|
139
|
+
MODEL_OPENAI_GPT_MINI_LATEST: () => MODEL_OPENAI_GPT_MINI_LATEST,
|
|
140
|
+
MODEL_OPENROUTER_AUTO: () => MODEL_OPENROUTER_AUTO,
|
|
131
141
|
MODEL_ZAI_GLM_4_5_AIR: () => MODEL_ZAI_GLM_4_5_AIR,
|
|
132
142
|
MODEL_ZAI_GLM_4_5_AIR_FREE: () => MODEL_ZAI_GLM_4_5_AIR_FREE,
|
|
133
143
|
MODEL_ZAI_GLM_4_7_FLASH: () => MODEL_ZAI_GLM_4_7_FLASH,
|
|
@@ -309,8 +319,14 @@ var AITuberOnAirChat = (() => {
|
|
|
309
319
|
|
|
310
320
|
// src/constants/openrouter.ts
|
|
311
321
|
var ENDPOINT_OPENROUTER_API = "https://openrouter.ai/api/v1/chat/completions";
|
|
322
|
+
var MODEL_OPENROUTER_AUTO = "openrouter/auto";
|
|
312
323
|
var MODEL_GPT_OSS_20B_FREE = "openai/gpt-oss-20b:free";
|
|
313
324
|
var MODEL_MOONSHOTAI_KIMI_K2_5 = "moonshotai/kimi-k2.5";
|
|
325
|
+
var MODEL_MOONSHOTAI_KIMI_LATEST = "~moonshotai/kimi-latest";
|
|
326
|
+
var MODEL_OPENAI_GPT_LATEST = "~openai/gpt-latest";
|
|
327
|
+
var MODEL_OPENAI_GPT_MINI_LATEST = "~openai/gpt-mini-latest";
|
|
328
|
+
var MODEL_OPENAI_GPT_5_5_PRO = "openai/gpt-5.5-pro";
|
|
329
|
+
var MODEL_OPENAI_GPT_5_5 = "openai/gpt-5.5";
|
|
314
330
|
var MODEL_OPENAI_GPT_5_1_CHAT = "openai/gpt-5.1-chat";
|
|
315
331
|
var MODEL_OPENAI_GPT_5_1_CODEX = "openai/gpt-5.1-codex";
|
|
316
332
|
var MODEL_OPENAI_GPT_5_MINI = "openai/gpt-5-mini";
|
|
@@ -318,11 +334,15 @@ var AITuberOnAirChat = (() => {
|
|
|
318
334
|
var MODEL_OPENAI_GPT_4O = "openai/gpt-4o";
|
|
319
335
|
var MODEL_OPENAI_GPT_4_1_MINI = "openai/gpt-4.1-mini";
|
|
320
336
|
var MODEL_OPENAI_GPT_4_1_NANO = "openai/gpt-4.1-nano";
|
|
337
|
+
var MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST = "~anthropic/claude-sonnet-latest";
|
|
338
|
+
var MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST = "~anthropic/claude-haiku-latest";
|
|
321
339
|
var MODEL_ANTHROPIC_CLAUDE_OPUS_4 = "anthropic/claude-opus-4";
|
|
322
340
|
var MODEL_ANTHROPIC_CLAUDE_SONNET_4 = "anthropic/claude-sonnet-4";
|
|
323
341
|
var MODEL_ANTHROPIC_CLAUDE_3_7_SONNET = "anthropic/claude-3.7-sonnet";
|
|
324
342
|
var MODEL_ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic/claude-3.5-sonnet";
|
|
325
343
|
var MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU = "anthropic/claude-haiku-4.5";
|
|
344
|
+
var MODEL_GOOGLE_GEMINI_PRO_LATEST = "~google/gemini-pro-latest";
|
|
345
|
+
var MODEL_GOOGLE_GEMINI_FLASH_LATEST = "~google/gemini-flash-latest";
|
|
326
346
|
var MODEL_GOOGLE_GEMINI_2_5_PRO = "google/gemini-2.5-pro";
|
|
327
347
|
var MODEL_GOOGLE_GEMINI_2_5_FLASH = "google/gemini-2.5-flash";
|
|
328
348
|
var MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025 = "google/gemini-2.5-flash-lite-preview-09-2025";
|
|
@@ -334,6 +354,11 @@ var AITuberOnAirChat = (() => {
|
|
|
334
354
|
MODEL_ZAI_GLM_4_5_AIR_FREE
|
|
335
355
|
];
|
|
336
356
|
var OPENROUTER_VISION_SUPPORTED_MODELS = [
|
|
357
|
+
MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
358
|
+
MODEL_OPENAI_GPT_LATEST,
|
|
359
|
+
MODEL_OPENAI_GPT_MINI_LATEST,
|
|
360
|
+
MODEL_OPENAI_GPT_5_5_PRO,
|
|
361
|
+
MODEL_OPENAI_GPT_5_5,
|
|
337
362
|
MODEL_OPENAI_GPT_5_1_CHAT,
|
|
338
363
|
MODEL_OPENAI_GPT_5_1_CODEX,
|
|
339
364
|
MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -341,10 +366,14 @@ var AITuberOnAirChat = (() => {
|
|
|
341
366
|
MODEL_OPENAI_GPT_4O,
|
|
342
367
|
MODEL_OPENAI_GPT_4_1_MINI,
|
|
343
368
|
MODEL_OPENAI_GPT_4_1_NANO,
|
|
369
|
+
MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
370
|
+
MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
344
371
|
MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
345
372
|
MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
346
373
|
MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
347
374
|
MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
375
|
+
MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
376
|
+
MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
348
377
|
MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
349
378
|
MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
350
379
|
MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -3883,10 +3912,16 @@ If it's in another language, summarize in that language.
|
|
|
3883
3912
|
*/
|
|
3884
3913
|
getSupportedModels() {
|
|
3885
3914
|
return [
|
|
3915
|
+
// OpenRouter routing
|
|
3916
|
+
MODEL_OPENROUTER_AUTO,
|
|
3886
3917
|
// Free models
|
|
3887
3918
|
MODEL_GPT_OSS_20B_FREE,
|
|
3888
3919
|
MODEL_ZAI_GLM_4_5_AIR_FREE,
|
|
3889
3920
|
// OpenAI models
|
|
3921
|
+
MODEL_OPENAI_GPT_LATEST,
|
|
3922
|
+
MODEL_OPENAI_GPT_MINI_LATEST,
|
|
3923
|
+
MODEL_OPENAI_GPT_5_5_PRO,
|
|
3924
|
+
MODEL_OPENAI_GPT_5_5,
|
|
3890
3925
|
MODEL_OPENAI_GPT_5_1_CHAT,
|
|
3891
3926
|
MODEL_OPENAI_GPT_5_1_CODEX,
|
|
3892
3927
|
MODEL_OPENAI_GPT_5_MINI,
|
|
@@ -3895,12 +3930,16 @@ If it's in another language, summarize in that language.
|
|
|
3895
3930
|
MODEL_OPENAI_GPT_4_1_MINI,
|
|
3896
3931
|
MODEL_OPENAI_GPT_4_1_NANO,
|
|
3897
3932
|
// Anthropic models
|
|
3933
|
+
MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST,
|
|
3934
|
+
MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST,
|
|
3898
3935
|
MODEL_ANTHROPIC_CLAUDE_OPUS_4,
|
|
3899
3936
|
MODEL_ANTHROPIC_CLAUDE_SONNET_4,
|
|
3900
3937
|
MODEL_ANTHROPIC_CLAUDE_3_7_SONNET,
|
|
3901
3938
|
MODEL_ANTHROPIC_CLAUDE_3_5_SONNET,
|
|
3902
3939
|
MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU,
|
|
3903
3940
|
// Gemini models
|
|
3941
|
+
MODEL_GOOGLE_GEMINI_PRO_LATEST,
|
|
3942
|
+
MODEL_GOOGLE_GEMINI_FLASH_LATEST,
|
|
3904
3943
|
MODEL_GOOGLE_GEMINI_2_5_PRO,
|
|
3905
3944
|
MODEL_GOOGLE_GEMINI_2_5_FLASH,
|
|
3906
3945
|
MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025,
|
|
@@ -3908,6 +3947,7 @@ If it's in another language, summarize in that language.
|
|
|
3908
3947
|
MODEL_ZAI_GLM_4_7_FLASH,
|
|
3909
3948
|
MODEL_ZAI_GLM_4_5_AIR,
|
|
3910
3949
|
// Other models
|
|
3950
|
+
MODEL_MOONSHOTAI_KIMI_LATEST,
|
|
3911
3951
|
MODEL_MOONSHOTAI_KIMI_K2_5
|
|
3912
3952
|
];
|
|
3913
3953
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var AITuberOnAirChat=(()=>{var
|
|
1
|
+
"use strict";var AITuberOnAirChat=(()=>{var Gt=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var Lo=Object.getOwnPropertyNames;var Po=Object.prototype.hasOwnProperty;var Io=(r,e)=>{for(var t in e)Gt(r,t,{get:e[t],enumerable:!0})},xo=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Lo(e))!Po.call(r,s)&&s!==t&&Gt(r,s,{get:()=>e[s],enumerable:!(o=yo(e,s))||o.enumerable});return r};var Ro=r=>xo(Gt({},"__esModule",{value:!0}),r);var os={};Io(os,{CHAT_RESPONSE_LENGTH:()=>S,CLAUDE_VISION_SUPPORTED_MODELS:()=>Ie,ChatServiceFactory:()=>Te,ChatServiceHttpClient:()=>_,ClaudeChatService:()=>le,ClaudeChatServiceProvider:()=>pe,DEFAULT_MAX_TOKENS:()=>no,DEFAULT_SUMMARY_PROMPT_TEMPLATE:()=>ko,DEFAULT_VISION_PROMPT:()=>Go,EMOTION_TAG_CLEANUP_REGEX:()=>po,EMOTION_TAG_REGEX:()=>fo,ENDPOINT_CLAUDE_API:()=>qt,ENDPOINT_GEMINI_API:()=>jt,ENDPOINT_KIMI_CHAT_COMPLETIONS_API:()=>re,ENDPOINT_OPENAI_CHAT_COMPLETIONS_API:()=>Y,ENDPOINT_OPENAI_RESPONSES_API:()=>x,ENDPOINT_OPENROUTER_API:()=>xe,ENDPOINT_XAI_CHAT_COMPLETIONS_API:()=>Ae,ENDPOINT_ZAI_CHAT_COMPLETIONS_API:()=>Re,EmotionParser:()=>ae,GEMINI_NANO_MAX_CONTEXT_MESSAGES:()=>lo,GEMINI_VISION_SUPPORTED_MODELS:()=>Pe,GPT5_PRESETS:()=>ao,GPT_5_MODELS:()=>uo,GeminiChatService:()=>ce,GeminiChatServiceProvider:()=>ue,GeminiNanoChatService:()=>he,GeminiNanoChatServiceProvider:()=>de,HttpError:()=>F,KIMI_VISION_SUPPORTED_MODELS:()=>_o,KimiChatService:()=>me,KimiChatServiceProvider:()=>ge,MAX_TOKENS_BY_LENGTH:()=>Dt,MODEL_ANTHROPIC_CLAUDE_3_5_SONNET:()=>Xt,MODEL_ANTHROPIC_CLAUDE_3_7_SONNET:()=>Mt,MODEL_ANTHROPIC_CLAUDE_4_5_HAIKU:()=>Ot,MODEL_ANTHROPIC_CLAUDE_HAIKU_LATEST:()=>_t,MODEL_ANTHROPIC_CLAUDE_OPUS_4:()=>ft,MODEL_ANTHROPIC_CLAUDE_SONNET_4:()=>vt,MODEL_ANTHROPIC_CLAUDE_SONNET_LATEST:()=>gt,MODEL_CLAUDE_3_5_HAIKU:()=>Ao,MODEL_CLAUDE_3_5_SONNET:()=>bo,MODEL_CLAUDE_3_7_SONNET:()=>Do,MODEL_CLAUDE_3_HAIKU:()=>ze,MODEL_CLAUDE_4_5_HAIKU:()=>R,MODEL_CLAUDE_4_5_OPUS:()=>Ye,MODEL_CLAUDE_4_5_SONNET:()=>Ze,MODEL_CLAUDE_4_6_OPUS:()=>et,MODEL_CLAUDE_4_6_SONNET:()=>Qe,MODEL_CLAUDE_4_7_OPUS:()=>tt,MODEL_CLAUDE_4_OPUS:()=>Je,MODEL_CLAUDE_4_SONNET:()=>Xe,MODEL_GEMINI_2_0_FLASH:()=>qe,MODEL_GEMINI_2_0_FLASH_LITE:()=>G,MODEL_GEMINI_2_5_FLASH:()=>Ke,MODEL_GEMINI_2_5_FLASH_LITE:()=>$e,MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17:()=>je,MODEL_GEMINI_2_5_PRO:()=>Be,MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW:()=>Ue,MODEL_GEMINI_3_1_PRO_PREVIEW:()=>Fe,MODEL_GEMINI_3_FLASH_PREVIEW:()=>We,MODEL_GEMINI_3_PRO_PREVIEW:()=>He,MODEL_GEMINI_NANO:()=>J,MODEL_GEMMA_4_26B_A4B_IT:()=>ke,MODEL_GEMMA_4_31B_IT:()=>Ge,MODEL_GLM_4_6:()=>io,MODEL_GLM_4_6V:()=>Pt,MODEL_GLM_4_6V_FLASH:()=>X,MODEL_GLM_4_6V_FLASHX:()=>It,MODEL_GLM_4_7:()=>oe,MODEL_GLM_4_7_FLASH:()=>so,MODEL_GLM_4_7_FLASHX:()=>oo,MODEL_GLM_5:()=>eo,MODEL_GLM_5_TURBO:()=>to,MODEL_GOOGLE_GEMINI_2_5_FLASH:()=>Tt,MODEL_GOOGLE_GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025:()=>yt,MODEL_GOOGLE_GEMINI_2_5_PRO:()=>Ct,MODEL_GOOGLE_GEMINI_FLASH_LATEST:()=>St,MODEL_GOOGLE_GEMINI_PRO_LATEST:()=>Et,MODEL_GPT_4O:()=>Ve,MODEL_GPT_4O_MINI:()=>j,MODEL_GPT_4_1:()=>De,MODEL_GPT_4_1_MINI:()=>Ne,MODEL_GPT_4_1_NANO:()=>we,MODEL_GPT_5:()=>ee,MODEL_GPT_5_1:()=>B,MODEL_GPT_5_4:()=>N,MODEL_GPT_5_4_MINI:()=>K,MODEL_GPT_5_4_NANO:()=>$,MODEL_GPT_5_4_PRO:()=>V,MODEL_GPT_5_5:()=>w,MODEL_GPT_5_MINI:()=>Q,MODEL_GPT_5_NANO:()=>W,MODEL_GPT_OSS_20B_FREE:()=>k,MODEL_GROK_4_1_FAST_NON_REASONING:()=>b,MODEL_GROK_4_1_FAST_REASONING:()=>At,MODEL_GROK_4_20_NON_REASONING:()=>Rt,MODEL_GROK_4_20_REASONING:()=>xt,MODEL_KIMI_K2_5:()=>bt,MODEL_KIMI_K2_6:()=>D,MODEL_MOONSHOTAI_KIMI_K2_5:()=>ot,MODEL_MOONSHOTAI_KIMI_LATEST:()=>st,MODEL_O1:()=>Ut,MODEL_O1_MINI:()=>Ft,MODEL_O3_MINI:()=>kt,MODEL_OPENAI_GPT_4O:()=>ht,MODEL_OPENAI_GPT_4_1_MINI:()=>dt,MODEL_OPENAI_GPT_4_1_NANO:()=>mt,MODEL_OPENAI_GPT_5_1_CHAT:()=>lt,MODEL_OPENAI_GPT_5_1_CODEX:()=>pt,MODEL_OPENAI_GPT_5_5:()=>at,MODEL_OPENAI_GPT_5_5_PRO:()=>nt,MODEL_OPENAI_GPT_5_MINI:()=>ct,MODEL_OPENAI_GPT_5_NANO:()=>ut,MODEL_OPENAI_GPT_LATEST:()=>it,MODEL_OPENAI_GPT_MINI_LATEST:()=>rt,MODEL_OPENROUTER_AUTO:()=>zt,MODEL_ZAI_GLM_4_5_AIR:()=>Zt,MODEL_ZAI_GLM_4_5_AIR_FREE:()=>Lt,MODEL_ZAI_GLM_4_7_FLASH:()=>Jt,OPENROUTER_CREDITS_THRESHOLD:()=>Vo,OPENROUTER_FREE_DAILY_LIMIT_HIGH_CREDITS:()=>wo,OPENROUTER_FREE_DAILY_LIMIT_LOW_CREDITS:()=>No,OPENROUTER_FREE_MODELS:()=>Yt,OPENROUTER_FREE_RATE_LIMIT_PER_MINUTE:()=>Qt,OPENROUTER_VISION_SUPPORTED_MODELS:()=>ho,OpenAIChatService:()=>U,OpenAIChatServiceProvider:()=>fe,OpenAICompatibleChatServiceProvider:()=>_e,OpenRouterChatService:()=>ve,OpenRouterChatServiceProvider:()=>Me,StreamTextAccumulator:()=>v,VISION_SUPPORTED_MODELS:()=>Le,XAIChatService:()=>Oe,XAIChatServiceProvider:()=>Ee,XAI_VISION_SUPPORTED_MODELS:()=>go,ZAIChatService:()=>Se,ZAIChatServiceProvider:()=>Ce,ZAI_VISION_SUPPORTED_MODELS:()=>mo,allowsReasoningLow:()=>$t,allowsReasoningMinimal:()=>Kt,allowsReasoningNone:()=>Bt,allowsReasoningXHigh:()=>Wt,buildOpenAICompatibleTools:()=>P,getDefaultReasoningEffortForGPT5Model:()=>A,getMaxTokensForResponseLength:()=>O,installGASFetch:()=>To,isGPT5Model:()=>q,isKimiVisionModel:()=>ne,isOpenRouterFreeModel:()=>z,isOpenRouterVisionModel:()=>te,isResponsesOnlyGPT5Model:()=>Ht,isXaiVisionModel:()=>ie,isZaiToolStreamModel:()=>ro,isZaiVisionModel:()=>se,parseOpenAICompatibleOneShot:()=>L,parseOpenAICompatibleTextStream:()=>T,parseOpenAICompatibleToolStream:()=>y,processChatWithOptionalTools:()=>f,refreshOpenRouterFreeModels:()=>Yo,resolveVisionModel:()=>E,runOnceText:()=>Wo,screenplayToText:()=>Ho,textToScreenplay:()=>vo,textsToScreenplay:()=>Uo});var Y="https://api.openai.com/v1/chat/completions",x="https://api.openai.com/v1/responses",W="gpt-5-nano",Q="gpt-5-mini",ee="gpt-5",B="gpt-5.1",N="gpt-5.4",w="gpt-5.5",K="gpt-5.4-mini",$="gpt-5.4-nano",V="gpt-5.4-pro",De="gpt-4.1",Ne="gpt-4.1-mini",we="gpt-4.1-nano",j="gpt-4o-mini",Ve="gpt-4o",kt="o3-mini",Ft="o1-mini",Ut="o1",Le=[W,Q,ee,B,N,w,K,$,V,De,Ne,we,j,Ve,"o1"],uo=[W,Q,ee,B,N,w,K,$,V];function q(r){return uo.includes(r)}function Ht(r){return r===V}function Wt(r){return r===w||r===N||r===K||r===$||r===V}function Bt(r){return r===B||r===N||r===w||r===K||r===$}function Kt(r){return r===W||r===Q||r===ee}function $t(r){return r!==V}function A(r){return r===B||r===N||r===w?"none":"medium"}var jt="https://generativelanguage.googleapis.com",Ge="gemma-4-31b-it",ke="gemma-4-26b-a4b-it",Fe="gemini-3.1-pro-preview",Ue="gemini-3.1-flash-lite-preview",He="gemini-3-pro-preview",We="gemini-3-flash-preview",Be="gemini-2.5-pro",Ke="gemini-2.5-flash",$e="gemini-2.5-flash-lite",je="gemini-2.5-flash-lite-preview-06-17",qe="gemini-2.0-flash",G="gemini-2.0-flash-lite",Pe=[Ge,ke,Fe,Ue,He,We,Be,Ke,$e,je,qe,G];var qt="https://api.anthropic.com/v1/messages",ze="claude-3-haiku-20240307",Ao="claude-3-5-haiku-20241022",bo="claude-3-5-sonnet-20241022",Do="claude-3-7-sonnet-20250219",Xe="claude-sonnet-4-20250514",Je="claude-opus-4-20250514",Ze="claude-sonnet-4-5-20250929",R="claude-haiku-4-5-20251001",Ye="claude-opus-4-5-20251101",Qe="claude-sonnet-4-6",et="claude-opus-4-6",tt="claude-opus-4-7",Ie=[ze,Xe,Je,Ze,R,Ye,Qe,et,tt];var xe="https://openrouter.ai/api/v1/chat/completions",zt="openrouter/auto",k="openai/gpt-oss-20b:free",ot="moonshotai/kimi-k2.5",st="~moonshotai/kimi-latest",it="~openai/gpt-latest",rt="~openai/gpt-mini-latest",nt="openai/gpt-5.5-pro",at="openai/gpt-5.5",lt="openai/gpt-5.1-chat",pt="openai/gpt-5.1-codex",ct="openai/gpt-5-mini",ut="openai/gpt-5-nano",ht="openai/gpt-4o",dt="openai/gpt-4.1-mini",mt="openai/gpt-4.1-nano",gt="~anthropic/claude-sonnet-latest",_t="~anthropic/claude-haiku-latest",ft="anthropic/claude-opus-4",vt="anthropic/claude-sonnet-4",Mt="anthropic/claude-3.7-sonnet",Xt="anthropic/claude-3.5-sonnet",Ot="anthropic/claude-haiku-4.5",Et="~google/gemini-pro-latest",St="~google/gemini-flash-latest",Ct="google/gemini-2.5-pro",Tt="google/gemini-2.5-flash",yt="google/gemini-2.5-flash-lite-preview-09-2025",Jt="z-ai/glm-4.7-flash",Zt="z-ai/glm-4.5-air",Lt="z-ai/glm-4.5-air:free",Yt=[k,Lt],ho=[st,it,rt,nt,at,lt,pt,ct,ut,ht,dt,mt,gt,_t,ft,vt,Mt,Ot,Et,St,Ct,Tt,yt,ot],Qt=20,No=50,wo=1e3,Vo=10;function z(r){return r.trim().endsWith(":free")}function te(r){return ho.some(e=>r.includes(e))}var Re="https://api.z.ai/api/paas/v4/chat/completions",eo="glm-5",to="glm-5-turbo",oe="glm-4.7",oo="glm-4.7-FlashX",so="glm-4.7-Flash",io="glm-4.6",Pt="glm-4.6V",It="glm-4.6V-FlashX",X="glm-4.6V-Flash",mo=[Pt,It,X];function se(r){return mo.includes(r)}function ro(r){return r.toLowerCase().startsWith("glm-4.6")}var Ae="https://api.x.ai/v1/chat/completions",xt="grok-4.20-0309-reasoning",Rt="grok-4.20-0309-non-reasoning",At="grok-4-1-fast-reasoning",b="grok-4-1-fast-non-reasoning",go=[xt,Rt,At,b];function ie(r){return go.includes(r)}var re="https://api.moonshot.ai/v1/chat/completions",D="kimi-k2.6",bt="kimi-k2.5",_o=[D,bt];function ne(r){return _o.includes(r)}var S={VERY_SHORT:"veryShort",SHORT:"short",MEDIUM:"medium",LONG:"long",VERY_LONG:"veryLong",DEEP:"deep"},Dt={[S.VERY_SHORT]:40,[S.SHORT]:100,[S.MEDIUM]:200,[S.LONG]:300,[S.VERY_LONG]:1e3,[S.DEEP]:5e3},no=5e3,ao={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 O(r){return r?Dt[r]??no:no}var Go="You are a friendly AI avatar. Comment on the situation based on the broadcast screen.",ko=`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 J="gemini-nano",
|
|
11
|
-
`);s=l.pop()||"";for(let u of l){let m=u.trim();if(!m||m.startsWith(":")||!m.startsWith("data:"))continue;let c=m.slice(5).trim();if(c==="[DONE]"){i=!0;break}e(c)}}};async function
|
|
12
|
-
`))!==-1;){let c=a.slice(0,m).trim();if(a=a.slice(m+1),!c.startsWith("data:"))continue;let d=c.slice(5).trim();if(d==="[DONE]")break;let p=JSON.parse(d);if(p.type==="content_block_delta"&&p.delta?.text&&(t(p.delta.text),i.push({type:"text",text:p.delta.text})),p.type==="content_block_start"&&p.content_block?.type==="tool_use"?n.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_use"?n.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:"",server_name:p.content_block.server_name}):p.type==="content_block_start"&&p.content_block?.type==="tool_result"?i.push({type:"tool_result",tool_use_id:p.content_block.tool_use_id,content:p.content_block.content??""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_result"&&i.push({type:"mcp_tool_result",tool_use_id:p.content_block.tool_use_id,is_error:p.content_block.is_error??!1,content:p.content_block.content??[]}),p.type==="content_block_delta"&&p.delta?.type==="input_json_delta"){let h=n.get(p.index);h&&(h.args+=p.delta.partial_json||"")}if(p.type==="content_block_stop"&&n.has(p.index)){let{id:h,name:M,args:S,server_name:g}=n.get(p.index);g?i.push({type:"mcp_tool_use",id:h,name:M,server_name:g,input:JSON.parse(S||"{}")}):i.push({type:"tool_use",id:h,name:M,input:JSON.parse(S||"{}")}),n.delete(p.index)}}}return{blocks:i,stop_reason:i.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(s=>s.type==="text").map(s=>s.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=()=>{},s){let i=await this.callClaude(e,this.model,t,s),n=t?await this.parseStream(i,o):this.parseOneShot(await i.json());return this.convertToStandardCompletion(n)}async visionChatOnce(e,t=!1,o=()=>{},s){let i=await this.callClaude(e,this.visionModel,t,s),n=t?await this.parseStream(i,o):this.parseOneShot(await i.json());return this.convertToStandardCompletion(n)}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 pe=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 le(e.apiKey,e.model||this.getDefaultModel(),t,e.tools??[],e.mcpServers??[],e.responseLength)}getProviderName(){return"claude"}getSupportedModels(){return[Xe,Je,Ze,b,Ye,Qe,et,tt,ze]}getDefaultModel(){return b}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return xe.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Lt=class{static async fetchToolSchemas(e){try{let t={"Content-Type":"application/json"};e.authorization_token&&(t.Authorization=`Bearer ${e.authorization_token}`);let s=await(await _.post(`${e.url}/tools`,{},t)).json();return Array.isArray(s.tools)?s.tools.map(i=>({name:`mcp_${e.name}_${i.name}`,description:i.description||`Tool from ${e.name} MCP server`,parameters:i.inputSchema||{type:"object",properties:{},required:[]}})):[{name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}]}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),[{name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server (schema fetch failed)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}]}}static async fetchAllToolSchemas(e){let t=[];for(let o of e)try{let s=await this.fetchToolSchemas(o);t.push(...s)}catch(s){console.error(`Failed to fetch schemas from ${o.name}:`,s)}return t}};var ce=class{constructor(e,t=k,o=k,s=[],i=[],n){this.provider="gemini";this.mcpToolSchemas=[];this.mcpSchemasInitialized=!1;this.callIdMap=new Map;if(this.apiKey=e,this.model=t,this.responseLength=n,!Pe.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o,this.tools=s,this.mcpServers=i}safeJsonParse(e){try{return JSON.parse(e)}catch{return e}}normalizeToolResult(e){return e===null?{content:null}:typeof e=="object"?e:{content:e}}isGemma4Model(e){return/^gemma-4-/.test(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,s])=>[t[o]??o,this.adaptKeysForApi(s)])):e}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e),this.mcpSchemasInitialized=!1}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e),this.mcpSchemasInitialized=!1}hasMCPServers(){return this.mcpServers.length>0}async initializeMCPSchemas(){if(!(this.mcpSchemasInitialized||this.mcpServers.length===0))try{let e=new Promise((o,s)=>setTimeout(()=>s(new Error("MCP schema fetch timeout")),5e3)),t=Lt.fetchAllToolSchemas(this.mcpServers);this.mcpToolSchemas=await Promise.race([t,e]),this.mcpSchemasInitialized=!0}catch(e){console.warn("Failed to initialize MCP schemas, using fallback:",e),this.mcpToolSchemas=this.mcpServers.map(t=>({name:`mcp_${t.name}_search`,description:`Search using ${t.name} MCP server (fallback)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}})),this.mcpSchemasInitialized=!0}}async processChat(e,t,o){try{await f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callGemini(e,this.model,!0),{blocks:i}=await this.parseStream(s,t,this.model);return v.getFullText(i)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use chatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processChat:",s),s}}async processVisionChat(e,t,o){try{await f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callGemini(e,this.visionModel,!0),{blocks:i}=await this.parseStream(s,t,this.visionModel);return v.getFullText(i)},runWithTools:()=>this.visionChatOnce(e),onToolBlocks:s=>{s.filter(i=>i.type==="text").forEach(i=>t(i.text))},onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use visionChatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processVisionChat:",s),s}}convertMessagesToGeminiFormat(e){let t=[],o=null,s=[],i=()=>{o&&s.length&&(t.push({role:o,parts:[...s]}),s=[])};for(let n of e){let a=this.mapRoleToGemini(n.role);if(n.tool_calls){i();for(let l of n.tool_calls)this.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(n.role==="tool"){i();let l=n.name??this.callIdMap.get(n.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:l,response:this.normalizeToolResult(this.safeJsonParse(n.content))}}]});continue}a!==o&&i(),o=a,s.push({text:n.content})}return i(),t}async callGemini(e,t,o=!1,s){let a={contents:e.some(g=>Array.isArray(g.content)&&g.content.some(x=>x?.type==="image_url"||x?.inlineData))?await this.convertVisionMessagesToGeminiFormat(e):this.convertMessagesToGeminiFormat(e),generationConfig:{maxOutputTokens:s!==void 0?s:O(this.responseLength)}};this.isGemma4Model(t)&&(a.generationConfig.thinkingConfig={includeThoughts:!1,thinkingLevel:"minimal"});let l=[];if(this.tools.length>0&&l.push(...this.tools.map(g=>({name:g.name,description:g.description,parameters:g.parameters}))),this.mcpServers.length>0)try{await this.initializeMCPSchemas(),l.push(...this.mcpToolSchemas.map(g=>({name:g.name,description:g.description,parameters:g.parameters})))}catch(g){console.warn("MCP initialization failed, skipping MCP tools:",g)}l.length>0&&(a.tools=[{functionDeclarations:l}],a.toolConfig={functionCallingConfig:{mode:"AUTO"}});let u=async(g,x)=>{let H=o?"streamGenerateContent":"generateContent",Te=o?"?alt=sse":"",Pt=`${kt}/${g}/models/${t}:${H}${Te}${Te?"&":"?"}key=${this.apiKey}`;return _.post(Pt,x)},m=/flash[-_]lite/.test(t),c=this.isGemma4Model(t),d=/gemini-2\.5/.test(t),p=/^gemini-3(?:\.[0-9]+)?-.*preview/.test(t),h=m||c||d||p,M=h?"v1beta":"v1",S=async()=>{try{let g=M==="v1"?a:this.adaptKeysForApi(a);return await u(M,g)}catch(g){let x=/Unknown name|Cannot find field|404/.test(g?.message||"")||g?.status===404;if(!h&&x)return await u("v1beta",this.adaptKeysForApi(a));throw g}};try{return await S()}catch(g){throw g.body&&(console.error("Gemini API Error Details:",g.body),console.error("Request Body:",JSON.stringify(a,null,2))),g}}async convertVisionMessagesToGeminiFormat(e){let t=[],o=null,s=[];for(let i of e){let n=this.mapRoleToGemini(i.role);if(i.tool_calls){for(let a of i.tool_calls)t.push({role:"model",parts:[{functionCall:{name:a.function.name,args:JSON.parse(a.function.arguments||"{}")}}]});continue}if(i.role==="tool"){let a=i.name??this.callIdMap.get(i.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:a,response:this.normalizeToolResult(this.safeJsonParse(i.content))}}]});continue}if(n!==o&&s.length>0&&(t.push({role:o,parts:[...s]}),s=[]),o=n,typeof i.content=="string")s.push({text:i.content});else if(Array.isArray(i.content)){for(let a of i.content)if(a.type==="text")s.push({text:a.text});else if(a.type==="image_url")try{let u=await(await _.get(a.image_url.url)).blob(),m=await this.blobToBase64(u);s.push({inlineData:{mimeType:u.type||"image/jpeg",data:m.split(",")[1]}})}catch(l){throw console.error("Error processing image:",l),new Error(`Failed to process image: ${l.message}`)}}}return o&&s.length>0&&t.push({role:o,parts:[...s]}),t}blobToBase64(e){return new Promise((t,o)=>{let s=new FileReader;s.onloadend=()=>t(s.result),s.onerror=o,s.readAsDataURL(e)})}mapRoleToGemini(e){switch(e){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}async parseStream(e,t,o){let s=e.body.getReader(),i=new TextDecoder,n=[],a=[],l="",u=c=>{if(!c||c==="[DONE]")return;let d;try{d=JSON.parse(c)}catch{return}for(let p of d.candidates??[])for(let h of p.content?.parts??[])this.shouldExposeTextPart(h,o)&&(t(h.text),v.addTextBlock(n,h.text)),h.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:h.functionCall.name,input:h.functionCall.args??{}}),h.functionResponse&&a.push({type:"tool_result",tool_use_id:h.functionResponse.name,content:JSON.stringify(h.functionResponse.response)})};for(;;){let{done:c,value:d}=await s.read();if(c)break;l+=i.decode(d,{stream:!0});let p;for(;(p=l.indexOf(`
|
|
13
|
-
`))!==-1;){let h=l.slice(0,p);if(l=l.slice(p+1),h.endsWith("\r")&&(h=h.slice(0,-1)),!h.trim()){u("");continue}h.startsWith("data:")&&(h=h.slice(5).trim()),h&&u(h)}}return l&&u(l),{blocks:[...n,...a],stop_reason:a.some(c=>c.type==="tool_use")?"tool_use":"end"}}parseOneShot(e,t){let o=[],s=[];for(let n of e.candidates??[])for(let a of n.content?.parts??[])this.shouldExposeTextPart(a,t)&&o.push({type:"text",text:a.text}),a.functionCall&&s.push({type:"tool_use",id:this.genUUID(),name:a.functionCall.name,input:a.functionCall.args??{}}),a.functionResponse&&s.push({type:"tool_result",tool_use_id:a.functionResponse.name,content:JSON.stringify(a.functionResponse.response)});return{blocks:[...o,...s],stop_reason:s.some(n=>n.type==="tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},s){let i=await this.callGemini(e,this.model,t,s);return t?this.parseStream(i,o,this.model):this.parseOneShot(await i.json(),this.model)}async visionChatOnce(e,t=!1,o=()=>{},s){let i=await this.callGemini(e,this.visionModel,t,s);return t?this.parseStream(i,o,this.visionModel):this.parseOneShot(await i.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 ue=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 ce(e.apiKey,e.model||this.getDefaultModel(),t,e.tools||[],e.mcpServers||[],e.responseLength)}getProviderName(){return"gemini"}getSupportedModels(){return[ke,
|
|
10
|
+
`;var J="gemini-nano",lo=20;var F=class extends Error{constructor(t,o,s){super(`HTTP ${t}: ${o}`);this.status=t;this.statusText=o;this.body=s;this.name="HttpError"}},be=class be{static setFetch(e){this.fetchImpl=e}static async post(e,t,o={},s={}){let{timeout:i=3e4,retries:n=0,retryDelay:a=1e3}=s,u={...{"Content-Type":"application/json"},...o},m=null;for(let c=0;c<=n;c++)try{let d=typeof AbortController<"u",p=d?new AbortController:void 0,h=d?setTimeout(()=>p.abort(),i):void 0,M=await be.fetchImpl(e,{method:"POST",headers:u,body:typeof t=="string"?t:JSON.stringify(t),...p?{signal:p.signal}:{}});if(h&&clearTimeout(h),!M.ok){let C=await M.text();throw new F(M.status,M.statusText,C)}return M}catch(d){if(m=d,d instanceof F&&d.status>=400&&d.status<500)throw d;if(d instanceof Error&&d.name==="AbortError")throw new Error(`Request timeout after ${i}ms`);c<n&&await new Promise(p=>setTimeout(p,a*(c+1)))}throw m||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:s=3e4,retries:i=0,retryDelay:n=1e3}=o,a=null;for(let l=0;l<=i;l++)try{let u=typeof AbortController<"u",m=u?new AbortController:void 0,c=u?setTimeout(()=>m.abort(),s):void 0,d=await be.fetchImpl(e,{method:"GET",headers:t,...m?{signal:m.signal}:{}});if(c&&clearTimeout(c),!d.ok){let p=await d.text();throw new F(d.status,d.statusText,p)}return d}catch(u){if(a=u,u instanceof F&&u.status>=400&&u.status<500)throw u;if(u instanceof Error&&u.name==="AbortError")throw new Error(`Request timeout after ${s}ms`);l<i&&await new Promise(m=>setTimeout(m,n*(l+1)))}throw a||new Error("Request failed")}};be.fetchImpl=(e,t)=>fetch(e,t);var _=be;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 Fo=["happy","sad","angry","surprised","neutral"],fo=/\[([a-z]+)\]/i,po=/\[[a-z]+\]\s*/gi,ae=class{static extractEmotion(e){let t=e.match(fo);if(t){let o=t[1].toLowerCase(),s=e.replace(po,"").trim();return{emotion:o,cleanText:s}}return{cleanText:e}}static isValidEmotion(e){return Fo.includes(e)}static cleanEmotionTags(e){return e.replace(po,"").trim()}static addEmotionTag(e,t){return`[${e}] ${t}`}};function vo(r){let{emotion:e,cleanText:t}=ae.extractEmotion(r);return e?{emotion:e,text:t}:{text:t}}function Uo(r){return r.map(e=>vo(e))}function Ho(r){return r.emotion?ae.addEmotionTag(r.emotion,r.text):r.text}async function Wo(r,e){let{blocks:t}=await r.chatOnce(e,!1,()=>{});return v.getFullText(t)}var Mo=(r,e)=>{try{return JSON.parse(r)}catch(t){if(e){e(r,t);return}throw t}},Oo=async(r,e)=>{let t=r.body?.getReader();if(!t)throw new Error("Response body is null.");let o=new TextDecoder,s="",i=!1;for(;!i;){let{done:n,value:a}=await t.read();if(n)break;s+=o.decode(a,{stream:!0});let l=s.split(`
|
|
11
|
+
`);s=l.pop()||"";for(let u of l){let m=u.trim();if(!m||m.startsWith(":")||!m.startsWith("data:"))continue;let c=m.slice(5).trim();if(c==="[DONE]"){i=!0;break}e(c)}}};async function T(r,e,t={}){let o="";return await Oo(r,s=>{let i=Mo(s,t.onJsonError);if(!i)return;let n=i.choices?.[0]?.delta?.content||"";n&&(e(n),o+=n)}),o}async function y(r,e,t={}){let o=[],s=new Map,i,n,a=t.appendTextBlock??v.append;await Oo(r,m=>{let c=Mo(m,t.onJsonError);if(!c)return;let d=c.choices?.[0];typeof d?.finish_reason=="string"&&(i=d.finish_reason),c.usage&&(n=c.usage);let p=d?.delta;p?.content&&(e(p.content),a(o,p.content)),p?.tool_calls&&p.tool_calls.forEach(h=>{let M=s.get(h.index)??{id:h.id,name:h.function?.name,args:""};M.args+=h.function?.arguments||"",s.set(h.index,M)})});let l=Array.from(s.entries()).sort((m,c)=>m[0]-c[0]).map(([m,c])=>({type:"tool_use",id:c.id,name:c.name,input:JSON.parse(c.args||"{}")}));return{blocks:[...o,...l],stop_reason:l.length?"tool_use":"end",truncated:i==="length",finish_reason:i,usage:n}}function L(r){let e=r?.choices?.[0],t=[];return e?.message?.tool_calls?.length?e.message.tool_calls.forEach(o=>t.push({type:"tool_use",id:o.id,name:o.function?.name,input:JSON.parse(o.function?.arguments||"{}")})):e?.message?.content&&t.push({type:"text",text:e.message.content}),{blocks:t,stop_reason:e?.finish_reason==="tool_calls"||t.some(o=>o.type==="tool_use")?"tool_use":"end",truncated:e?.finish_reason==="length",finish_reason:e?.finish_reason,usage:r?.usage}}var P=(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 f(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 Bo="https://openrouter.ai/api/v1/models",Ko=2,$o=12e3,jo=1,qo=10;function co(r){return r instanceof Error?r.message:String(r)}function Nt(r,e){return typeof r!="number"||!Number.isFinite(r)?e:Math.max(1,Math.floor(r))}function zo(r){let e=new Set,t=[];for(let o of r){let s=o.trim();!s||e.has(s)||(e.add(s),t.push(s))}return t}async function Eo(r,e,t){if(!(typeof AbortController<"u"))return fetch(r,e);let s=new AbortController,i=setTimeout(()=>s.abort(),t);try{return await fetch(r,{...e,signal:s.signal})}catch(n){throw n instanceof Error&&n.name==="AbortError"?new Error(`Timeout after ${t}ms`):n}finally{clearTimeout(i)}}async function So(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 Xo(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(s=>s.id).filter(s=>typeof s=="string");return zo(o)}async function Jo({modelId:r,apiKey:e,endpoint:t,timeoutMs:o,appName:s,appUrl:i}){let n={Authorization:`Bearer ${e}`,"Content-Type":"application/json"};s&&(n["X-Title"]=s),i&&(n["HTTP-Referer"]=i);try{let a=await Eo(t,{method:"POST",headers:n,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 So(a)};try{await a.json()}catch(l){return{id:r,ok:!1,reason:`JSON parse failed: ${co(l)}`}}return{id:r,ok:!0}}catch(a){return{id:r,ok:!1,reason:co(a)}}}async function Zo(r,e,t){if(r.length===0)return[];let o=new Array(r.length),s=0,i=Math.min(e,r.length);return await Promise.all(Array.from({length:i},async()=>{for(;s<r.length;){let n=s;s+=1,o[n]=await t(r[n])}})),o}async function Yo(r){let e=r.apiKey.trim();if(!e)throw new Error("OpenRouter API key is required.");let t=r.modelsEndpoint||Bo,o=r.endpoint||xe,s=Nt(r.timeoutMs,$o),i=Nt(r.concurrency,Ko),n=Nt(r.maxCandidates,jo),a=Nt(r.maxWorking,qo),l=await Eo(t,{method:"GET"},s);if(!l.ok)throw new Error(await So(l));let u;try{u=await l.json()}catch(h){throw new Error(`JSON parse failed: ${co(h)}`)}let m=Xo(u).filter(h=>z(h)).slice(0,n),c=await Zo(m,i,h=>Jo({modelId:h,apiKey:e,endpoint:o,timeoutMs:s,appName:r.appName,appUrl:r.appUrl})),d=c.filter(h=>h.ok).map(h=>h.id).slice(0,a),p=c.filter(h=>!h.ok).map(h=>({id:h.id,reason:h.reason||"Unknown error"}));return{working:d,failed:p,fetchedAt:Date.now()}}var le=class{constructor(e,t=R,o=R,s=[],i=[],n){this.provider="claude";if(this.apiKey=e,this.model=t||R,this.visionModel=o||R,this.tools=s,this.mcpServers=i,this.responseLength=n,!Ie.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 f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callClaude(e,this.model,!0);return this.parsePureStream(s,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 f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callClaude(e,this.visionModel,!0);return this.parsePureStream(s,t)},runWithTools:()=>this.visionChatOnce(e),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use chatOnce() loop when tools are enabled."})}convertMessagesToClaudeFormat(e){return e.map(t=>({role:this.mapRoleToClaude(t.role),content:t.content}))}convertVisionMessagesToClaudeFormat(e){return e.map(t=>{if(typeof t.content=="string")return{role:this.mapRoleToClaude(t.role),content:[{type:"text",text:t.content}]};if(Array.isArray(t.content)){let o=t.content.map(s=>{if(s.type==="image_url"){if(s.image_url.url.startsWith("data:")){let i=s.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:s.image_url.url,media_type:this.getMimeTypeFromUrl(s.image_url.url)}}}return s}).filter(s=>s);return{role:this.mapRoleToClaude(t.role),content:o}}return{role:this.mapRoleToClaude(t.role),content:[]}})}mapRoleToClaude(e){switch(e){case"system":return"system";case"user":return"user";case"assistant":return"assistant";default:return"user"}}getMimeTypeFromUrl(e){switch(e.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"}}async callClaude(e,t,o,s){let i=e.find(c=>c.role==="system")?.content??"",n=e.filter(c=>c.role!=="system"),a=n.some(c=>Array.isArray(c.content)&&c.content.some(d=>d.type==="image_url"||d.type==="image")),l={model:t,system:i,messages:a?this.convertVisionMessagesToClaudeFormat(n):this.convertMessagesToClaudeFormat(n),stream:o,max_tokens:s!==void 0?s:O(this.responseLength)};this.tools.length&&(l.tools=this.tools.map(c=>({name:c.name,description:c.description,input_schema:c.parameters})),l.tool_choice={type:"auto"}),this.mcpServers.length>0&&(l.mcp_servers=this.mcpServers);let u={"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&&(u["anthropic-beta"]="mcp-client-2025-04-04"),await _.post(qt,l,u)}async parseStream(e,t){let o=e.body.getReader(),s=new TextDecoder,i=[],n=new Map,a="";for(;;){let{done:l,value:u}=await o.read();if(l)break;a+=s.decode(u,{stream:!0});let m;for(;(m=a.indexOf(`
|
|
12
|
+
`))!==-1;){let c=a.slice(0,m).trim();if(a=a.slice(m+1),!c.startsWith("data:"))continue;let d=c.slice(5).trim();if(d==="[DONE]")break;let p=JSON.parse(d);if(p.type==="content_block_delta"&&p.delta?.text&&(t(p.delta.text),i.push({type:"text",text:p.delta.text})),p.type==="content_block_start"&&p.content_block?.type==="tool_use"?n.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_use"?n.set(p.index,{id:p.content_block.id,name:p.content_block.name,args:"",server_name:p.content_block.server_name}):p.type==="content_block_start"&&p.content_block?.type==="tool_result"?i.push({type:"tool_result",tool_use_id:p.content_block.tool_use_id,content:p.content_block.content??""}):p.type==="content_block_start"&&p.content_block?.type==="mcp_tool_result"&&i.push({type:"mcp_tool_result",tool_use_id:p.content_block.tool_use_id,is_error:p.content_block.is_error??!1,content:p.content_block.content??[]}),p.type==="content_block_delta"&&p.delta?.type==="input_json_delta"){let h=n.get(p.index);h&&(h.args+=p.delta.partial_json||"")}if(p.type==="content_block_stop"&&n.has(p.index)){let{id:h,name:M,args:C,server_name:g}=n.get(p.index);g?i.push({type:"mcp_tool_use",id:h,name:M,server_name:g,input:JSON.parse(C||"{}")}):i.push({type:"tool_use",id:h,name:M,input:JSON.parse(C||"{}")}),n.delete(p.index)}}}return{blocks:i,stop_reason:i.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(s=>s.type==="text").map(s=>s.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=()=>{},s){let i=await this.callClaude(e,this.model,t,s),n=t?await this.parseStream(i,o):this.parseOneShot(await i.json());return this.convertToStandardCompletion(n)}async visionChatOnce(e,t=!1,o=()=>{},s){let i=await this.callClaude(e,this.visionModel,t,s),n=t?await this.parseStream(i,o):this.parseOneShot(await i.json());return this.convertToStandardCompletion(n)}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 pe=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 le(e.apiKey,e.model||this.getDefaultModel(),t,e.tools??[],e.mcpServers??[],e.responseLength)}getProviderName(){return"claude"}getSupportedModels(){return[Xe,Je,Ze,R,Ye,Qe,et,tt,ze]}getDefaultModel(){return R}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Ie.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var wt=class{static async fetchToolSchemas(e){try{let t={"Content-Type":"application/json"};e.authorization_token&&(t.Authorization=`Bearer ${e.authorization_token}`);let s=await(await _.post(`${e.url}/tools`,{},t)).json();return Array.isArray(s.tools)?s.tools.map(i=>({name:`mcp_${e.name}_${i.name}`,description:i.description||`Tool from ${e.name} MCP server`,parameters:i.inputSchema||{type:"object",properties:{},required:[]}})):[{name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}]}catch(t){return console.warn(`Failed to fetch MCP schemas from ${e.name}:`,t),[{name:`mcp_${e.name}_search`,description:`Search using ${e.name} MCP server (schema fetch failed)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}}]}}static async fetchAllToolSchemas(e){let t=[];for(let o of e)try{let s=await this.fetchToolSchemas(o);t.push(...s)}catch(s){console.error(`Failed to fetch schemas from ${o.name}:`,s)}return t}};var ce=class{constructor(e,t=G,o=G,s=[],i=[],n){this.provider="gemini";this.mcpToolSchemas=[];this.mcpSchemasInitialized=!1;this.callIdMap=new Map;if(this.apiKey=e,this.model=t,this.responseLength=n,!Pe.includes(o))throw new Error(`Model ${o} does not support vision capabilities.`);this.visionModel=o,this.tools=s,this.mcpServers=i}safeJsonParse(e){try{return JSON.parse(e)}catch{return e}}normalizeToolResult(e){return e===null?{content:null}:typeof e=="object"?e:{content:e}}isGemma4Model(e){return/^gemma-4-/.test(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,s])=>[t[o]??o,this.adaptKeysForApi(s)])):e}getModel(){return this.model}getVisionModel(){return this.visionModel}getMCPServers(){return this.mcpServers}addMCPServer(e){this.mcpServers.push(e),this.mcpSchemasInitialized=!1}removeMCPServer(e){this.mcpServers=this.mcpServers.filter(t=>t.name!==e),this.mcpSchemasInitialized=!1}hasMCPServers(){return this.mcpServers.length>0}async initializeMCPSchemas(){if(!(this.mcpSchemasInitialized||this.mcpServers.length===0))try{let e=new Promise((o,s)=>setTimeout(()=>s(new Error("MCP schema fetch timeout")),5e3)),t=wt.fetchAllToolSchemas(this.mcpServers);this.mcpToolSchemas=await Promise.race([t,e]),this.mcpSchemasInitialized=!0}catch(e){console.warn("Failed to initialize MCP schemas, using fallback:",e),this.mcpToolSchemas=this.mcpServers.map(t=>({name:`mcp_${t.name}_search`,description:`Search using ${t.name} MCP server (fallback)`,parameters:{type:"object",properties:{query:{type:"string",description:"Search query"}},required:["query"]}})),this.mcpSchemasInitialized=!0}}async processChat(e,t,o){try{await f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callGemini(e,this.model,!0),{blocks:i}=await this.parseStream(s,t,this.model);return v.getFullText(i)},runWithTools:()=>this.chatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use chatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processChat:",s),s}}async processVisionChat(e,t,o){try{await f({hasTools:this.tools.length>0||this.mcpServers.length>0,runWithoutTools:async()=>{let s=await this.callGemini(e,this.visionModel,!0),{blocks:i}=await this.parseStream(s,t,this.visionModel);return v.getFullText(i)},runWithTools:()=>this.visionChatOnce(e),onToolBlocks:s=>{s.filter(i=>i.type==="text").forEach(i=>t(i.text))},onCompleteResponse:o,toolErrorMessage:"Received functionCall. Use visionChatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processVisionChat:",s),s}}convertMessagesToGeminiFormat(e){let t=[],o=null,s=[],i=()=>{o&&s.length&&(t.push({role:o,parts:[...s]}),s=[])};for(let n of e){let a=this.mapRoleToGemini(n.role);if(n.tool_calls){i();for(let l of n.tool_calls)this.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(n.role==="tool"){i();let l=n.name??this.callIdMap.get(n.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:l,response:this.normalizeToolResult(this.safeJsonParse(n.content))}}]});continue}a!==o&&i(),o=a,s.push({text:n.content})}return i(),t}async callGemini(e,t,o=!1,s){let a={contents:e.some(g=>Array.isArray(g.content)&&g.content.some(I=>I?.type==="image_url"||I?.inlineData))?await this.convertVisionMessagesToGeminiFormat(e):this.convertMessagesToGeminiFormat(e),generationConfig:{maxOutputTokens:s!==void 0?s:O(this.responseLength)}};this.isGemma4Model(t)&&(a.generationConfig.thinkingConfig={includeThoughts:!1,thinkingLevel:"minimal"});let l=[];if(this.tools.length>0&&l.push(...this.tools.map(g=>({name:g.name,description:g.description,parameters:g.parameters}))),this.mcpServers.length>0)try{await this.initializeMCPSchemas(),l.push(...this.mcpToolSchemas.map(g=>({name:g.name,description:g.description,parameters:g.parameters})))}catch(g){console.warn("MCP initialization failed, skipping MCP tools:",g)}l.length>0&&(a.tools=[{functionDeclarations:l}],a.toolConfig={functionCallingConfig:{mode:"AUTO"}});let u=async(g,I)=>{let H=o?"streamGenerateContent":"generateContent",ye=o?"?alt=sse":"",Vt=`${jt}/${g}/models/${t}:${H}${ye}${ye?"&":"?"}key=${this.apiKey}`;return _.post(Vt,I)},m=/flash[-_]lite/.test(t),c=this.isGemma4Model(t),d=/gemini-2\.5/.test(t),p=/^gemini-3(?:\.[0-9]+)?-.*preview/.test(t),h=m||c||d||p,M=h?"v1beta":"v1",C=async()=>{try{let g=M==="v1"?a:this.adaptKeysForApi(a);return await u(M,g)}catch(g){let I=/Unknown name|Cannot find field|404/.test(g?.message||"")||g?.status===404;if(!h&&I)return await u("v1beta",this.adaptKeysForApi(a));throw g}};try{return await C()}catch(g){throw g.body&&(console.error("Gemini API Error Details:",g.body),console.error("Request Body:",JSON.stringify(a,null,2))),g}}async convertVisionMessagesToGeminiFormat(e){let t=[],o=null,s=[];for(let i of e){let n=this.mapRoleToGemini(i.role);if(i.tool_calls){for(let a of i.tool_calls)t.push({role:"model",parts:[{functionCall:{name:a.function.name,args:JSON.parse(a.function.arguments||"{}")}}]});continue}if(i.role==="tool"){let a=i.name??this.callIdMap.get(i.tool_call_id)??"result";t.push({role:"user",parts:[{functionResponse:{name:a,response:this.normalizeToolResult(this.safeJsonParse(i.content))}}]});continue}if(n!==o&&s.length>0&&(t.push({role:o,parts:[...s]}),s=[]),o=n,typeof i.content=="string")s.push({text:i.content});else if(Array.isArray(i.content)){for(let a of i.content)if(a.type==="text")s.push({text:a.text});else if(a.type==="image_url")try{let u=await(await _.get(a.image_url.url)).blob(),m=await this.blobToBase64(u);s.push({inlineData:{mimeType:u.type||"image/jpeg",data:m.split(",")[1]}})}catch(l){throw console.error("Error processing image:",l),new Error(`Failed to process image: ${l.message}`)}}}return o&&s.length>0&&t.push({role:o,parts:[...s]}),t}blobToBase64(e){return new Promise((t,o)=>{let s=new FileReader;s.onloadend=()=>t(s.result),s.onerror=o,s.readAsDataURL(e)})}mapRoleToGemini(e){switch(e){case"system":return"model";case"user":return"user";case"assistant":return"model";default:return"user"}}async parseStream(e,t,o){let s=e.body.getReader(),i=new TextDecoder,n=[],a=[],l="",u=c=>{if(!c||c==="[DONE]")return;let d;try{d=JSON.parse(c)}catch{return}for(let p of d.candidates??[])for(let h of p.content?.parts??[])this.shouldExposeTextPart(h,o)&&(t(h.text),v.addTextBlock(n,h.text)),h.functionCall&&a.push({type:"tool_use",id:this.genUUID(),name:h.functionCall.name,input:h.functionCall.args??{}}),h.functionResponse&&a.push({type:"tool_result",tool_use_id:h.functionResponse.name,content:JSON.stringify(h.functionResponse.response)})};for(;;){let{done:c,value:d}=await s.read();if(c)break;l+=i.decode(d,{stream:!0});let p;for(;(p=l.indexOf(`
|
|
13
|
+
`))!==-1;){let h=l.slice(0,p);if(l=l.slice(p+1),h.endsWith("\r")&&(h=h.slice(0,-1)),!h.trim()){u("");continue}h.startsWith("data:")&&(h=h.slice(5).trim()),h&&u(h)}}return l&&u(l),{blocks:[...n,...a],stop_reason:a.some(c=>c.type==="tool_use")?"tool_use":"end"}}parseOneShot(e,t){let o=[],s=[];for(let n of e.candidates??[])for(let a of n.content?.parts??[])this.shouldExposeTextPart(a,t)&&o.push({type:"text",text:a.text}),a.functionCall&&s.push({type:"tool_use",id:this.genUUID(),name:a.functionCall.name,input:a.functionCall.args??{}}),a.functionResponse&&s.push({type:"tool_result",tool_use_id:a.functionResponse.name,content:JSON.stringify(a.functionResponse.response)});return{blocks:[...o,...s],stop_reason:s.some(n=>n.type==="tool_use")?"tool_use":"end"}}async chatOnce(e,t=!0,o=()=>{},s){let i=await this.callGemini(e,this.model,t,s);return t?this.parseStream(i,o,this.model):this.parseOneShot(await i.json(),this.model)}async visionChatOnce(e,t=!1,o=()=>{},s){let i=await this.callGemini(e,this.visionModel,t,s);return t?this.parseStream(i,o,this.visionModel):this.parseOneShot(await i.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 ue=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 ce(e.apiKey,e.model||this.getDefaultModel(),t,e.tools||[],e.mcpServers||[],e.responseLength)}getProviderName(){return"gemini"}getSupportedModels(){return[Ge,ke,Fe,Ue,He,We,Be,Ke,$e,je,qe,G]}getDefaultModel(){return G}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Pe.includes(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};function Qo(){if(typeof globalThis<"u"&&"LanguageModel"in globalThis)return globalThis.LanguageModel}var he=class{constructor(e={}){this.provider="gemini-nano";this.expectedInputLanguages=e.expectedInputLanguages??["ja"],this.expectedOutputLanguages=e.expectedOutputLanguages??["ja"],this._responseLength=e.responseLength}getModel(){return J}getVisionModel(){return J}async processChat(e,t,o){let s=await this.generateResponse(e);t(s),await o(s)}async processVisionChat(e,t,o){throw new Error("Gemini Nano does not support vision capabilities.")}async chatOnce(e,t=!1,o=()=>{},s){let i=await this.generateResponse(e);return o(i),{blocks:[{type:"text",text:i}],stop_reason:"end"}}async visionChatOnce(e,t=!1,o=()=>{},s){throw new Error("Gemini Nano does not support vision capabilities.")}async generateResponse(e){let t=Qo();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 i=e.filter(u=>u.role==="system").map(u=>u.content).join(`
|
|
14
14
|
`),n=e.filter(u=>u.role!=="system").slice(-20),a=[...n].reverse().find(u=>u.role==="user");if(!a)throw new Error("No user message found in the provided messages.");let l=await this.createSession(t,i,n);try{return await l.prompt(a.content)}finally{try{l.destroy()}catch{}}}async createSession(e,t,o){let s=this.buildSystemPrompt(t),i=o.slice(0,-1);if(i.length>0){let n=i.map(a=>`${a.role==="user"?"User":"Assistant"}: ${a.content}`).join(`
|
|
15
15
|
`);s+=`
|
|
16
16
|
|
|
17
17
|
The following is the prior conversation history. Use it as context for your response:
|
|
18
18
|
`+n}return e.create({systemPrompt:s,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(`
|
|
19
19
|
|
|
20
|
-
`)}getResponseLengthInstruction(){if(!this._responseLength)return;let e=
|
|
21
|
-
`);m=g.pop()||"";for(let x=0;x<g.length;x++){let H=g[x].trim();if(H.startsWith("event:"))M=H.slice(6).trim();else if(H.startsWith("data:"))S=H.slice(5).trim();else if(H===""&&M&&S){try{let Te=JSON.parse(S),Pt=this.handleResponsesSSEEvent(M,Te,t,i,n,Z=>{Z.responseStatus!==void 0&&(a=Z.responseStatus),Z.incompleteDetails!==void 0&&(l=Z.incompleteDetails),Z.usage!==void 0&&(u=Z.usage)})}catch{console.warn("Failed to parse SSE data:",S)}M="",S=""}}}let c=Array.from(n.values()).map(p=>({type:"tool_use",id:p.id,name:p.name,input:p.input||{}}));return{blocks:[...i,...c],stop_reason:c.length?"tool_use":"end",truncated:a==="incomplete",response_status:a,incomplete_details:l,usage:u}}handleResponsesSSEEvent(e,t,o,s,i,n){switch(e){case"response.output_item.added":t.item?.type==="message"&&Array.isArray(t.item.content)?t.item.content.forEach(a=>{a.type==="output_text"&&a.text&&(o(a.text),v.append(s,a.text))}):t.item?.type==="function_call"&&i.set(t.item.id,{id:t.item.id,name:t.item.name,input:t.item.arguments?JSON.parse(t.item.arguments):{}});break;case"response.content_part.added":t.part?.type==="output_text"&&typeof t.part.text=="string"&&(o(t.part.text),v.append(s,t.part.text));break;case"response.output_text.delta":case"response.content_part.delta":{let a=typeof t.delta=="string"?t.delta:t.delta?.text??"";a&&(o(a),v.append(s,a))}break;case"response.output_text.done":case"response.content_part.done":break;case"response.completed":return n(this.extractResponsesMetadata(t,"completed")),"completed";case"response.incomplete":return n(this.extractResponsesMetadata(t,"incomplete")),"completed";case"response.reasoning.started":case"response.reasoning.delta":case"response.reasoning.done":break;default:break}}extractResponsesMetadata(e,t){let o=e?.response??e;return{responseStatus:o?.status??t,incompleteDetails:o?.incomplete_details??null,usage:o?.usage}}parseResponsesOneShot(e){let t=[];return e.output&&Array.isArray(e.output)&&e.output.forEach(o=>{o.type==="message"&&o.content&&o.content.forEach(s=>{s.type==="output_text"&&s.text&&t.push({type:"text",text:s.text})}),o.type==="function_call"&&t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments?JSON.parse(o.arguments):{}})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use")?"tool_use":"end",truncated:e?.status==="incomplete",response_status:e?.status,incomplete_details:e?.incomplete_details??null,usage:e?.usage}}};var _e=class{createChatService(e){return this.validateRequiredOptions(e),new U(e.apiKey?.trim()??"",e.model,e.visionModel??e.model,e.tools,e.endpoint,[],e.responseLength,e.verbosity,e.reasoning_effort,e.enableReasoningSummary,this.getProviderName(),!1)}getProviderName(){return"openai-compatible"}getSupportedModels(){return[]}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"unknown"}supportsVisionForModel(e){return!0}getVisionSupportLevelForModel(e){return"unknown"}getDefaultModel(){return"local-model"}validateRequiredOptions(e){if(e.mcpServers!==void 0)throw new Error("openai-compatible provider does not support mcpServers.");let t=e.endpoint?.trim();if(!t)throw new Error("openai-compatible provider requires endpoint (full URL).");let o;try{o=new URL(t)}catch{throw new Error("openai-compatible provider requires endpoint to be a full URL.")}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error("openai-compatible provider requires endpoint to be a full URL.");if(!e.model?.trim())throw new Error("openai-compatible provider requires model.")}};var fe=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=E({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:u=>this.supportsVisionForModel(u),validate:"resolved"}),s=t.tools,i=t.mcpServers??[],n=t.model||this.getDefaultModel(),a=!1;i.length>0||At(n)?a=!0:q(n)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?I:Y);return new U(t.apiKey,n,o,s,l,i,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName())}getProviderName(){return"openai"}getSupportedModels(){return[W,Q,ee,B,N,w,K,$,V,De,Ne,we,j,Ve,It,bt,"o1"]}getDefaultModel(){return W}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Le.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 s=Zt[e.gpt5Preset];o.reasoning_effort=s.reasoning_effort,o.verbosity=s.verbosity}else e.reasoning_effort||(o.reasoning_effort=R(t));return o.reasoning_effort=this.normalizeReasoningEffort(t,o.reasoning_effort),o}normalizeReasoningEffort(e,t){if(t)return t==="none"&&!Nt(e)?R(e):t==="minimal"&&!wt(e)?R(e):t==="low"&&!Vt(e)?R(e):t==="xhigh"&&!Dt(e)?R(e):t}};var ve=class{constructor(e,t=G,o=G,s,i=Ie,n,a,l,u,m,c){this.provider="openrouter";this.lastRequestTime=0;this.requestCount=0;this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,this.appName=a,this.appUrl=l,this.reasoning_effort=u,this.includeReasoning=m,this.reasoningMaxTokens=c,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async applyRateLimiting(){if(!z(this.model))return;let e=Date.now(),t=e-this.lastRequestTime;if(t>6e4&&(this.requestCount=0),this.requestCount>=Bt){let o=6e4-t;o>0&&(console.log(`Rate limit reached for free tier. Waiting ${o}ms...`),await new Promise(s=>setTimeout(s,o)),this.requestCount=0)}this.lastRequestTime=e,this.requestCount++}async processChat(e,t,o){await this.applyRateLimiting(),await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenRouter(e,this.model,!0);return this.handleStream(s,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(!te(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();try{await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenRouter(e,this.visionModel,!0);return this.handleStream(s,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processVisionChat:",s),s}}async chatOnce(e,t=!0,o=()=>{},s){await this.applyRateLimiting();let i=await this.callOpenRouter(e,this.model,t,s);return t?this.parseStream(i,o):this.parseOneShot(await i.json())}async visionChatOnce(e,t=!1,o=()=>{},s){if(!te(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();let i=await this.callOpenRouter(e,this.visionModel,t,s);return t?this.parseStream(i,o):this.parseOneShot(await i.json())}async callOpenRouter(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s),n={Authorization:`Bearer ${this.apiKey}`};return this.appUrl&&(n["HTTP-Referer"]=this.appUrl),this.appName&&(n["X-Title"]=this.appName),await _.post(this.endpoint,i,n)}buildRequestBody(e,t,o,s){let i={model:t,messages:e,stream:o};if((s!==void 0?s:O(this.responseLength))&&console.warn("OpenRouter: Token limits are not supported for gpt-oss-20b model due to known issues. Using unlimited tokens instead."),this.reasoning_effort!==void 0||this.includeReasoning!==void 0||this.reasoningMaxTokens){if(i.reasoning={},this.reasoning_effort&&this.reasoning_effort!=="none"){let a=this.reasoning_effort==="minimal"?"low":this.reasoning_effort;i.reasoning.effort=a}(this.reasoning_effort==="none"||this.includeReasoning!==!0)&&(i.reasoning.exclude=!0),this.reasoningMaxTokens&&(i.reasoning.max_tokens=this.reasoningMaxTokens)}else i.reasoning={exclude:!0};return this.tools.length>0&&(i.tools=P(this.tools,"chat-completions"),i.tool_choice="auto"),i}async handleStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return T(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return L(e)}};var Me=class{createChatService(e){let t=E({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:e.model||this.getDefaultModel(),supportsVisionForModel:n=>this.supportsVisionForModel(n),validate:"explicit"}),o=e.tools,s=e.appName,i=e.appUrl;return new ve(e.apiKey,e.model||this.getDefaultModel(),t,o,e.endpoint,e.responseLength,s,i,e.reasoning_effort,e.includeReasoning,e.reasoningMaxTokens)}getProviderName(){return"openrouter"}getSupportedModels(){return[G,ft,st,it,rt,nt,at,lt,pt,ct,ut,ht,Ft,dt,mt,gt,_t,Ut,Ht,ot]}getDefaultModel(){return G}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return this.getSupportedModels().some(e=>this.supportsVisionForModel(e))?"supported":"unsupported"}supportsVisionForModel(e){return te(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}getFreeModels(){return Wt}isModelFree(e){return z(e)}};var Oe=class{constructor(e,t=A,o=A,s,i=Re,n){this.provider="xai";this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callXAI(e,this.model,!0);return this.handleStream(s,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(!ie(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callXAI(e,this.visionModel,!0);return this.handleStream(s,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=()=>{},s){let i=await this.callXAI(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){if(!ie(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let i=await this.callXAI(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callXAI(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s);return await _.post(this.endpoint,i,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,s){let i={model:t,stream:o,messages:e},n=s!==void 0?s:O(this.responseLength);n!==void 0&&(i.max_tokens=n);let a=this.buildToolsDefinition();return a.length>0&&(i.tools=a,i.tool_choice="auto"),i}buildToolsDefinition(){return P(this.tools,"chat-completions")}async handleStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return T(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return L(e)}};var Ee=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=E({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:i=>this.supportsVisionForModel(i),validate:"explicit"}),s=e.tools;return new Oe(e.apiKey,t,o,s,e.endpoint||Re,e.responseLength)}getProviderName(){return"xai"}getSupportedModels(){return[Ot,Et,Ct,A]}getDefaultModel(){return A}getDefaultVisionModel(){return A}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ie(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Ce=class{constructor(e,t=oe,o=X,s,i=be,n,a,l){this.provider="zai";this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callZAI(e,this.model,!0);return this.handleStream(s,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callZAI(e,this.visionModel,!0);return this.handleStream(s,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=()=>{},s){let i=await this.callZAI(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let i=await this.callZAI(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callZAI(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s);return await _.post(this.endpoint,i,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,s){let i={model:t,stream:o,messages:e},n=s!==void 0?s:O(this.responseLength);n!==void 0&&(i.max_tokens=n),this.responseFormat&&(i.response_format=this.responseFormat),this.thinking&&(i.thinking=this.thinking);let a=this.buildToolsDefinition();return a.length>0&&(i.tools=a,i.tool_choice="auto",o&&Xt(t)&&(i.tool_stream=!0)),i}buildToolsDefinition(){return P(this.tools,"chat-completions")}async handleStream(e,t){return y(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}async parseStream(e,t){return T(e,t,{onJsonError:o=>console.debug("Failed to parse SSE data:",o)})}parseOneShot(e){return L(e)}};var Se=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"}),s=e.tools,i=e.thinking??{type:"disabled"};return new Ce(e.apiKey,t,o,s,e.endpoint||be,e.responseLength,e.responseFormat,i)}getProviderName(){return"zai"}getSupportedModels(){return[Kt,$t,oe,jt,qt,zt,vt,Mt,X]}getDefaultModel(){return oe}getDefaultVisionModel(){return X}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return se(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var ho=[new fe,new _e,new ue,new de,new pe,new Me,new Se,new Ee,new ge];var ye=class{static registerProvider(e){this.providers.set(e.getProviderName(),e)}static createChatService(e,t){let o=this.providers.get(e);if(!o)throw new Error(`Unknown chat provider: ${e}`);return o.createChatService(t)}static getProviders(){return this.providers}static getAvailableProviders(){return Array.from(this.providers.keys())}static getSupportedModels(e){let t=this.providers.get(e);return t?t.getSupportedModels():[]}static getVisionSupportLevel(e){let t=this.providers.get(e);return t?t.getVisionSupportLevel():"unsupported"}static getVisionSupportLevelForModel(e,t){let o=this.providers.get(e);return o?o.getVisionSupportLevelForModel?o.getVisionSupportLevelForModel(t):o.supportsVisionForModel?o.supportsVisionForModel(t)?"supported":"unsupported":o.getVisionSupportLevel():"unsupported"}};ye.providers=new Map;ho.forEach(r=>ye.registerProvider(r));function mo(){_.setFetch(async(r,e={})=>{let t=(e.method||"GET").toString().toUpperCase(),o=e.headers,s={};if(Array.isArray(o))for(let[c,d]of o)s[c]=String(d);else if(o&&typeof o=="object")for(let[c,d]of Object.entries(o))s[c]=String(d);let i={method:t,headers:s,muteHttpExceptions:!0},n=e.body;typeof n=="string"?i.payload=n:n!=null&&(s["Content-Type"]||(s["Content-Type"]="application/json"),i.payload=JSON.stringify(n));let a=UrlFetchApp.fetch(r,i),l=a.getResponseCode(),u=a.getContentText();return{ok:l>=200&&l<300,status:l,statusText:String(l),text:async()=>u,json:async()=>u?JSON.parse(u):null}})}return Oo(jo);})();
|
|
20
|
+
`)}getResponseLengthInstruction(){if(!this._responseLength)return;let e=Dt[this._responseLength];if(e)return`Please keep your response concise, within approximately ${e} tokens.`}};var de=class{createChatService(e){return new he({expectedInputLanguages:e.expectedInputLanguages,expectedOutputLanguages:e.expectedOutputLanguages,responseLength:e.responseLength})}getProviderName(){return"gemini-nano"}getSupportedModels(){return[J]}getDefaultModel(){return J}supportsVision(){return!1}getVisionSupportLevel(){return"unsupported"}};var me=class{constructor(e,t=D,o=D,s,i=re,n,a,l){this.provider="kimi";this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callKimi(e,this.model,!0);return this.handleStream(s,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callKimi(e,this.visionModel,!0);return this.handleStream(s,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=()=>{},s){let i=await this.callKimi(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){if(!ne(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let i=await this.callKimi(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callKimi(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s);return await _.post(this.endpoint,i,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,s){let i={model:t,stream:o,messages:e},n=s!==void 0?s:O(this.responseLength);n!==void 0&&(i.max_tokens=n),this.responseFormat&&(i.response_format=this.responseFormat);let a=this.tools.length>0?{type:"disabled"}:this.thinking;a&&(this.isSelfHostedEndpoint()?a.type==="disabled"&&(i.chat_template_kwargs={thinking:!1}):i.thinking=a);let l=this.buildToolsDefinition();return l.length>0&&(i.tools=l,i.tool_choice="auto"),i}isSelfHostedEndpoint(){return this.normalizeEndpoint(this.endpoint)!==this.normalizeEndpoint(re)}normalizeEndpoint(e){return e.replace(/\/+$/,"")}buildToolsDefinition(){return P(this.tools,"chat-completions")}async handleStream(e,t){return T(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 L(e)}};var ge=class{createChatService(e){let t=this.resolveEndpoint(e),o=e.model||this.getDefaultModel(),s=E({model:o,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:l=>this.supportsVisionForModel(l),validate:"explicit"}),i=e.tools,n=e.thinking??{type:"enabled"},a=i&&i.length>0?{type:"disabled"}:n;return new me(e.apiKey,o,s,i,t,e.responseLength,e.responseFormat,a)}getProviderName(){return"kimi"}getSupportedModels(){return[D,bt]}getDefaultModel(){return D}getDefaultVisionModel(){return D}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ne(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 re}normalizeEndpoint(e){return e.replace(/\/+$/,"")}};var es={[S.VERY_SHORT]:800,[S.SHORT]:1200,[S.MEDIUM]:2e3,[S.LONG]:3e3,[S.VERY_LONG]:8e3,[S.DEEP]:25e3},ts={none:1200,minimal:1600,low:2500,medium:4e3,high:8e3,xhigh:12e3},U=class{constructor(e,t=j,o=j,s,i=Y,n=[],a,l,u,m=!1,c="openai",d=!0){if(this.provider=c,this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.mcpServers=n,this.responseLength=a,this.verbosity=l,this.reasoning_effort=u,this.enableReasoningSummary=m,d&&!Le.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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenAI(e,this.model,!0),i=this.endpoint===x;try{if(i){let n=await this.parseResponsesStream(s,t);return v.getFullText(n.blocks)}return this.handleStream(s,t)}catch(n){throw console.error("[processChat] Error in streaming/completion:",n),n}},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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenAI(e,this.visionModel,!0),i=this.endpoint===x;try{if(i){let n=await this.parseResponsesStream(s,t);return v.getFullText(n.blocks)}return this.handleStream(s,t)}catch(n){throw console.error("[processVisionChat] Error in streaming/completion:",n),n}},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processVisionChat:",s),s}}async chatOnce(e,t=!0,o=()=>{},s){let i=await this.callOpenAI(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){let i=await this.callOpenAI(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return this.endpoint===x?t?this.parseResponsesStream(e,o):this.parseResponsesOneShot(await e.json()):t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callOpenAI(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s),n={};return(this.provider!=="openai-compatible"||this.apiKey.trim()!=="")&&(n.Authorization=`Bearer ${this.apiKey}`),await _.post(this.endpoint,i,n)}buildRequestBody(e,t,o,s){let i=this.endpoint===x;this.validateMCPCompatibility();let n={model:t,stream:o},a=this.resolveTokenLimit(t,s);i?a!==void 0&&(n.max_output_tokens=a):a!==void 0&&(this.provider==="openai-compatible"?n.max_tokens=a:n.max_completion_tokens=a),i?n.input=this.cleanMessagesForResponsesAPI(e):n.messages=e,q(t)&&(i?(this.reasoning_effort&&(n.reasoning={...n.reasoning,effort:this.reasoning_effort},this.enableReasoningSummary&&(n.reasoning.summary="auto")),this.verbosity&&(n.text={...n.text,format:{type:"text"},verbosity:this.verbosity})):(this.reasoning_effort&&(n.reasoning_effort=this.reasoning_effort),this.verbosity&&(n.verbosity=this.verbosity)));let l=this.buildToolsDefinition();return l.length>0&&(n.tools=l,i||(n.tool_choice="auto")),n}resolveTokenLimit(e,t){if(t!==void 0)return t;let o=this.provider==="openai-compatible"?this.responseLength!==void 0?O(this.responseLength):void 0:O(this.responseLength);if(this.provider!=="openai"||!q(e)||this.responseLength===void 0)return o;let s=this.reasoning_effort??A(e);return Math.max(o??0,es[this.responseLength],ts[s])}validateMCPCompatibility(){if(this.mcpServers.length>0&&this.endpoint===Y)throw new Error(`MCP servers are not supported with Chat Completions API. Current endpoint: ${this.endpoint}. Please use OpenAI Responses API endpoint: ${x}. MCP tools are only available in the Responses API endpoint.`)}cleanMessagesForResponsesAPI(e){return e.map(t=>{let s={role:t.role==="tool"?"user":t.role};return typeof t.content=="string"?s.content=t.content:Array.isArray(t.content)?s.content=t.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):s.content=t.content,s})}buildToolsDefinition(){let e=this.endpoint===x,t=[];return this.tools.length>0&&t.push(...P(this.tools,e?"responses":"chat-completions")),this.mcpServers.length>0&&e&&t.push(...this.buildMCPToolsDefinition()),t}buildMCPToolsDefinition(){return this.mcpServers.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})}async handleStream(e,t){return T(e,t)}async parseStream(e,t){return y(e,t,{appendTextBlock:v.addTextBlock})}parseOneShot(e){return L(e)}async parseResponsesStream(e,t){let o=e.body.getReader(),s=new TextDecoder,i=[],n=new Map,a,l,u,m="";for(;;){let{done:p,value:h}=await o.read();if(p)break;m+=s.decode(h,{stream:!0});let M="",C="",g=m.split(`
|
|
21
|
+
`);m=g.pop()||"";for(let I=0;I<g.length;I++){let H=g[I].trim();if(H.startsWith("event:"))M=H.slice(6).trim();else if(H.startsWith("data:"))C=H.slice(5).trim();else if(H===""&&M&&C){try{let ye=JSON.parse(C),Vt=this.handleResponsesSSEEvent(M,ye,t,i,n,Z=>{Z.responseStatus!==void 0&&(a=Z.responseStatus),Z.incompleteDetails!==void 0&&(l=Z.incompleteDetails),Z.usage!==void 0&&(u=Z.usage)})}catch{console.warn("Failed to parse SSE data:",C)}M="",C=""}}}let c=Array.from(n.values()).map(p=>({type:"tool_use",id:p.id,name:p.name,input:p.input||{}}));return{blocks:[...i,...c],stop_reason:c.length?"tool_use":"end",truncated:a==="incomplete",response_status:a,incomplete_details:l,usage:u}}handleResponsesSSEEvent(e,t,o,s,i,n){switch(e){case"response.output_item.added":t.item?.type==="message"&&Array.isArray(t.item.content)?t.item.content.forEach(a=>{a.type==="output_text"&&a.text&&(o(a.text),v.append(s,a.text))}):t.item?.type==="function_call"&&i.set(t.item.id,{id:t.item.id,name:t.item.name,input:t.item.arguments?JSON.parse(t.item.arguments):{}});break;case"response.content_part.added":t.part?.type==="output_text"&&typeof t.part.text=="string"&&(o(t.part.text),v.append(s,t.part.text));break;case"response.output_text.delta":case"response.content_part.delta":{let a=typeof t.delta=="string"?t.delta:t.delta?.text??"";a&&(o(a),v.append(s,a))}break;case"response.output_text.done":case"response.content_part.done":break;case"response.completed":return n(this.extractResponsesMetadata(t,"completed")),"completed";case"response.incomplete":return n(this.extractResponsesMetadata(t,"incomplete")),"completed";case"response.reasoning.started":case"response.reasoning.delta":case"response.reasoning.done":break;default:break}}extractResponsesMetadata(e,t){let o=e?.response??e;return{responseStatus:o?.status??t,incompleteDetails:o?.incomplete_details??null,usage:o?.usage}}parseResponsesOneShot(e){let t=[];return e.output&&Array.isArray(e.output)&&e.output.forEach(o=>{o.type==="message"&&o.content&&o.content.forEach(s=>{s.type==="output_text"&&s.text&&t.push({type:"text",text:s.text})}),o.type==="function_call"&&t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments?JSON.parse(o.arguments):{}})}),{blocks:t,stop_reason:t.some(o=>o.type==="tool_use")?"tool_use":"end",truncated:e?.status==="incomplete",response_status:e?.status,incomplete_details:e?.incomplete_details??null,usage:e?.usage}}};var _e=class{createChatService(e){return this.validateRequiredOptions(e),new U(e.apiKey?.trim()??"",e.model,e.visionModel??e.model,e.tools,e.endpoint,[],e.responseLength,e.verbosity,e.reasoning_effort,e.enableReasoningSummary,this.getProviderName(),!1)}getProviderName(){return"openai-compatible"}getSupportedModels(){return[]}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"unknown"}supportsVisionForModel(e){return!0}getVisionSupportLevelForModel(e){return"unknown"}getDefaultModel(){return"local-model"}validateRequiredOptions(e){if(e.mcpServers!==void 0)throw new Error("openai-compatible provider does not support mcpServers.");let t=e.endpoint?.trim();if(!t)throw new Error("openai-compatible provider requires endpoint (full URL).");let o;try{o=new URL(t)}catch{throw new Error("openai-compatible provider requires endpoint to be a full URL.")}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error("openai-compatible provider requires endpoint to be a full URL.");if(!e.model?.trim())throw new Error("openai-compatible provider requires model.")}};var fe=class{createChatService(e){let t=this.optimizeGPT5Options(e),o=E({model:t.model,visionModel:t.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultModel(),supportsVisionForModel:u=>this.supportsVisionForModel(u),validate:"resolved"}),s=t.tools,i=t.mcpServers??[],n=t.model||this.getDefaultModel(),a=!1;i.length>0||Ht(n)?a=!0:q(n)&&(a=(t.gpt5EndpointPreference||"chat")==="responses");let l=t.endpoint||(a?x:Y);return new U(t.apiKey,n,o,s,l,i,t.responseLength,t.verbosity,t.reasoning_effort,t.enableReasoningSummary,this.getProviderName())}getProviderName(){return"openai"}getSupportedModels(){return[W,Q,ee,B,N,w,K,$,V,De,Ne,we,j,Ve,kt,Ft,"o1"]}getDefaultModel(){return W}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return Le.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 s=ao[e.gpt5Preset];o.reasoning_effort=s.reasoning_effort,o.verbosity=s.verbosity}else e.reasoning_effort||(o.reasoning_effort=A(t));return o.reasoning_effort=this.normalizeReasoningEffort(t,o.reasoning_effort),o}normalizeReasoningEffort(e,t){if(t)return t==="none"&&!Bt(e)?A(e):t==="minimal"&&!Kt(e)?A(e):t==="low"&&!$t(e)?A(e):t==="xhigh"&&!Wt(e)?A(e):t}};var ve=class{constructor(e,t=k,o=k,s,i=xe,n,a,l,u,m,c){this.provider="openrouter";this.lastRequestTime=0;this.requestCount=0;this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,this.appName=a,this.appUrl=l,this.reasoning_effort=u,this.includeReasoning=m,this.reasoningMaxTokens=c,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async applyRateLimiting(){if(!z(this.model))return;let e=Date.now(),t=e-this.lastRequestTime;if(t>6e4&&(this.requestCount=0),this.requestCount>=Qt){let o=6e4-t;o>0&&(console.log(`Rate limit reached for free tier. Waiting ${o}ms...`),await new Promise(s=>setTimeout(s,o)),this.requestCount=0)}this.lastRequestTime=e,this.requestCount++}async processChat(e,t,o){await this.applyRateLimiting(),await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenRouter(e,this.model,!0);return this.handleStream(s,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(!te(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();try{await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callOpenRouter(e,this.visionModel,!0);return this.handleStream(s,t)},runWithTools:()=>this.visionChatOnce(e,!0,t),onCompleteResponse:o,toolErrorMessage:"processVisionChat received tool_calls. ChatProcessor must use visionChatOnce() loop when tools are enabled."})}catch(s){throw console.error("Error in processVisionChat:",s),s}}async chatOnce(e,t=!0,o=()=>{},s){await this.applyRateLimiting();let i=await this.callOpenRouter(e,this.model,t,s);return t?this.parseStream(i,o):this.parseOneShot(await i.json())}async visionChatOnce(e,t=!1,o=()=>{},s){if(!te(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await this.applyRateLimiting();let i=await this.callOpenRouter(e,this.visionModel,t,s);return t?this.parseStream(i,o):this.parseOneShot(await i.json())}async callOpenRouter(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s),n={Authorization:`Bearer ${this.apiKey}`};return this.appUrl&&(n["HTTP-Referer"]=this.appUrl),this.appName&&(n["X-Title"]=this.appName),await _.post(this.endpoint,i,n)}buildRequestBody(e,t,o,s){let i={model:t,messages:e,stream:o};if((s!==void 0?s:O(this.responseLength))&&console.warn("OpenRouter: Token limits are not supported for gpt-oss-20b model due to known issues. Using unlimited tokens instead."),this.reasoning_effort!==void 0||this.includeReasoning!==void 0||this.reasoningMaxTokens){if(i.reasoning={},this.reasoning_effort&&this.reasoning_effort!=="none"){let a=this.reasoning_effort==="minimal"?"low":this.reasoning_effort;i.reasoning.effort=a}(this.reasoning_effort==="none"||this.includeReasoning!==!0)&&(i.reasoning.exclude=!0),this.reasoningMaxTokens&&(i.reasoning.max_tokens=this.reasoningMaxTokens)}else i.reasoning={exclude:!0};return this.tools.length>0&&(i.tools=P(this.tools,"chat-completions"),i.tool_choice="auto"),i}async handleStream(e,t){return T(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 L(e)}};var Me=class{createChatService(e){let t=E({model:e.model,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:e.model||this.getDefaultModel(),supportsVisionForModel:n=>this.supportsVisionForModel(n),validate:"explicit"}),o=e.tools,s=e.appName,i=e.appUrl;return new ve(e.apiKey,e.model||this.getDefaultModel(),t,o,e.endpoint,e.responseLength,s,i,e.reasoning_effort,e.includeReasoning,e.reasoningMaxTokens)}getProviderName(){return"openrouter"}getSupportedModels(){return[zt,k,Lt,it,rt,nt,at,lt,pt,ct,ut,ht,dt,mt,gt,_t,ft,vt,Mt,Xt,Ot,Et,St,Ct,Tt,yt,Jt,Zt,st,ot]}getDefaultModel(){return k}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return this.getSupportedModels().some(e=>this.supportsVisionForModel(e))?"supported":"unsupported"}supportsVisionForModel(e){return te(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}getFreeModels(){return Yt}isModelFree(e){return z(e)}};var Oe=class{constructor(e,t=b,o=b,s,i=Ae,n){this.provider="xai";this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,this.visionModel=o}getModel(){return this.model}getVisionModel(){return this.visionModel}async processChat(e,t,o){await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callXAI(e,this.model,!0);return this.handleStream(s,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(!ie(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);await f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callXAI(e,this.visionModel,!0);return this.handleStream(s,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=()=>{},s){let i=await this.callXAI(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){if(!ie(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let i=await this.callXAI(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callXAI(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s);return await _.post(this.endpoint,i,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,s){let i={model:t,stream:o,messages:e},n=s!==void 0?s:O(this.responseLength);n!==void 0&&(i.max_tokens=n);let a=this.buildToolsDefinition();return a.length>0&&(i.tools=a,i.tool_choice="auto"),i}buildToolsDefinition(){return P(this.tools,"chat-completions")}async handleStream(e,t){return T(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 L(e)}};var Ee=class{createChatService(e){let t=e.model||this.getDefaultModel(),o=E({model:t,visionModel:e.visionModel,defaultModel:this.getDefaultModel(),defaultVisionModel:this.getDefaultVisionModel(),supportsVisionForModel:i=>this.supportsVisionForModel(i),validate:"explicit"}),s=e.tools;return new Oe(e.apiKey,t,o,s,e.endpoint||Ae,e.responseLength)}getProviderName(){return"xai"}getSupportedModels(){return[xt,Rt,At,b]}getDefaultModel(){return b}getDefaultVisionModel(){return b}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return ie(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Se=class{constructor(e,t=oe,o=X,s,i=Re,n,a,l){this.provider="zai";this.apiKey=e,this.model=t,this.tools=s||[],this.endpoint=i,this.responseLength=n,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callZAI(e,this.model,!0);return this.handleStream(s,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 f({hasTools:this.tools.length>0,runWithoutTools:async()=>{let s=await this.callZAI(e,this.visionModel,!0);return this.handleStream(s,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=()=>{},s){let i=await this.callZAI(e,this.model,t,s);return this.parseResponse(i,t,o)}async visionChatOnce(e,t=!1,o=()=>{},s){if(!se(this.visionModel))throw new Error(`Model ${this.visionModel} does not support vision capabilities.`);let i=await this.callZAI(e,this.visionModel,t,s);return this.parseResponse(i,t,o)}async parseResponse(e,t,o){return t?this.parseStream(e,o):this.parseOneShot(await e.json())}async callZAI(e,t,o=!1,s){let i=this.buildRequestBody(e,t,o,s);return await _.post(this.endpoint,i,{Authorization:`Bearer ${this.apiKey}`})}buildRequestBody(e,t,o,s){let i={model:t,stream:o,messages:e},n=s!==void 0?s:O(this.responseLength);n!==void 0&&(i.max_tokens=n),this.responseFormat&&(i.response_format=this.responseFormat),this.thinking&&(i.thinking=this.thinking);let a=this.buildToolsDefinition();return a.length>0&&(i.tools=a,i.tool_choice="auto",o&&ro(t)&&(i.tool_stream=!0)),i}buildToolsDefinition(){return P(this.tools,"chat-completions")}async handleStream(e,t){return T(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 L(e)}};var Ce=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"}),s=e.tools,i=e.thinking??{type:"disabled"};return new Se(e.apiKey,t,o,s,e.endpoint||Re,e.responseLength,e.responseFormat,i)}getProviderName(){return"zai"}getSupportedModels(){return[eo,to,oe,oo,so,io,Pt,It,X]}getDefaultModel(){return oe}getDefaultVisionModel(){return X}supportsVision(){return this.getVisionSupportLevel()!=="unsupported"}getVisionSupportLevel(){return"supported"}supportsVisionForModel(e){return se(e)}getVisionSupportLevelForModel(e){return this.supportsVisionForModel(e)?"supported":"unsupported"}};var Co=[new fe,new _e,new ue,new de,new pe,new Me,new Ce,new Ee,new ge];var Te=class{static registerProvider(e){this.providers.set(e.getProviderName(),e)}static createChatService(e,t){let o=this.providers.get(e);if(!o)throw new Error(`Unknown chat provider: ${e}`);return o.createChatService(t)}static getProviders(){return this.providers}static getAvailableProviders(){return Array.from(this.providers.keys())}static getSupportedModels(e){let t=this.providers.get(e);return t?t.getSupportedModels():[]}static getVisionSupportLevel(e){let t=this.providers.get(e);return t?t.getVisionSupportLevel():"unsupported"}static getVisionSupportLevelForModel(e,t){let o=this.providers.get(e);return o?o.getVisionSupportLevelForModel?o.getVisionSupportLevelForModel(t):o.supportsVisionForModel?o.supportsVisionForModel(t)?"supported":"unsupported":o.getVisionSupportLevel():"unsupported"}};Te.providers=new Map;Co.forEach(r=>Te.registerProvider(r));function To(){_.setFetch(async(r,e={})=>{let t=(e.method||"GET").toString().toUpperCase(),o=e.headers,s={};if(Array.isArray(o))for(let[c,d]of o)s[c]=String(d);else if(o&&typeof o=="object")for(let[c,d]of Object.entries(o))s[c]=String(d);let i={method:t,headers:s,muteHttpExceptions:!0},n=e.body;typeof n=="string"?i.payload=n:n!=null&&(s["Content-Type"]||(s["Content-Type"]="application/json"),i.payload=JSON.stringify(n));let a=UrlFetchApp.fetch(r,i),l=a.getResponseCode(),u=a.getContentText();return{ok:l>=200&&l<300,status:l,statusText:String(l),text:async()=>u,json:async()=>u?JSON.parse(u):null}})}return Ro(os);})();
|