@agi-cli/sdk 0.1.84 → 0.1.86

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/sdk",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "ntishxyz",
6
6
  "license": "MIT",
@@ -3,6 +3,7 @@ import { anthropic, createAnthropic } from '@ai-sdk/anthropic';
3
3
  import { google } from '@ai-sdk/google';
4
4
  import { createOpenRouter } from '@openrouter/ai-sdk-provider';
5
5
  import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
6
+ import { catalog } from '../../../providers/src/index.ts';
6
7
 
7
8
  export type ProviderName =
8
9
  | 'openai'
@@ -58,27 +59,64 @@ export async function resolveModel(
58
59
  }
59
60
 
60
61
  if (provider === 'opencode') {
61
- const baseURL = config.baseURL || 'https://opencode.ai/zen/v1';
62
+ const entry = catalog[provider];
63
+ const normalizedModel = normalizeModelIdentifier(provider, model);
64
+ const modelInfo =
65
+ entry?.models.find((m) => m.id === normalizedModel) ??
66
+ entry?.models.find((m) => m.id === model);
67
+ const resolvedModelId = modelInfo?.id ?? normalizedModel ?? model;
68
+ const binding = modelInfo?.provider?.npm ?? entry?.npm;
62
69
  const apiKey = config.apiKey || process.env.OPENCODE_API_KEY || '';
70
+ const baseURL =
71
+ config.baseURL ||
72
+ modelInfo?.provider?.baseURL ||
73
+ modelInfo?.provider?.api ||
74
+ entry?.api ||
75
+ 'https://opencode.ai/zen/v1';
76
+ const headers = apiKey ? { Authorization: `Bearer ${apiKey}` } : undefined;
77
+ if (binding === '@ai-sdk/openai') {
78
+ const instance = createOpenAI({ apiKey, baseURL });
79
+ return instance(resolvedModelId);
80
+ }
81
+ if (binding === '@ai-sdk/anthropic') {
82
+ const instance = createAnthropic({ apiKey, baseURL });
83
+ return instance(resolvedModelId);
84
+ }
85
+ if (binding === '@ai-sdk/openai-compatible') {
86
+ const instance = createOpenAICompatible({
87
+ name: entry?.label ?? 'opencode',
88
+ baseURL,
89
+ headers,
90
+ });
91
+ return instance(resolvedModelId);
92
+ }
63
93
 
64
94
  const ocOpenAI = createOpenAI({ apiKey, baseURL });
65
95
  const ocAnthropic = createAnthropic({ apiKey, baseURL });
66
96
  const ocCompat = createOpenAICompatible({
67
- name: 'opencode',
97
+ name: entry?.label ?? 'opencode',
68
98
  baseURL,
69
- headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : undefined,
99
+ headers,
70
100
  });
71
101
 
72
- const id = model.toLowerCase();
73
- if (id.includes('claude')) return ocAnthropic(model);
102
+ const id = resolvedModelId.toLowerCase();
103
+ if (id.includes('claude')) return ocAnthropic(resolvedModelId);
74
104
  if (
75
105
  id.includes('qwen3-coder') ||
76
106
  id.includes('grok-code') ||
77
107
  id.includes('kimi-k2')
78
108
  )
79
- return ocCompat(model);
80
- return ocOpenAI(model);
109
+ return ocCompat(resolvedModelId);
110
+ return ocOpenAI(resolvedModelId);
81
111
  }
82
112
 
83
113
  throw new Error(`Unsupported provider: ${provider}`);
84
114
  }
115
+
116
+ function normalizeModelIdentifier(
117
+ provider: ProviderName,
118
+ model: string,
119
+ ): string {
120
+ const prefix = `${provider}/`;
121
+ return model.startsWith(prefix) ? model.slice(prefix.length) : model;
122
+ }
package/src/index.ts CHANGED
@@ -13,7 +13,12 @@
13
13
  // Types (from internal types module)
14
14
  // =======================
15
15
  // Provider types
16
- export type { ProviderId, ModelInfo } from './types/src/index.ts';
16
+ export type {
17
+ ProviderId,
18
+ ModelInfo,
19
+ ModelProviderBinding,
20
+ ProviderCatalogEntry,
21
+ } from './types/src/index.ts';
17
22
 
18
23
  // Auth types
19
24
  export type { ApiAuth, OAuth, AuthInfo, AuthFile } from './types/src/index.ts';
@@ -1,9 +1,13 @@
1
1
  // AUTO-GENERATED by scripts/update-catalog.ts. Do not edit manually.
