@aituber-onair/chat 0.31.0 → 0.33.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 +84 -6
- package/README.md +96 -9
- package/dist/cjs/constants/gemini.d.ts +11 -0
- package/dist/cjs/constants/gemini.d.ts.map +1 -1
- package/dist/cjs/constants/gemini.js +24 -7
- package/dist/cjs/constants/gemini.js.map +1 -1
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatService.d.ts +39 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatService.d.ts.map +1 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatService.js +103 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatService.js.map +1 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatServiceProvider.d.ts +14 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatServiceProvider.d.ts.map +1 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatServiceProvider.js +31 -0
- package/dist/cjs/services/providers/agent/ClaudeAgentSDKChatServiceProvider.js.map +1 -0
- package/dist/cjs/services/providers/agent/index.d.ts +8 -3
- package/dist/cjs/services/providers/agent/index.d.ts.map +1 -1
- package/dist/cjs/services/providers/agent/index.js +9 -2
- package/dist/cjs/services/providers/agent/index.js.map +1 -1
- package/dist/cjs/services/providers/gemini/GeminiChatService.js +1 -1
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.d.ts.map +1 -1
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.js +2 -15
- package/dist/cjs/services/providers/gemini/GeminiChatServiceProvider.js.map +1 -1
- package/dist/esm/constants/gemini.d.ts +11 -0
- package/dist/esm/constants/gemini.d.ts.map +1 -1
- package/dist/esm/constants/gemini.js +23 -6
- package/dist/esm/constants/gemini.js.map +1 -1
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatService.d.ts +39 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatService.d.ts.map +1 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatService.js +99 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatService.js.map +1 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatServiceProvider.d.ts +14 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatServiceProvider.d.ts.map +1 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatServiceProvider.js +27 -0
- package/dist/esm/services/providers/agent/ClaudeAgentSDKChatServiceProvider.js.map +1 -0
- package/dist/esm/services/providers/agent/index.d.ts +8 -3
- package/dist/esm/services/providers/agent/index.d.ts.map +1 -1
- package/dist/esm/services/providers/agent/index.js +5 -1
- package/dist/esm/services/providers/agent/index.js.map +1 -1
- package/dist/esm/services/providers/gemini/GeminiChatService.js +2 -2
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.d.ts.map +1 -1
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.js +3 -16
- package/dist/esm/services/providers/gemini/GeminiChatServiceProvider.js.map +1 -1
- package/dist/umd/aituber-onair-chat.js +19 -21
- package/dist/umd/aituber-onair-chat.min.js +7 -7
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -91,7 +91,7 @@ async function testChat() {
|
|
|
91
91
|
|
|
92
92
|
## Agent SDKプロバイダー
|
|
93
93
|
|
|
94
|
-
Codex SDK
|
|
94
|
+
Codex SDK、Claude Agent SDK、Copilot SDK のようなエージェントSDKを使う場合は、
|
|
95
95
|
専用の `@aituber-onair/chat/agent` エントリを使用します。
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
@@ -104,6 +104,8 @@ import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
|
104
104
|
```bash
|
|
105
105
|
npm install @aituber-onair/chat @openai/codex-sdk
|
|
106
106
|
# または
|
|
107
|
+
npm install @aituber-onair/chat @anthropic-ai/claude-agent-sdk
|
|
108
|
+
# または
|
|
107
109
|
npm install @aituber-onair/chat @github/copilot-sdk
|
|
108
110
|
```
|
|
109
111
|
|
|
@@ -136,6 +138,40 @@ const response = await chatService.chatOnce(messages, false);
|
|
|
136
138
|
console.log(response);
|
|
137
139
|
```
|
|
138
140
|
|
|
141
|
+
Claude Agent SDK を使う場合:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
145
|
+
|
|
146
|
+
const chatService = createAgentChatService('claude-agent-sdk', {
|
|
147
|
+
workingDirectory: process.cwd(),
|
|
148
|
+
maxTurns: 1,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const messages = [
|
|
152
|
+
{
|
|
153
|
+
role: 'system',
|
|
154
|
+
content:
|
|
155
|
+
'あなたはライブ配信中のAIアバターです。親しみやすく短めに返答してください。',
|
|
156
|
+
},
|
|
157
|
+
{ role: 'user', content: '今日はTypeScriptのライブラリを作っています。' },
|
|
158
|
+
{
|
|
159
|
+
role: 'assistant',
|
|
160
|
+
content: 'いいですね。作業の合間に、会話で少し気分転換しましょう。',
|
|
161
|
+
},
|
|
162
|
+
{ role: 'user', content: '夜の作業に合う飲み物をおすすめして。' },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
const response = await chatService.chatOnce(messages, false);
|
|
166
|
+
|
|
167
|
+
console.log(response);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
このプロバイダーでは、Claude Agent SDK を通常のチャット応答生成にだけ使います。
|
|
171
|
+
既定では Claude Code のファイル操作やコマンド実行などのツール機能は使いません。
|
|
172
|
+
2026年6月15日以降、対象の有料 Claude プランでは Agent SDK 用の月間クレジットを
|
|
173
|
+
利用できます。APIキーを使う Developer Platform の利用は従来通り従量課金です。
|
|
174
|
+
|
|
139
175
|
Copilot SDK を使う場合:
|
|
140
176
|
|
|
141
177
|
```typescript
|
|
@@ -256,7 +292,7 @@ const localCompatibleService = ChatServiceFactory.createChatService(
|
|
|
256
292
|
|
|
257
293
|
#### Agent SDKプロバイダー
|
|
258
294
|
|
|
259
|
-
`@aituber-onair/chat/agent` は、Codex SDK
|
|
295
|
+
`@aituber-onair/chat/agent` は、Codex SDK、Claude Agent SDK、Copilot SDK のような
|
|
260
296
|
エージェントSDK向けの実験的なプロバイダーを公開します。ブラウザ/GAS向けUMDエントリには
|
|
261
297
|
含まれず、APIキーも使用しません。
|
|
262
298
|
|
|
@@ -265,11 +301,13 @@ const localCompatibleService = ChatServiceFactory.createChatService(
|
|
|
265
301
|
```bash
|
|
266
302
|
npm install @aituber-onair/chat @openai/codex-sdk
|
|
267
303
|
# または
|
|
304
|
+
npm install @aituber-onair/chat @anthropic-ai/claude-agent-sdk
|
|
305
|
+
# または
|
|
268
306
|
npm install @aituber-onair/chat @github/copilot-sdk
|
|
269
307
|
```
|
|
270
308
|
|
|
271
|
-
`@openai/codex-sdk
|
|
272
|
-
|
|
309
|
+
`@openai/codex-sdk`、`@anthropic-ai/claude-agent-sdk`、`@github/copilot-sdk` は
|
|
310
|
+
`@aituber-onair/chat` の依存関係には含めていません。SDK は動的に読み込むため、通常の API
|
|
273
311
|
プロバイダーだけを使うユーザーはこれらのエージェントSDKパッケージをインストールする
|
|
274
312
|
必要がありません。
|
|
275
313
|
|
|
@@ -300,6 +338,39 @@ const result = await codexService.chatOnce(messages, false, (text) =>
|
|
|
300
338
|
);
|
|
301
339
|
```
|
|
302
340
|
|
|
341
|
+
Claude Agent SDK を使う場合は `claude-agent-sdk` を指定します。
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
345
|
+
|
|
346
|
+
const claudeService = createAgentChatService('claude-agent-sdk', {
|
|
347
|
+
workingDirectory: process.cwd(),
|
|
348
|
+
maxTurns: 1,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
const messages = [
|
|
352
|
+
{
|
|
353
|
+
role: 'system',
|
|
354
|
+
content:
|
|
355
|
+
'あなたはライブ配信中のAIアバターです。視聴者との自然な会話を続けてください。',
|
|
356
|
+
},
|
|
357
|
+
{ role: 'user', content: '最近、個人開発の進め方で悩んでいます。' },
|
|
358
|
+
{
|
|
359
|
+
role: 'assistant',
|
|
360
|
+
content: '無理なく続けられる形を一緒に考えましょう。',
|
|
361
|
+
},
|
|
362
|
+
{ role: 'user', content: '今日は何から手をつけるのが良さそう?' },
|
|
363
|
+
];
|
|
364
|
+
|
|
365
|
+
const result = await claudeService.chatOnce(messages, false, (text) =>
|
|
366
|
+
process.stdout.write(text),
|
|
367
|
+
);
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Claude Agent SDK は既定で `tools: []`、`permissionMode: 'dontAsk'`、
|
|
371
|
+
`settingSources: []` を指定し、Claude Code のファイル操作・コマンド実行や
|
|
372
|
+
プロジェクト/ユーザー設定を使わずにチャット応答を生成します。
|
|
373
|
+
|
|
303
374
|
Copilot SDK を使う場合は `copilot-sdk` を指定します。
|
|
304
375
|
|
|
305
376
|
```typescript
|
|
@@ -342,6 +413,7 @@ const copilotService = createAgentChatService('copilot-sdk', {
|
|
|
342
413
|
|
|
343
414
|
利用可能なプロバイダー:
|
|
344
415
|
- `codex-sdk`: `@openai/codex-sdk` と Codex 認証が必要です。
|
|
416
|
+
- `claude-agent-sdk`: `@anthropic-ai/claude-agent-sdk` と Claude Agent SDK 認証が必要です。
|
|
345
417
|
- `copilot-sdk`: `@github/copilot-sdk` と GitHub Copilot 認証が必要です。
|
|
346
418
|
|
|
347
419
|
現時点の制限:
|
|
@@ -455,10 +527,16 @@ const claudeService = ChatServiceFactory.createChatService('claude', {
|
|
|
455
527
|
```typescript
|
|
456
528
|
const geminiService = ChatServiceFactory.createChatService('gemini', {
|
|
457
529
|
apiKey: process.env.GOOGLE_API_KEY,
|
|
458
|
-
model: 'gemini-3.1-flash-lite
|
|
530
|
+
model: 'gemini-3.1-flash-lite'
|
|
459
531
|
});
|
|
460
532
|
```
|
|
461
533
|
|
|
534
|
+
`gemini-3.1-flash-lite` が推奨の安定版 Flash-Lite モデルです。
|
|
535
|
+
`gemini-3.1-flash-lite-preview`、`gemini-3-pro-preview`、
|
|
536
|
+
`gemini-2.0-flash`、`gemini-2.0-flash-lite` などの preview /
|
|
537
|
+
shutdown 予定モデルは後方互換のため明示的な model string では利用できますが、
|
|
538
|
+
本番用途では新しいモデルへ移行してください。
|
|
539
|
+
|
|
462
540
|
#### OpenRouter
|
|
463
541
|
|
|
464
542
|
```typescript
|
|
@@ -875,7 +953,7 @@ console.log(modelLevel); // 'unknown'
|
|
|
875
953
|
|
|
876
954
|
- **OpenAI**: GPT-5.5、GPT-5.4 Pro、GPT-5.4、GPT-5.4 Mini、GPT-5.4 Nano、GPT-5.1、GPT-5(Nano/Mini/Standard)、GPT-4.1(miniとnanoを含む), GPT-4, GPT-4o-mini, O3-mini, o1, o1-miniのモデルをサポート
|
|
877
955
|
- **OpenAI-Compatible**: OpenAI互換 endpoint 経由で任意のローカル/セルフホスト model ID を利用できます。vision 対応可否は endpoint ごとに差があるため、原則 `unknown` 扱いです
|
|
878
|
-
- **Gemini**: Gemini 3.1
|
|
956
|
+
- **Gemini**: Gemini 3.1 Flash-Lite、Gemini 3.1 Pro Preview、Gemini 3 Flash Preview、Gemini 2.5 Pro、Gemini 2.5 Flash、Gemini 2.5 Flash Lite、Gemma 4 31B IT、Gemma 4 26B A4B IT などの推奨モデルをサポート。Gemini 3.1 Flash-Lite Preview、Gemini 3 Pro Preview、Gemini 2.0 Flash、Gemini 2.0 Flash-Lite などの lifecycle 上 deprecated なモデルは明示指定用に export を残していますが、shutdown 前に移行してください
|
|
879
957
|
- **Claude**: Claude Opus 4.7, Claude Opus 4.6, Claude Opus 4.5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Haiku 4.5 に加え、まだ利用可能だが非推奨の Claude 4 Opus, Claude 4 Sonnet, Claude 3 Haiku をサポート
|
|
880
958
|
- **OpenRouter**: OpenRouterのキュレーション済みモデル一覧(OpenAI/Claude/Gemini/Z.ai/Kimi)をサポート。モデルIDはOpenRouter節を参照してください
|
|
881
959
|
- **Z.ai**: GLM-5/GLM-5-Turbo(テキスト)、GLM-4.7/4.6(テキスト)、GLM-4.6V系(ビジョン)をサポート
|
package/README.md
CHANGED
|
@@ -91,8 +91,8 @@ Notes:
|
|
|
91
91
|
|
|
92
92
|
## Agent SDK Providers
|
|
93
93
|
|
|
94
|
-
For agent SDKs such as Codex SDK and Copilot SDK, use the
|
|
95
|
-
`@aituber-onair/chat/agent` entry point:
|
|
94
|
+
For agent SDKs such as Codex SDK, Claude Agent SDK, and Copilot SDK, use the
|
|
95
|
+
separate `@aituber-onair/chat/agent` entry point:
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
98
|
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
@@ -104,6 +104,8 @@ dynamically, so install only the agent SDK package used by your JavaScript runti
|
|
|
104
104
|
```bash
|
|
105
105
|
npm install @aituber-onair/chat @openai/codex-sdk
|
|
106
106
|
# or
|
|
107
|
+
npm install @aituber-onair/chat @anthropic-ai/claude-agent-sdk
|
|
108
|
+
# or
|
|
107
109
|
npm install @aituber-onair/chat @github/copilot-sdk
|
|
108
110
|
```
|
|
109
111
|
|
|
@@ -139,6 +141,43 @@ const response = await chatService.chatOnce(messages, false);
|
|
|
139
141
|
console.log(response);
|
|
140
142
|
```
|
|
141
143
|
|
|
144
|
+
For Claude Agent SDK:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
148
|
+
|
|
149
|
+
const chatService = createAgentChatService('claude-agent-sdk', {
|
|
150
|
+
workingDirectory: process.cwd(),
|
|
151
|
+
maxTurns: 1,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const messages = [
|
|
155
|
+
{
|
|
156
|
+
role: 'system',
|
|
157
|
+
content:
|
|
158
|
+
'You are a friendly AI avatar for a live chat. Reply warmly and concisely.',
|
|
159
|
+
},
|
|
160
|
+
{ role: 'user', content: 'I am working on a TypeScript library tonight.' },
|
|
161
|
+
{
|
|
162
|
+
role: 'assistant',
|
|
163
|
+
content: 'Nice. I can keep the conversation light while you work.',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
role: 'user',
|
|
167
|
+
content: 'What drink would you recommend for a late-night coding session?',
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const response = await chatService.chatOnce(messages, false);
|
|
172
|
+
|
|
173
|
+
console.log(response);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Claude Agent SDK is run as a text-chat provider with built-in tools disabled by
|
|
177
|
+
default. Eligible Claude subscription plans can use Agent SDK monthly credits
|
|
178
|
+
starting June 15, 2026; API-key based Developer Platform usage remains
|
|
179
|
+
pay-as-you-go.
|
|
180
|
+
|
|
142
181
|
For Copilot SDK:
|
|
143
182
|
|
|
144
183
|
```typescript
|
|
@@ -262,20 +301,23 @@ Notes:
|
|
|
262
301
|
#### Agent SDK Providers
|
|
263
302
|
|
|
264
303
|
`@aituber-onair/chat/agent` exposes experimental providers for agent SDKs such
|
|
265
|
-
as Codex SDK and Copilot SDK. These providers are not
|
|
266
|
-
browser/GAS UMD entry point and do not use API keys.
|
|
304
|
+
as Codex SDK, Claude Agent SDK, and Copilot SDK. These providers are not
|
|
305
|
+
included in the browser/GAS UMD entry point and do not use API keys.
|
|
267
306
|
|
|
268
307
|
Install only the agent SDK package you actually use in your JavaScript runtime application:
|
|
269
308
|
|
|
270
309
|
```bash
|
|
271
310
|
npm install @aituber-onair/chat @openai/codex-sdk
|
|
272
311
|
# or
|
|
312
|
+
npm install @aituber-onair/chat @anthropic-ai/claude-agent-sdk
|
|
313
|
+
# or
|
|
273
314
|
npm install @aituber-onair/chat @github/copilot-sdk
|
|
274
315
|
```
|
|
275
316
|
|
|
276
|
-
`@openai/codex-sdk
|
|
277
|
-
`@aituber-onair/chat`. They are
|
|
278
|
-
normal API providers do not
|
|
317
|
+
`@openai/codex-sdk`, `@anthropic-ai/claude-agent-sdk`, and
|
|
318
|
+
`@github/copilot-sdk` are not dependencies of `@aituber-onair/chat`. They are
|
|
319
|
+
loaded dynamically, so users who only use the normal API providers do not
|
|
320
|
+
install these agent SDK packages.
|
|
279
321
|
|
|
280
322
|
```typescript
|
|
281
323
|
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
@@ -307,6 +349,43 @@ const result = await codexService.chatOnce(messages, false, (text) =>
|
|
|
307
349
|
);
|
|
308
350
|
```
|
|
309
351
|
|
|
352
|
+
For Claude Agent SDK, use `claude-agent-sdk`.
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { createAgentChatService } from '@aituber-onair/chat/agent';
|
|
356
|
+
|
|
357
|
+
const claudeService = createAgentChatService('claude-agent-sdk', {
|
|
358
|
+
workingDirectory: process.cwd(),
|
|
359
|
+
maxTurns: 1,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const messages = [
|
|
363
|
+
{
|
|
364
|
+
role: 'system',
|
|
365
|
+
content:
|
|
366
|
+
'You are a friendly AI avatar for a live chat. Keep a natural conversation going.',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
role: 'user',
|
|
370
|
+
content: 'I am thinking about how to keep a side project moving.',
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
role: 'assistant',
|
|
374
|
+
content: 'Let us make it feel manageable and easy to restart.',
|
|
375
|
+
},
|
|
376
|
+
{ role: 'user', content: 'What should I work on first today?' },
|
|
377
|
+
];
|
|
378
|
+
|
|
379
|
+
const result = await claudeService.chatOnce(messages, false, (text) =>
|
|
380
|
+
process.stdout.write(text),
|
|
381
|
+
);
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Claude Agent SDK is configured with `tools: []`, `permissionMode: 'dontAsk'`,
|
|
385
|
+
and `settingSources: []` by default so this provider behaves as text chat and
|
|
386
|
+
does not load Claude Code project/user settings unless the implementation is
|
|
387
|
+
expanded later.
|
|
388
|
+
|
|
310
389
|
For Copilot SDK, use `copilot-sdk`.
|
|
311
390
|
|
|
312
391
|
```typescript
|
|
@@ -352,6 +431,7 @@ const copilotService = createAgentChatService('copilot-sdk', {
|
|
|
352
431
|
|
|
353
432
|
Available providers:
|
|
354
433
|
- `codex-sdk`: requires `@openai/codex-sdk` and Codex authentication.
|
|
434
|
+
- `claude-agent-sdk`: requires `@anthropic-ai/claude-agent-sdk` and Claude Agent SDK authentication.
|
|
355
435
|
- `copilot-sdk`: requires `@github/copilot-sdk` and GitHub Copilot authentication.
|
|
356
436
|
|
|
357
437
|
Current limitations:
|
|
@@ -462,10 +542,17 @@ const claudeService = ChatServiceFactory.createChatService('claude', {
|
|
|
462
542
|
```typescript
|
|
463
543
|
const geminiService = ChatServiceFactory.createChatService('gemini', {
|
|
464
544
|
apiKey: process.env.GOOGLE_API_KEY,
|
|
465
|
-
model: 'gemini-3.1-flash-lite
|
|
545
|
+
model: 'gemini-3.1-flash-lite'
|
|
466
546
|
});
|
|
467
547
|
```
|
|
468
548
|
|
|
549
|
+
`gemini-3.1-flash-lite` is the recommended stable Flash-Lite model. Deprecated
|
|
550
|
+
preview and shutdown-scheduled models such as `gemini-3.1-flash-lite-preview`,
|
|
551
|
+
`gemini-3-pro-preview`, `gemini-2.0-flash`, and
|
|
552
|
+
`gemini-2.0-flash-lite` remain usable by explicit model string for backward
|
|
553
|
+
compatibility, but are no longer advertised in the standard supported-model
|
|
554
|
+
list for production use.
|
|
555
|
+
|
|
469
556
|
#### OpenRouter
|
|
470
557
|
|
|
471
558
|
```typescript
|
|
@@ -882,7 +969,7 @@ Currently, the following AI providers are built-in:
|
|
|
882
969
|
|
|
883
970
|
- **OpenAI**: Supports models like GPT-5.5, GPT-5.4 Pro, GPT-5.4, GPT-5.4 Mini, GPT-5.4 Nano, GPT-5.1, GPT-5 (Nano/Mini/Standard), GPT-4.1 (including mini and nano), GPT-4, GPT-4o-mini, O3-mini, o1, o1-mini
|
|
884
971
|
- **OpenAI-Compatible**: Supports arbitrary local/self-hosted model IDs via OpenAI-compatible endpoints. Vision capability is treated as `unknown` unless your app knows the endpoint-specific model catalog.
|
|
885
|
-
- **Gemini**: Supports models like Gemini 3.1
|
|
972
|
+
- **Gemini**: Supports recommended models like Gemini 3.1 Flash-Lite, Gemini 3.1 Pro Preview, Gemini 3 Flash Preview, Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.5 Flash Lite, Gemma 4 31B IT, and Gemma 4 26B A4B IT. Deprecated lifecycle models such as Gemini 3.1 Flash-Lite Preview, Gemini 3 Pro Preview, Gemini 2.0 Flash, and Gemini 2.0 Flash-Lite remain exported for explicit use, but should be migrated before shutdown.
|
|
886
973
|
- **Claude**: Supports current Claude API model IDs including Claude Opus 4.7, Claude Opus 4.6, Claude Opus 4.5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Haiku 4.5, plus deprecated-but-still-available Claude 4 Opus, Claude 4 Sonnet, and Claude 3 Haiku
|
|
887
974
|
- **OpenRouter**: Supports a curated OpenRouter model list (OpenAI/Claude/Gemini/Z.ai/Kimi). See the OpenRouter section for model IDs.
|
|
888
975
|
- **Z.ai**: Supports GLM-5/GLM-5-Turbo (text), GLM-4.7/4.6 (text), and GLM-4.6V family (vision)
|
|
@@ -2,14 +2,25 @@ export declare const ENDPOINT_GEMINI_API = "https://generativelanguage.googleapi
|
|
|
2
2
|
export declare const MODEL_GEMMA_4_31B_IT = "gemma-4-31b-it";
|
|
3
3
|
export declare const MODEL_GEMMA_4_26B_A4B_IT = "gemma-4-26b-a4b-it";
|
|
4
4
|
export declare const MODEL_GEMINI_3_1_PRO_PREVIEW = "gemini-3.1-pro-preview";
|
|
5
|
+
export declare const MODEL_GEMINI_3_1_FLASH_LITE = "gemini-3.1-flash-lite";
|
|
6
|
+
/** @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE instead. */
|
|
5
7
|
export declare const MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW = "gemini-3.1-flash-lite-preview";
|
|
8
|
+
/** @deprecated Use MODEL_GEMINI_3_1_PRO_PREVIEW instead. */
|
|
6
9
|
export declare const MODEL_GEMINI_3_PRO_PREVIEW = "gemini-3-pro-preview";
|
|
7
10
|
export declare const MODEL_GEMINI_3_FLASH_PREVIEW = "gemini-3-flash-preview";
|
|
8
11
|
export declare const MODEL_GEMINI_2_5_PRO = "gemini-2.5-pro";
|
|
9
12
|
export declare const MODEL_GEMINI_2_5_FLASH = "gemini-2.5-flash";
|
|
10
13
|
export declare const MODEL_GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite";
|
|
14
|
+
/** @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE instead. */
|
|
11
15
|
export declare const MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17 = "gemini-2.5-flash-lite-preview-06-17";
|
|
16
|
+
/** @deprecated Use MODEL_GEMINI_2_5_FLASH instead. */
|
|
12
17
|
export declare const MODEL_GEMINI_2_0_FLASH = "gemini-2.0-flash";
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE or
|
|
20
|
+
* MODEL_GEMINI_2_5_FLASH_LITE instead.
|
|
21
|
+
*/
|
|
13
22
|
export declare const MODEL_GEMINI_2_0_FLASH_LITE = "gemini-2.0-flash-lite";
|
|
23
|
+
export declare const GEMINI_RECOMMENDED_MODELS: string[];
|
|
24
|
+
export declare const GEMINI_DEPRECATED_MODELS: string[];
|
|
14
25
|
export declare const GEMINI_VISION_SUPPORTED_MODELS: string[];
|
|
15
26
|
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/constants/gemini.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,8CAA8C,CAAC;AAG/E,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AACrE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|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GEMINI_VISION_SUPPORTED_MODELS = exports.MODEL_GEMINI_2_0_FLASH_LITE = exports.MODEL_GEMINI_2_0_FLASH = exports.MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17 = exports.MODEL_GEMINI_2_5_FLASH_LITE = exports.MODEL_GEMINI_2_5_FLASH = exports.MODEL_GEMINI_2_5_PRO = exports.MODEL_GEMINI_3_FLASH_PREVIEW = exports.MODEL_GEMINI_3_PRO_PREVIEW = exports.MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW = exports.MODEL_GEMINI_3_1_PRO_PREVIEW = exports.MODEL_GEMMA_4_26B_A4B_IT = exports.MODEL_GEMMA_4_31B_IT = exports.ENDPOINT_GEMINI_API = void 0;
|
|
3
|
+
exports.GEMINI_VISION_SUPPORTED_MODELS = exports.GEMINI_DEPRECATED_MODELS = exports.GEMINI_RECOMMENDED_MODELS = exports.MODEL_GEMINI_2_0_FLASH_LITE = exports.MODEL_GEMINI_2_0_FLASH = exports.MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17 = exports.MODEL_GEMINI_2_5_FLASH_LITE = exports.MODEL_GEMINI_2_5_FLASH = exports.MODEL_GEMINI_2_5_PRO = exports.MODEL_GEMINI_3_FLASH_PREVIEW = exports.MODEL_GEMINI_3_PRO_PREVIEW = exports.MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW = exports.MODEL_GEMINI_3_1_FLASH_LITE = exports.MODEL_GEMINI_3_1_PRO_PREVIEW = exports.MODEL_GEMMA_4_26B_A4B_IT = exports.MODEL_GEMMA_4_31B_IT = exports.ENDPOINT_GEMINI_API = void 0;
|
|
4
4
|
// API Endpoints
|
|
5
5
|
exports.ENDPOINT_GEMINI_API = 'https://generativelanguage.googleapis.com';
|
|
6
6
|
// Gemini / Gemma models
|
|
7
7
|
exports.MODEL_GEMMA_4_31B_IT = 'gemma-4-31b-it';
|
|
8
8
|
exports.MODEL_GEMMA_4_26B_A4B_IT = 'gemma-4-26b-a4b-it';
|
|
9
9
|
exports.MODEL_GEMINI_3_1_PRO_PREVIEW = 'gemini-3.1-pro-preview';
|
|
10
|
+
exports.MODEL_GEMINI_3_1_FLASH_LITE = 'gemini-3.1-flash-lite';
|
|
11
|
+
/** @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE instead. */
|
|
10
12
|
exports.MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW = 'gemini-3.1-flash-lite-preview';
|
|
13
|
+
/** @deprecated Use MODEL_GEMINI_3_1_PRO_PREVIEW instead. */
|
|
11
14
|
exports.MODEL_GEMINI_3_PRO_PREVIEW = 'gemini-3-pro-preview';
|
|
12
15
|
exports.MODEL_GEMINI_3_FLASH_PREVIEW = 'gemini-3-flash-preview';
|
|
13
16
|
exports.MODEL_GEMINI_2_5_PRO = 'gemini-2.5-pro';
|
|
14
17
|
exports.MODEL_GEMINI_2_5_FLASH = 'gemini-2.5-flash';
|
|
15
18
|
exports.MODEL_GEMINI_2_5_FLASH_LITE = 'gemini-2.5-flash-lite';
|
|
19
|
+
/** @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE instead. */
|
|
16
20
|
exports.MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17 = 'gemini-2.5-flash-lite-preview-06-17';
|
|
21
|
+
/** @deprecated Use MODEL_GEMINI_2_5_FLASH instead. */
|
|
17
22
|
exports.MODEL_GEMINI_2_0_FLASH = 'gemini-2.0-flash';
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use MODEL_GEMINI_3_1_FLASH_LITE or
|
|
25
|
+
* MODEL_GEMINI_2_5_FLASH_LITE instead.
|
|
26
|
+
*/
|
|
18
27
|
exports.MODEL_GEMINI_2_0_FLASH_LITE = 'gemini-2.0-flash-lite';
|
|
19
|
-
|
|
20
|
-
exports.
|
|
21
|
-
exports.MODEL_GEMMA_4_31B_IT,
|
|
22
|
-
exports.MODEL_GEMMA_4_26B_A4B_IT,
|
|
28
|
+
exports.GEMINI_RECOMMENDED_MODELS = [
|
|
29
|
+
exports.MODEL_GEMINI_3_1_FLASH_LITE,
|
|
23
30
|
exports.MODEL_GEMINI_3_1_PRO_PREVIEW,
|
|
24
|
-
exports.MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW,
|
|
25
|
-
exports.MODEL_GEMINI_3_PRO_PREVIEW,
|
|
26
31
|
exports.MODEL_GEMINI_3_FLASH_PREVIEW,
|
|
27
32
|
exports.MODEL_GEMINI_2_5_PRO,
|
|
28
33
|
exports.MODEL_GEMINI_2_5_FLASH,
|
|
29
34
|
exports.MODEL_GEMINI_2_5_FLASH_LITE,
|
|
35
|
+
exports.MODEL_GEMMA_4_31B_IT,
|
|
36
|
+
exports.MODEL_GEMMA_4_26B_A4B_IT,
|
|
37
|
+
];
|
|
38
|
+
exports.GEMINI_DEPRECATED_MODELS = [
|
|
39
|
+
exports.MODEL_GEMINI_3_1_FLASH_LITE_PREVIEW,
|
|
40
|
+
exports.MODEL_GEMINI_3_PRO_PREVIEW,
|
|
30
41
|
exports.MODEL_GEMINI_2_5_FLASH_LITE_PREVIEW_06_17,
|
|
31
42
|
exports.MODEL_GEMINI_2_0_FLASH,
|
|
32
43
|
exports.MODEL_GEMINI_2_0_FLASH_LITE,
|
|
33
44
|
];
|
|
45
|
+
// Vision support for Gemini models. Deprecated entries remain for explicit
|
|
46
|
+
// model-string compatibility, but are omitted from recommended model lists.
|
|
47
|
+
exports.GEMINI_VISION_SUPPORTED_MODELS = [
|
|
48
|
+
...exports.GEMINI_RECOMMENDED_MODELS,
|
|
49
|
+
...exports.GEMINI_DEPRECATED_MODELS,
|
|
50
|
+
];
|
|
34
51
|
//# sourceMappingURL=gemini.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/constants/gemini.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AACH,QAAA,mBA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CAAC;AAEF,2EAA2E;AAC3E,4EAA4E;AAC/D,QAAA,8BAA8B,GAAG;IAC5C,GAAG,iCAAyB;IAC5B,GAAG,gCAAwB;CAC5B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChatResponseLength } from '../../../constants';
|
|
2
|
+
import { AgentTextChatService } from './shared';
|
|
3
|
+
export declare const DEFAULT_CLAUDE_AGENT_SDK_MODEL = "claude-default";
|
|
4
|
+
type ClaudeAgentSDKModule = {
|
|
5
|
+
query: (params: {
|
|
6
|
+
prompt: string;
|
|
7
|
+
options?: Record<string, unknown>;
|
|
8
|
+
}) => AsyncIterable<ClaudeAgentSDKMessage>;
|
|
9
|
+
};
|
|
10
|
+
type ClaudeAgentSDKMessage = {
|
|
11
|
+
type: 'result';
|
|
12
|
+
is_error?: boolean;
|
|
13
|
+
result?: unknown;
|
|
14
|
+
errors?: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'stream_event';
|
|
17
|
+
event?: {
|
|
18
|
+
type?: string;
|
|
19
|
+
delta?: {
|
|
20
|
+
type?: string;
|
|
21
|
+
text?: unknown;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | Record<string, unknown>;
|
|
25
|
+
export type ClaudeAgentSDKLoader = () => Promise<ClaudeAgentSDKModule>;
|
|
26
|
+
export type ClaudeAgentSDKChatServiceOptions = {
|
|
27
|
+
apiKey?: never;
|
|
28
|
+
model?: string;
|
|
29
|
+
responseLength?: ChatResponseLength;
|
|
30
|
+
workingDirectory?: string;
|
|
31
|
+
maxTurns?: number;
|
|
32
|
+
pathToClaudeCodeExecutable?: string;
|
|
33
|
+
env?: Record<string, string | undefined>;
|
|
34
|
+
};
|
|
35
|
+
export declare class ClaudeAgentSDKChatService extends AgentTextChatService {
|
|
36
|
+
constructor(options?: ClaudeAgentSDKChatServiceOptions, loadSDK?: ClaudeAgentSDKLoader);
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=ClaudeAgentSDKChatService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeAgentSDKChatService.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/agent/ClaudeAgentSDKChatService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAA0B,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAE/D,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,CAAC,MAAM,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,KAAK,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,qBAAqB,GACtB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE;YACN,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,IAAI,CAAC,EAAE,OAAO,CAAC;SAChB,CAAC;KACH,CAAC;CACH,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEvE,MAAM,MAAM,gCAAgC,GAAG;IAC7C,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C,CAAC;AAEF,qBAAa,yBAA0B,SAAQ,oBAAoB;gBAE/D,OAAO,GAAE,gCAAqC,EAC9C,OAAO,GAAE,oBAAyC;CAyBrD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudeAgentSDKChatService = exports.DEFAULT_CLAUDE_AGENT_SDK_MODEL = void 0;
|
|
4
|
+
const shared_1 = require("./shared");
|
|
5
|
+
exports.DEFAULT_CLAUDE_AGENT_SDK_MODEL = 'claude-default';
|
|
6
|
+
class ClaudeAgentSDKChatService extends shared_1.AgentTextChatService {
|
|
7
|
+
constructor(options = {}, loadSDK = loadClaudeAgentSDK) {
|
|
8
|
+
const model = options.model ?? exports.DEFAULT_CLAUDE_AGENT_SDK_MODEL;
|
|
9
|
+
super({
|
|
10
|
+
provider: 'claude-agent-sdk',
|
|
11
|
+
model,
|
|
12
|
+
defaultModel: exports.DEFAULT_CLAUDE_AGENT_SDK_MODEL,
|
|
13
|
+
responseLength: options.responseLength,
|
|
14
|
+
getResponse: async (prompt, stream, onPartialResponse) => {
|
|
15
|
+
try {
|
|
16
|
+
return await runClaudeAgentPrompt(loadSDK, model, options, prompt, stream, onPartialResponse);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw (0, shared_1.wrapAgentProviderError)('claude-agent-sdk', error);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ClaudeAgentSDKChatService = ClaudeAgentSDKChatService;
|
|
26
|
+
async function runClaudeAgentPrompt(loadSDK, model, options, prompt, stream, onPartialResponse) {
|
|
27
|
+
const { query } = await loadSDK();
|
|
28
|
+
let finalText = '';
|
|
29
|
+
let streamedText = '';
|
|
30
|
+
const queryOptions = {
|
|
31
|
+
tools: [],
|
|
32
|
+
permissionMode: 'dontAsk',
|
|
33
|
+
settingSources: [],
|
|
34
|
+
...(options.model ? { model } : {}),
|
|
35
|
+
...(options.workingDirectory ? { cwd: options.workingDirectory } : {}),
|
|
36
|
+
...(options.maxTurns !== undefined ? { maxTurns: options.maxTurns } : {}),
|
|
37
|
+
...(options.pathToClaudeCodeExecutable
|
|
38
|
+
? { pathToClaudeCodeExecutable: options.pathToClaudeCodeExecutable }
|
|
39
|
+
: {}),
|
|
40
|
+
...(options.env ? { env: options.env } : {}),
|
|
41
|
+
...(stream ? { includePartialMessages: true } : {}),
|
|
42
|
+
};
|
|
43
|
+
for await (const message of query({ prompt, options: queryOptions })) {
|
|
44
|
+
const delta = extractTextDelta(message);
|
|
45
|
+
if (stream && delta) {
|
|
46
|
+
streamedText += delta;
|
|
47
|
+
onPartialResponse(delta);
|
|
48
|
+
}
|
|
49
|
+
if (isResultMessage(message)) {
|
|
50
|
+
if (message.is_error) {
|
|
51
|
+
throw new Error(formatClaudeAgentResultError(message.errors));
|
|
52
|
+
}
|
|
53
|
+
if (typeof message.result === 'string') {
|
|
54
|
+
finalText = message.result;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!finalText) {
|
|
59
|
+
throw new Error('claude-agent-sdk provider received an empty response.');
|
|
60
|
+
}
|
|
61
|
+
if (stream && streamedText === '') {
|
|
62
|
+
onPartialResponse(finalText);
|
|
63
|
+
}
|
|
64
|
+
return finalText;
|
|
65
|
+
}
|
|
66
|
+
function extractTextDelta(message) {
|
|
67
|
+
if (!isStreamEventMessage(message)) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const delta = message.event?.delta;
|
|
71
|
+
if (delta?.type === 'text_delta' && typeof delta.text === 'string') {
|
|
72
|
+
return delta.text;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
function isStreamEventMessage(message) {
|
|
77
|
+
return message.type === 'stream_event';
|
|
78
|
+
}
|
|
79
|
+
function isResultMessage(message) {
|
|
80
|
+
return message.type === 'result';
|
|
81
|
+
}
|
|
82
|
+
function formatClaudeAgentResultError(errors) {
|
|
83
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
84
|
+
return errors
|
|
85
|
+
.map((error) => (typeof error === 'string' ? error : String(error)))
|
|
86
|
+
.join('\n');
|
|
87
|
+
}
|
|
88
|
+
return 'claude-agent-sdk provider failed during execution.';
|
|
89
|
+
}
|
|
90
|
+
async function loadClaudeAgentSDK() {
|
|
91
|
+
try {
|
|
92
|
+
return (await dynamicImport('@anthropic-ai/claude-agent-sdk'));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const message = 'claude-agent-sdk provider requires @anthropic-ai/claude-agent-sdk. ' +
|
|
96
|
+
'Install it in your JavaScript runtime project and authenticate with Claude Agent SDK.';
|
|
97
|
+
const wrappedError = new Error(message);
|
|
98
|
+
wrappedError.cause = error;
|
|
99
|
+
throw wrappedError;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
103
|
+
//# sourceMappingURL=ClaudeAgentSDKChatService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeAgentSDKChatService.js","sourceRoot":"","sources":["../../../../../src/services/providers/agent/ClaudeAgentSDKChatService.ts"],"names":[],"mappings":";;;AACA,qCAAwE;AAE3D,QAAA,8BAA8B,GAAG,gBAAgB,CAAC;AAwC/D,MAAa,yBAA0B,SAAQ,6BAAoB;IACjE,YACE,UAA4C,EAAE,EAC9C,UAAgC,kBAAkB;QAElD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,sCAA8B,CAAC;QAE9D,KAAK,CAAC;YACJ,QAAQ,EAAE,kBAAkB;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AED,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAErD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChatService } from '../../ChatService';
|
|
2
|
+
import { ChatServiceProvider, VisionSupportLevel } from '../ChatServiceProvider';
|
|
3
|
+
import { ClaudeAgentSDKChatServiceOptions, ClaudeAgentSDKLoader } from './ClaudeAgentSDKChatService';
|
|
4
|
+
export declare class ClaudeAgentSDKChatServiceProvider implements ChatServiceProvider<ClaudeAgentSDKChatServiceOptions> {
|
|
5
|
+
private loadSDK?;
|
|
6
|
+
constructor(loadSDK?: ClaudeAgentSDKLoader | undefined);
|
|
7
|
+
createChatService(options: ClaudeAgentSDKChatServiceOptions): ChatService;
|
|
8
|
+
getProviderName(): string;
|
|
9
|
+
getSupportedModels(): string[];
|
|
10
|
+
getDefaultModel(): string;
|
|
11
|
+
supportsVision(): boolean;
|
|
12
|
+
getVisionSupportLevel(): VisionSupportLevel;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ClaudeAgentSDKChatServiceProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeAgentSDKChatServiceProvider.d.ts","sourceRoot":"","sources":["../../../../../src/services/providers/agent/ClaudeAgentSDKChatServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,gCAAgC,EAChC,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAGrC,qBAAa,iCACX,YAAW,mBAAmB,CAAC,gCAAgC,CAAC;IAEpD,OAAO,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,EAAE,oBAAoB,YAAA;IAElD,iBAAiB,CAAC,OAAO,EAAE,gCAAgC,GAAG,WAAW;IAKzE,eAAe,IAAI,MAAM;IAIzB,kBAAkB,IAAI,MAAM,EAAE;IAI9B,eAAe,IAAI,MAAM;IAIzB,cAAc,IAAI,OAAO;IAIzB,qBAAqB,IAAI,kBAAkB;CAG5C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClaudeAgentSDKChatServiceProvider = void 0;
|
|
4
|
+
const ClaudeAgentSDKChatService_1 = require("./ClaudeAgentSDKChatService");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
class ClaudeAgentSDKChatServiceProvider {
|
|
7
|
+
constructor(loadSDK) {
|
|
8
|
+
this.loadSDK = loadSDK;
|
|
9
|
+
}
|
|
10
|
+
createChatService(options) {
|
|
11
|
+
(0, shared_1.rejectUnsupportedAgentOptions)(this.getProviderName(), options);
|
|
12
|
+
return new ClaudeAgentSDKChatService_1.ClaudeAgentSDKChatService(options, this.loadSDK);
|
|
13
|
+
}
|
|
14
|
+
getProviderName() {
|
|
15
|
+
return 'claude-agent-sdk';
|
|
16
|
+
}
|
|
17
|
+
getSupportedModels() {
|
|
18
|
+
return [ClaudeAgentSDKChatService_1.DEFAULT_CLAUDE_AGENT_SDK_MODEL];
|
|
19
|
+
}
|
|
20
|
+
getDefaultModel() {
|
|
21
|
+
return ClaudeAgentSDKChatService_1.DEFAULT_CLAUDE_AGENT_SDK_MODEL;
|
|
22
|
+
}
|
|
23
|
+
supportsVision() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
getVisionSupportLevel() {
|
|
27
|
+
return 'unsupported';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ClaudeAgentSDKChatServiceProvider = ClaudeAgentSDKChatServiceProvider;
|
|
31
|
+
//# sourceMappingURL=ClaudeAgentSDKChatServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeAgentSDKChatServiceProvider.js","sourceRoot":"","sources":["../../../../../src/services/providers/agent/ClaudeAgentSDKChatServiceProvider.ts"],"names":[],"mappings":";;;AAKA,2EAKqC;AACrC,qCAAyD;AAEzD,MAAa,iCAAiC;IAG5C,YAAoB,OAA8B;QAA9B,YAAO,GAAP,OAAO,CAAuB;IAAG,CAAC;IAEtD,iBAAiB,CAAC,OAAyC;QACzD,IAAA,sCAA6B,EAAC,IAAI,CAAC,eAAe,EAAE,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,IAAI,qDAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,eAAe;QACb,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,kBAAkB;QAChB,OAAO,CAAC,0DAA8B,CAAC,CAAC;IAC1C,CAAC;IAED,eAAe;QACb,OAAO,0DAA8B,CAAC;IACxC,CAAC;IAED,cAAc;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IAED,qBAAqB;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AA7BD,8EA6BC"}
|