2
2
 
3
- import type { ProviderId, ModelInfo } from '../../types/src/index.ts';
3
+ import type {
4
+ ProviderId,
5
+ ProviderCatalogEntry,
6
+ } from '../../types/src/index.ts';
4
7
 
5
- export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
8
+ export const catalog: Record<ProviderId, ProviderCatalogEntry> = {
6
9
  openai: {
10
+ id: 'openai',
7
11
  models: [
8
12
  {
9
13
  id: 'codex-mini-latest',
@@ -366,6 +370,11 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
366
370
  releaseDate: '2025-09-15',
367
371
  lastUpdated: '2025-09-15',
368
372
  openWeights: false,
373
+ cost: {
374
+ input: 1.25,
375
+ output: 10,
376
+ cacheRead: 0.125,
377
+ },
369
378
  limit: {
370
379
  context: 400000,
371
380
  output: 128000,
@@ -670,8 +679,13 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
670
679
  },
671
680
  },
672
681
  ],
682
+ label: 'OpenAI',
683
+ env: ['OPENAI_API_KEY'],
684
+ npm: '@ai-sdk/openai',
685
+ doc: 'https://platform.openai.com/docs/models',
673
686
  },
674
687
  anthropic: {
688
+ id: 'anthropic',
675
689
  models: [
676
690
  {
677
691
  id: 'claude-3-5-haiku-20241022',
@@ -949,8 +963,13 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
949
963
  },
950
964
  },
951
965
  ],
966
+ label: 'Anthropic',
967
+ env: ['ANTHROPIC_API_KEY'],
968
+ npm: '@ai-sdk/anthropic',
969
+ doc: 'https://docs.anthropic.com/en/docs/about-claude/models',
952
970
  },
953
971
  google: {
972
+ id: 'google',
954
973
  models: [
955
974
  {
956
975
  id: 'gemini-1.5-flash',
@@ -1101,6 +1120,56 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
1101
1120
  output: 65536,
1102
1121
  },
1103
1122
  },
1123
+ {
1124
+ id: 'gemini-2.5-flash-image',
1125
+ label: 'Gemini 2.5 Flash Image',
1126
+ modalities: {
1127
+ input: ['text', 'image'],
1128
+ output: ['text', 'image'],
1129
+ },
1130
+ toolCall: false,
1131
+ reasoning: true,
1132
+ attachment: true,
1133
+ temperature: true,
1134
+ knowledge: '2025-06',
1135
+ releaseDate: '2025-08-26',
1136
+ lastUpdated: '2025-08-26',
1137
+ openWeights: false,
1138
+ cost: {
1139
+ input: 0.3,
1140
+ output: 30,
1141
+ cacheRead: 0.075,
1142
+ },
1143
+ limit: {
1144
+ context: 32768,
1145
+ output: 32768,
1146
+ },
1147
+ },
1148
+ {
1149
+ id: 'gemini-2.5-flash-image-preview',
1150
+ label: 'Gemini 2.5 Flash Image (Preview)',
1151
+ modalities: {
1152
+ input: ['text', 'image'],
1153
+ output: ['text', 'image'],
1154
+ },
1155
+ toolCall: false,
1156
+ reasoning: true,
1157
+ attachment: true,
1158
+ temperature: true,
1159
+ knowledge: '2025-06',
1160
+ releaseDate: '2025-08-26',
1161
+ lastUpdated: '2025-08-26',
1162
+ openWeights: false,
1163
+ cost: {
1164
+ input: 0.3,
1165
+ output: 30,
1166
+ cacheRead: 0.075,
1167
+ },
1168
+ limit: {
1169
+ context: 32768,
1170
+ output: 32768,
1171
+ },
1172
+ },
1104
1173
  {
1105
1174
  id: 'gemini-2.5-flash-lite',
1106
1175
  label: 'Gemini 2.5 Flash Lite',
@@ -1251,6 +1320,30 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
1251
1320
  output: 65536,
1252
1321
  },
1253
1322
  },
1323
+ {
1324
+ id: 'gemini-2.5-flash-preview-tts',
1325
+ label: 'Gemini 2.5 Flash Preview TTS',
1326
+ modalities: {
1327
+ input: ['text'],
1328
+ output: ['audio'],
1329
+ },
1330
+ toolCall: false,
1331
+ reasoning: false,
1332
+ attachment: false,
1333
+ temperature: false,
1334
+ knowledge: '2025-01',
1335
+ releaseDate: '2025-05-01',
1336
+ lastUpdated: '2025-05-01',
1337
+ openWeights: false,
1338
+ cost: {
1339
+ input: 0.5,
1340
+ output: 10,
1341
+ },
1342
+ limit: {
1343
+ context: 8000,
1344
+ output: 16000,
1345
+ },
1346
+ },
1254
1347
  {
1255
1348
  id: 'gemini-2.5-pro',
1256
1349
  label: 'Gemini 2.5 Pro',
@@ -1326,6 +1419,30 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
1326
1419
  output: 65536,
1327
1420
  },
1328
1421
  },
1422
+ {
1423
+ id: 'gemini-2.5-pro-preview-tts',
1424
+ label: 'Gemini 2.5 Pro Preview TTS',
1425
+ modalities: {
1426
+ input: ['text'],
1427
+ output: ['audio'],
1428
+ },
1429
+ toolCall: false,
1430
+ reasoning: false,
1431
+ attachment: false,
1432
+ temperature: false,
1433
+ knowledge: '2025-01',
1434
+ releaseDate: '2025-05-01',
1435
+ lastUpdated: '2025-05-01',
1436
+ openWeights: false,
1437
+ cost: {
1438
+ input: 1,
1439
+ output: 20,
1440
+ },
1441
+ limit: {
1442
+ context: 8000,
1443
+ output: 16000,
1444
+ },
1445
+ },
1329
1446
  {
1330
1447
  id: 'gemini-flash-latest',
1331
1448
  label: 'Gemini Flash Latest',
@@ -1376,6 +1493,30 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
1376
1493
  output: 65536,
1377
1494
  },
1378
1495
  },
1496
+ {
1497
+ id: 'gemini-live-2.5-flash',
1498
+ label: 'Gemini Live 2.5 Flash',
1499
+ modalities: {
1500
+ input: ['text', 'image', 'audio', 'video'],
1501
+ output: ['text', 'audio'],
1502
+ },
1503
+ toolCall: true,
1504
+ reasoning: true,
1505
+ attachment: true,
1506
+ temperature: true,
1507
+ knowledge: '2025-01',
1508
+ releaseDate: '2025-09-01',
1509
+ lastUpdated: '2025-09-01',
1510
+ openWeights: false,
1511
+ cost: {
1512
+ input: 0.5,
1513
+ output: 2,
1514
+ },
1515
+ limit: {
1516
+ context: 128000,
1517
+ output: 8000,
1518
+ },
1519
+ },
1379
1520
  {
1380
1521
  id: 'gemini-live-2.5-flash-preview-native-audio',
1381
1522
  label: 'Gemini Live 2.5 Flash Preview Native Audio',
@@ -1401,8 +1542,13 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
1401
1542
  },
1402
1543
  },
1403
1544
  ],
1545
+ label: 'Google',
1546
+ env: ['GOOGLE_GENERATIVE_AI_API_KEY', 'GEMINI_API_KEY'],
1547
+ npm: '@ai-sdk/google',
1548
+ doc: 'https://ai.google.dev/gemini-api/docs/pricing',
1404
1549
  },
1405
1550
  openrouter: {
1551
+ id: 'openrouter',
1406
1552
  models: [
1407
1553
  {
1408
1554
  id: 'anthropic/claude-3.5-haiku',
@@ -3271,7 +3417,7 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3271
3417
  input: ['text'],
3272
3418
  output: ['text'],
3273
3419
  },
3274
- toolCall: false,
3420
+ toolCall: true,
3275
3421
  reasoning: false,
3276
3422
  attachment: false,
3277
3423
  temperature: true,
@@ -3284,8 +3430,32 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3284
3430
  output: 0.8,
3285
3431
  },
3286
3432
  limit: {
3287
- context: 131072,
3288
- output: 33000,
3433
+ context: 262000,
3434
+ output: 262000,
3435
+ },
3436
+ },
3437
+ {
3438
+ id: 'qwen/qwen3-30b-a3b-thinking-2507',
3439
+ label: 'Qwen3 30B A3B Thinking 2507',
3440
+ modalities: {
3441
+ input: ['text'],
3442
+ output: ['text'],
3443
+ },
3444
+ toolCall: true,
3445
+ reasoning: true,
3446
+ attachment: false,
3447
+ temperature: true,
3448
+ knowledge: '2025-04',
3449
+ releaseDate: '2025-07-29',
3450
+ lastUpdated: '2025-07-29',
3451
+ openWeights: true,
3452
+ cost: {
3453
+ input: 0.2,
3454
+ output: 0.8,
3455
+ },
3456
+ limit: {
3457
+ context: 262000,
3458
+ output: 262000,
3289
3459
  },
3290
3460
  },
3291
3461
  {
@@ -3455,6 +3625,30 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3455
3625
  output: 262144,
3456
3626
  },
3457
3627
  },
3628
+ {
3629
+ id: 'qwen/qwen3-next-80b-a3b-thinking',
3630
+ label: 'Qwen3 Next 80B A3B Thinking',
3631
+ modalities: {
3632
+ input: ['text'],
3633
+ output: ['text'],
3634
+ },
3635
+ toolCall: true,
3636
+ reasoning: true,
3637
+ attachment: false,
3638
+ temperature: true,
3639
+ knowledge: '2025-04',
3640
+ releaseDate: '2025-09-11',
3641
+ lastUpdated: '2025-09-11',
3642
+ openWeights: true,
3643
+ cost: {
3644
+ input: 0.14,
3645
+ output: 1.4,
3646
+ },
3647
+ limit: {
3648
+ context: 262144,
3649
+ output: 262144,
3650
+ },
3651
+ },
3458
3652
  {
3459
3653
  id: 'qwen/qwq-32b:free',
3460
3654
  label: 'QwQ 32B (free)',
@@ -3897,9 +4091,39 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3897
4091
  },
3898
4092
  },
3899
4093
  ],
4094
+ label: 'OpenRouter',
4095
+ env: ['OPENROUTER_API_KEY'],
4096
+ npm: '@ai-sdk/openai-compatible',
4097
+ api: 'https://openrouter.ai/api/v1',
4098
+ doc: 'https://openrouter.ai/models',
3900
4099
  },
3901
4100
  opencode: {
4101
+ id: 'opencode',
3902
4102
  models: [
4103
+ {
4104
+ id: 'an-g8x',
4105
+ label: 'Code G8X (alpha)',
4106
+ modalities: {
4107
+ input: ['text'],
4108
+ output: ['text'],
4109
+ },
4110
+ toolCall: true,
4111
+ reasoning: true,
4112
+ attachment: false,
4113
+ temperature: true,
4114
+ knowledge: '2025-01',
4115
+ releaseDate: '2025-07-30',
4116
+ lastUpdated: '2025-07-30',
4117
+ openWeights: true,
4118
+ cost: {
4119
+ input: 0.5,
4120
+ output: 2,
4121
+ },
4122
+ limit: {
4123
+ context: 200000,
4124
+ output: 128000,
4125
+ },
4126
+ },
3903
4127
  {
3904
4128
  id: 'claude-3-5-haiku',
3905
4129
  label: 'Claude Haiku 3.5',
@@ -3924,6 +4148,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3924
4148
  context: 200000,
3925
4149
  output: 8192,
3926
4150
  },
4151
+ provider: {
4152
+ npm: '@ai-sdk/anthropic',
4153
+ },
3927
4154
  },
3928
4155
  {
3929
4156
  id: 'claude-opus-4-1',
@@ -3949,6 +4176,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3949
4176
  context: 200000,
3950
4177
  output: 32000,
3951
4178
  },
4179
+ provider: {
4180
+ npm: '@ai-sdk/anthropic',
4181
+ },
3952
4182
  },
3953
4183
  {
3954
4184
  id: 'claude-sonnet-4',
@@ -3974,6 +4204,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3974
4204
  context: 1000000,
3975
4205
  output: 64000,
3976
4206
  },
4207
+ provider: {
4208
+ npm: '@ai-sdk/anthropic',
4209
+ },
3977
4210
  },
3978
4211
  {
3979
4212
  id: 'claude-sonnet-4-5',
@@ -3999,6 +4232,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
3999
4232
  context: 1000000,
4000
4233
  output: 64000,
4001
4234
  },
4235
+ provider: {
4236
+ npm: '@ai-sdk/anthropic',
4237
+ },
4002
4238
  },
4003
4239
  {
4004
4240
  id: 'code-supernova',
@@ -4026,7 +4262,7 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
4026
4262
  },
4027
4263
  {
4028
4264
  id: 'glm-4.6',
4029
- label: 'GLM-4.6',
4265
+ label: 'GLM-4.6 (beta)',
4030
4266
  modalities: {
4031
4267
  input: ['text'],
4032
4268
  output: ['text'],
@@ -4041,8 +4277,7 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
4041
4277
  openWeights: true,
4042
4278
  cost: {
4043
4279
  input: 0.6,
4044
- output: 2.2,
4045
- cacheRead: 0.11,
4280
+ output: 1.9,
4046
4281
  },
4047
4282
  limit: {
4048
4283
  context: 204800,
@@ -4073,6 +4308,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
4073
4308
  context: 400000,
4074
4309
  output: 128000,
4075
4310
  },
4311
+ provider: {
4312
+ npm: '@ai-sdk/openai',
4313
+ },
4076
4314
  },
4077
4315
  {
4078
4316
  id: 'gpt-5-codex',
@@ -4098,6 +4336,9 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
4098
4336
  context: 400000,
4099
4337
  output: 128000,
4100
4338
  },
4339
+ provider: {
4340
+ npm: '@ai-sdk/openai',
4341
+ },
4101
4342
  },
4102
4343
  {
4103
4344
  id: 'grok-code',
@@ -4172,30 +4413,11 @@ export const catalog: Record<ProviderId, { models: ModelInfo[] }> = {
4172
4413
  output: 65536,
4173
4414
  },
4174
4415
  },
4175
- {
4176
- id: 'qwen3-max',
4177
- label: 'Qwen3 Max',
4178
- modalities: {
4179
- input: ['text'],
4180
- output: ['text'],
4181
- },
4182
- toolCall: true,
4183
- reasoning: true,
4184
- attachment: false,
4185
- temperature: true,
4186
- knowledge: '2025-04',
4187
- releaseDate: '2025-09-05',
4188
- lastUpdated: '2025-09-05',
4189
- openWeights: true,
4190
- cost: {
4191
- input: 1.6,
4192
- output: 6.4,
4193
- },
4194
- limit: {
4195
- context: 262144,
4196
- output: 65536,
4197
- },
4198
- },
4199
4416
  ],
4417
+ label: 'OpenCode Zen',
4418
+ env: ['OPENCODE_API_KEY'],
4419
+ npm: '@ai-sdk/openai-compatible',
4420
+ api: 'https://opencode.ai/zen/v1',
4421
+ doc: 'https://opencode.ai/docs/zen',
4200
4422
  },
4201
- } as const satisfies Record<ProviderId, { models: ModelInfo[] }>;
4423
+ } as const satisfies Record<ProviderId, ProviderCatalogEntry>;
@@ -1,6 +1,11 @@
1
1
  export { isProviderAuthorized, ensureProviderEnv } from './authorization.ts';
2
2
  export { catalog } from './catalog.ts';
3
- export type { ProviderId, ModelInfo } from '../../types/src/index.ts';
3
+ export type {
4
+ ProviderId,
5
+ ModelInfo,
6
+ ModelProviderBinding,
7
+ ProviderCatalogEntry,
8
+ } from '../../types/src/index.ts';
4
9
  export {
5
10
  isProviderId,
6
11
  providerIds,
@@ -1,5 +1,10 @@
1
1
  // Provider types
2
- export type { ProviderId, ModelInfo } from './provider';
2
+ export type {
3
+ ProviderId,
4
+ ModelInfo,
5
+ ModelProviderBinding,
6
+ ProviderCatalogEntry,
7
+ } from './provider';
3
8
 
4
9
  // Auth types
5
10
  export type { ApiAuth, OAuth, AuthInfo, AuthFile } from './auth';
@@ -8,6 +8,13 @@ export type ProviderId =
8
8
  | 'openrouter'
9
9
  | 'opencode';
10
10
 
11
+ export type ModelProviderBinding = {
12
+ id?: string;
13
+ npm?: string;
14
+ api?: string;
15
+ baseURL?: string;
16
+ };
17
+
11
18
  /**
12
19
  * Information about a specific model
13
20
  */
@@ -25,4 +32,15 @@ export type ModelInfo = {
25
32
  openWeights?: boolean;
26
33
  cost?: { input?: number; output?: number; cacheRead?: number };
27
34
  limit?: { context?: number; output?: number };
35
+ provider?: ModelProviderBinding;
36
+ };
37
+
38
+ export type ProviderCatalogEntry = {
39
+ id: ProviderId;
40
+ label?: string;
41
+ env?: string[];
42
+ npm?: string;
43
+ api?: string;
44
+ doc?: string;
45
+ models: ModelInfo[];
28
46
  };