@causyne/agent 1.20.44 → 1.20.45
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 +1 -1
- package/src/commands.js +46 -0
- package/src/dynamicCatalogue.js +92 -10
- package/src/dynamicCatalogue.ts +86 -10
- package/src/providers/antigravity.js +29 -4
- package/src/providers/antigravity.ts +30 -4
- package/src/tui/modelPicker.js +7 -1
- package/src/tui/modelPicker.ts +9 -0
- package/src/tui/setup.js +3 -0
- package/src/tui/setup.ts +3 -0
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -1274,6 +1274,52 @@ export const COMMANDS = [
|
|
|
1274
1274
|
return ok(`Refreshed ${providerToRefresh} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
|
|
1275
1275
|
}
|
|
1276
1276
|
|
|
1277
|
+
if (first === 'test') {
|
|
1278
|
+
const targetProvider = argv[1] || config.provider;
|
|
1279
|
+
const targetModel = argv[2] || (targetProvider === config.provider ? config.model : undefined);
|
|
1280
|
+
if (!targetProvider) return fail('No provider specified or configured. Run /setup first.');
|
|
1281
|
+
|
|
1282
|
+
const testConfig = { ...config, provider: targetProvider };
|
|
1283
|
+
if (targetModel) {
|
|
1284
|
+
testConfig.model = targetModel;
|
|
1285
|
+
} else if (targetProvider !== config.provider) {
|
|
1286
|
+
delete testConfig.model;
|
|
1287
|
+
}
|
|
1288
|
+
if (config.providerKeys && config.providerKeys[targetProvider]) {
|
|
1289
|
+
testConfig.apiKey = config.providerKeys[targetProvider];
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
try {
|
|
1293
|
+
const { createProvider } = await import('./providers/factory.js');
|
|
1294
|
+
const providerInstance = createProvider(testConfig);
|
|
1295
|
+
const t0 = performance.now();
|
|
1296
|
+
const response = await providerInstance.chat([
|
|
1297
|
+
{ role: 'user', content: 'Respond with exactly: OK' }
|
|
1298
|
+
], { maxTokens: 16 });
|
|
1299
|
+
const latencyMs = Math.round(performance.now() - t0);
|
|
1300
|
+
|
|
1301
|
+
const outputLines = [
|
|
1302
|
+
`✅ API Call Test Succeeded: "${targetProvider}" / "${providerInstance.model || targetModel || 'default'}"`,
|
|
1303
|
+
'',
|
|
1304
|
+
` • Round-trip Latency : ${latencyMs} ms`,
|
|
1305
|
+
` • Response Content : ${JSON.stringify(response.content || '').slice(0, 80)}`,
|
|
1306
|
+
` • Tokens Used : ${response.usage ? `${response.usage.promptTokens} in / ${response.usage.completionTokens} out` : 'unreported'}`,
|
|
1307
|
+
'',
|
|
1308
|
+
'Wire format, credentials, and model endpoint are verified and accurate.'
|
|
1309
|
+
];
|
|
1310
|
+
return ok(outputLines.join('\n'));
|
|
1311
|
+
} catch (err) {
|
|
1312
|
+
return fail(
|
|
1313
|
+
`❌ API Call Test Failed for "${targetProvider}" / "${targetModel || config.model || 'default'}":\n\n`
|
|
1314
|
+
+ ` Error: ${err.message || err}\n\n`
|
|
1315
|
+
+ `Checks:\n`
|
|
1316
|
+
+ ` - Verify the API key in /setup.\n`
|
|
1317
|
+
+ ` - Check if the model is active with "/model list ${targetProvider}".\n`
|
|
1318
|
+
+ ` - Ensure the provider endpoint or account has sufficient quota.`
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1277
1323
|
const rawRequested = argv.join(' ').trim().replace(/^\/model\s+/i, '');
|
|
1278
1324
|
|
|
1279
1325
|
// Helper to cleanly activate a provider + model, persist config, update live loop & prompt
|
package/src/dynamicCatalogue.js
CHANGED
|
@@ -954,6 +954,51 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
954
954
|
return data.data.map((m) => m.id || '').filter(Boolean).sort();
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
|
+
if (norm === 'xai') {
|
|
958
|
+
if (!apiKey)
|
|
959
|
+
return [];
|
|
960
|
+
const host = (baseUrl || 'https://api.x.ai/v1').replace(/\/+$/, '');
|
|
961
|
+
const res = await fetch(`${host}/models`, {
|
|
962
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
963
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
964
|
+
});
|
|
965
|
+
if (!res.ok)
|
|
966
|
+
return [];
|
|
967
|
+
const data = await res.json();
|
|
968
|
+
if (Array.isArray(data.data)) {
|
|
969
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(grok)/i.test(id)).sort();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (norm === 'moonshot') {
|
|
973
|
+
if (!apiKey)
|
|
974
|
+
return [];
|
|
975
|
+
const host = (baseUrl || 'https://api.moonshot.cn/v1').replace(/\/+$/, '');
|
|
976
|
+
const res = await fetch(`${host}/models`, {
|
|
977
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
978
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
979
|
+
});
|
|
980
|
+
if (!res.ok)
|
|
981
|
+
return [];
|
|
982
|
+
const data = await res.json();
|
|
983
|
+
if (Array.isArray(data.data)) {
|
|
984
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(kimi|moonshot)/i.test(id)).sort();
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (norm === 'dashscope-byok' || norm === 'qwen') {
|
|
988
|
+
if (!apiKey)
|
|
989
|
+
return [];
|
|
990
|
+
const host = (baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1').replace(/\/+$/, '');
|
|
991
|
+
const res = await fetch(`${host}/models`, {
|
|
992
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
993
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
994
|
+
});
|
|
995
|
+
if (!res.ok)
|
|
996
|
+
return [];
|
|
997
|
+
const data = await res.json();
|
|
998
|
+
if (Array.isArray(data.data)) {
|
|
999
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(qwen)/i.test(id)).sort();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
957
1002
|
if (norm === 'openai-compatible') {
|
|
958
1003
|
if (!baseUrl)
|
|
959
1004
|
return [];
|
|
@@ -978,37 +1023,74 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
978
1023
|
}
|
|
979
1024
|
return [];
|
|
980
1025
|
}
|
|
1026
|
+
function resolveEffectiveApiKey(norm, config = {}) {
|
|
1027
|
+
if (config.apiKey)
|
|
1028
|
+
return config.apiKey;
|
|
1029
|
+
const pKeys = config.providerKeys;
|
|
1030
|
+
if (pKeys) {
|
|
1031
|
+
if (pKeys[norm])
|
|
1032
|
+
return pKeys[norm];
|
|
1033
|
+
if (norm === 'qwen' && pKeys['dashscope-byok'])
|
|
1034
|
+
return pKeys['dashscope-byok'];
|
|
1035
|
+
if (norm === 'dashscope-byok' && pKeys['qwen'])
|
|
1036
|
+
return pKeys['qwen'];
|
|
1037
|
+
}
|
|
1038
|
+
const envMap = {
|
|
1039
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
1040
|
+
openai: 'OPENAI_API_KEY',
|
|
1041
|
+
gemini: 'GEMINI_API_KEY',
|
|
1042
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
1043
|
+
qwen: 'DASHSCOPE_API_KEY',
|
|
1044
|
+
'dashscope-byok': 'DASHSCOPE_API_KEY',
|
|
1045
|
+
xai: 'XAI_API_KEY',
|
|
1046
|
+
moonshot: 'MOONSHOT_API_KEY'
|
|
1047
|
+
};
|
|
1048
|
+
const envVar = envMap[norm];
|
|
1049
|
+
if (envVar && process.env[envVar]) {
|
|
1050
|
+
return process.env[envVar];
|
|
1051
|
+
}
|
|
1052
|
+
return '';
|
|
1053
|
+
}
|
|
981
1054
|
/**
|
|
982
1055
|
* Resolve available models using dual-layer architecture:
|
|
983
1056
|
* 1. Checks live query if forceRefresh is true.
|
|
984
1057
|
* 2. Checks local cache if available and fresh.
|
|
985
|
-
* 3. Falls back to static curated catalogue
|
|
1058
|
+
* 3. Falls back to static curated catalogue when unconfigured or offline.
|
|
986
1059
|
*/
|
|
987
1060
|
export async function resolveAvailableModels(provider, config = {}, forceRefresh = false) {
|
|
988
1061
|
const norm = normalizeProviderKey(provider);
|
|
989
1062
|
const curated = getCuratedModels(norm);
|
|
990
1063
|
const localAgent = isLocalOrAcpProvider(norm);
|
|
1064
|
+
const effectiveKey = resolveEffectiveApiKey(norm, config);
|
|
1065
|
+
const queryConfig = {};
|
|
1066
|
+
if (config.baseUrl)
|
|
1067
|
+
queryConfig.baseUrl = config.baseUrl;
|
|
1068
|
+
if (config.providerKeys)
|
|
1069
|
+
queryConfig.providerKeys = config.providerKeys;
|
|
1070
|
+
const keyToUse = effectiveKey || config.apiKey;
|
|
1071
|
+
if (keyToUse)
|
|
1072
|
+
queryConfig.apiKey = keyToUse;
|
|
991
1073
|
if (forceRefresh) {
|
|
992
|
-
const live = await fetchLiveModels(norm,
|
|
1074
|
+
const live = await fetchLiveModels(norm, queryConfig);
|
|
993
1075
|
if (live.length > 0) {
|
|
994
|
-
const models =
|
|
995
|
-
saveCachedModels(norm, models, { config });
|
|
1076
|
+
const models = [...new Set(live)];
|
|
1077
|
+
saveCachedModels(norm, models, { config: queryConfig });
|
|
996
1078
|
return { models, source: 'live' };
|
|
997
1079
|
}
|
|
998
1080
|
}
|
|
999
|
-
const cached = getCachedModels(norm,
|
|
1081
|
+
const cached = getCachedModels(norm, queryConfig);
|
|
1000
1082
|
if (cached && cached.length > 0) {
|
|
1001
|
-
const models =
|
|
1083
|
+
const models = [...new Set(cached)];
|
|
1002
1084
|
return { models, source: 'cache' };
|
|
1003
1085
|
}
|
|
1004
1086
|
// Attempt lazy background discovery if credentials exist. Peer agents and
|
|
1005
1087
|
// Antigravity are credentialed by their own CLI login, so they qualify even
|
|
1006
1088
|
// with no apiKey in Causyne's vault.
|
|
1007
|
-
if (
|
|
1008
|
-
const live = await fetchLiveModels(norm,
|
|
1089
|
+
if (effectiveKey || norm === 'ollama' || localAgent) {
|
|
1090
|
+
const live = await fetchLiveModels(norm, queryConfig);
|
|
1009
1091
|
if (live.length > 0) {
|
|
1010
|
-
const models =
|
|
1011
|
-
saveCachedModels(norm, models, { config });
|
|
1092
|
+
const models = [...new Set(live)];
|
|
1093
|
+
saveCachedModels(norm, models, { config: queryConfig });
|
|
1012
1094
|
return { models, source: 'live' };
|
|
1013
1095
|
}
|
|
1014
1096
|
}
|
package/src/dynamicCatalogue.ts
CHANGED
|
@@ -1024,6 +1024,48 @@ export async function fetchLiveModels(
|
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
|
|
1027
|
+
if (norm === 'xai') {
|
|
1028
|
+
if (!apiKey) return [];
|
|
1029
|
+
const host = (baseUrl || 'https://api.x.ai/v1').replace(/\/+$/, '');
|
|
1030
|
+
const res = await fetch(`${host}/models`, {
|
|
1031
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
1032
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1033
|
+
});
|
|
1034
|
+
if (!res.ok) return [];
|
|
1035
|
+
const data = await res.json() as { data?: Array<{ id?: string }> };
|
|
1036
|
+
if (Array.isArray(data.data)) {
|
|
1037
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(grok)/i.test(id)).sort();
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (norm === 'moonshot') {
|
|
1042
|
+
if (!apiKey) return [];
|
|
1043
|
+
const host = (baseUrl || 'https://api.moonshot.cn/v1').replace(/\/+$/, '');
|
|
1044
|
+
const res = await fetch(`${host}/models`, {
|
|
1045
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
1046
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1047
|
+
});
|
|
1048
|
+
if (!res.ok) return [];
|
|
1049
|
+
const data = await res.json() as { data?: Array<{ id?: string }> };
|
|
1050
|
+
if (Array.isArray(data.data)) {
|
|
1051
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(kimi|moonshot)/i.test(id)).sort();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
if (norm === 'dashscope-byok' || norm === 'qwen') {
|
|
1056
|
+
if (!apiKey) return [];
|
|
1057
|
+
const host = (baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1').replace(/\/+$/, '');
|
|
1058
|
+
const res = await fetch(`${host}/models`, {
|
|
1059
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
1060
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1061
|
+
});
|
|
1062
|
+
if (!res.ok) return [];
|
|
1063
|
+
const data = await res.json() as { data?: Array<{ id?: string }> };
|
|
1064
|
+
if (Array.isArray(data.data)) {
|
|
1065
|
+
return data.data.map((m) => m.id || '').filter((id) => /^(qwen)/i.test(id)).sort();
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1027
1069
|
if (norm === 'openai-compatible') {
|
|
1028
1070
|
if (!baseUrl) return [];
|
|
1029
1071
|
const host = baseUrl.replace(/\/+$/, '');
|
|
@@ -1050,11 +1092,39 @@ export interface ModelResolutionResult {
|
|
|
1050
1092
|
source: 'live' | 'cache' | 'catalogue';
|
|
1051
1093
|
}
|
|
1052
1094
|
|
|
1095
|
+
function resolveEffectiveApiKey(
|
|
1096
|
+
norm: string,
|
|
1097
|
+
config: { apiKey?: string; providerKeys?: Record<string, string> } = {}
|
|
1098
|
+
): string {
|
|
1099
|
+
if (config.apiKey) return config.apiKey;
|
|
1100
|
+
const pKeys = config.providerKeys;
|
|
1101
|
+
if (pKeys) {
|
|
1102
|
+
if (pKeys[norm]) return pKeys[norm]!;
|
|
1103
|
+
if (norm === 'qwen' && pKeys['dashscope-byok']) return pKeys['dashscope-byok']!;
|
|
1104
|
+
if (norm === 'dashscope-byok' && pKeys['qwen']) return pKeys['qwen']!;
|
|
1105
|
+
}
|
|
1106
|
+
const envMap: Record<string, string> = {
|
|
1107
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
1108
|
+
openai: 'OPENAI_API_KEY',
|
|
1109
|
+
gemini: 'GEMINI_API_KEY',
|
|
1110
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
1111
|
+
qwen: 'DASHSCOPE_API_KEY',
|
|
1112
|
+
'dashscope-byok': 'DASHSCOPE_API_KEY',
|
|
1113
|
+
xai: 'XAI_API_KEY',
|
|
1114
|
+
moonshot: 'MOONSHOT_API_KEY'
|
|
1115
|
+
};
|
|
1116
|
+
const envVar = envMap[norm];
|
|
1117
|
+
if (envVar && process.env[envVar]) {
|
|
1118
|
+
return process.env[envVar]!;
|
|
1119
|
+
}
|
|
1120
|
+
return '';
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1053
1123
|
/**
|
|
1054
1124
|
* Resolve available models using dual-layer architecture:
|
|
1055
1125
|
* 1. Checks live query if forceRefresh is true.
|
|
1056
1126
|
* 2. Checks local cache if available and fresh.
|
|
1057
|
-
* 3. Falls back to static curated catalogue
|
|
1127
|
+
* 3. Falls back to static curated catalogue when unconfigured or offline.
|
|
1058
1128
|
*/
|
|
1059
1129
|
export async function resolveAvailableModels(
|
|
1060
1130
|
provider: string,
|
|
@@ -1064,30 +1134,36 @@ export async function resolveAvailableModels(
|
|
|
1064
1134
|
const norm = normalizeProviderKey(provider);
|
|
1065
1135
|
const curated = getCuratedModels(norm);
|
|
1066
1136
|
const localAgent = isLocalOrAcpProvider(norm);
|
|
1137
|
+
const effectiveKey = resolveEffectiveApiKey(norm, config);
|
|
1138
|
+
const queryConfig: { apiKey?: string; baseUrl?: string; providerKeys?: Record<string, string> } = {};
|
|
1139
|
+
if (config.baseUrl) queryConfig.baseUrl = config.baseUrl;
|
|
1140
|
+
if (config.providerKeys) queryConfig.providerKeys = config.providerKeys;
|
|
1141
|
+
const keyToUse = effectiveKey || config.apiKey;
|
|
1142
|
+
if (keyToUse) queryConfig.apiKey = keyToUse;
|
|
1067
1143
|
|
|
1068
1144
|
if (forceRefresh) {
|
|
1069
|
-
const live = await fetchLiveModels(norm,
|
|
1145
|
+
const live = await fetchLiveModels(norm, queryConfig);
|
|
1070
1146
|
if (live.length > 0) {
|
|
1071
|
-
const models =
|
|
1072
|
-
saveCachedModels(norm, models, { config });
|
|
1147
|
+
const models = [...new Set(live)];
|
|
1148
|
+
saveCachedModels(norm, models, { config: queryConfig });
|
|
1073
1149
|
return { models, source: 'live' };
|
|
1074
1150
|
}
|
|
1075
1151
|
}
|
|
1076
1152
|
|
|
1077
|
-
const cached = getCachedModels(norm,
|
|
1153
|
+
const cached = getCachedModels(norm, queryConfig);
|
|
1078
1154
|
if (cached && cached.length > 0) {
|
|
1079
|
-
const models =
|
|
1155
|
+
const models = [...new Set(cached)];
|
|
1080
1156
|
return { models, source: 'cache' };
|
|
1081
1157
|
}
|
|
1082
1158
|
|
|
1083
1159
|
// Attempt lazy background discovery if credentials exist. Peer agents and
|
|
1084
1160
|
// Antigravity are credentialed by their own CLI login, so they qualify even
|
|
1085
1161
|
// with no apiKey in Causyne's vault.
|
|
1086
|
-
if (
|
|
1087
|
-
const live = await fetchLiveModels(norm,
|
|
1162
|
+
if (effectiveKey || norm === 'ollama' || localAgent) {
|
|
1163
|
+
const live = await fetchLiveModels(norm, queryConfig);
|
|
1088
1164
|
if (live.length > 0) {
|
|
1089
|
-
const models =
|
|
1090
|
-
saveCachedModels(norm, models, { config });
|
|
1165
|
+
const models = [...new Set(live)];
|
|
1166
|
+
saveCachedModels(norm, models, { config: queryConfig });
|
|
1091
1167
|
return { models, source: 'live' };
|
|
1092
1168
|
}
|
|
1093
1169
|
}
|
|
@@ -243,6 +243,29 @@ export function isAntigravityProvider(provider) {
|
|
|
243
243
|
const p = String(provider).toLowerCase();
|
|
244
244
|
return p === 'antigravity' || p === 'agy' || p.startsWith('antigravity/') || p.startsWith('agy/');
|
|
245
245
|
}
|
|
246
|
+
export function isAntigravityModel(input) {
|
|
247
|
+
if (typeof input !== 'string' || !input.trim())
|
|
248
|
+
return false;
|
|
249
|
+
const trimmed = input.trim();
|
|
250
|
+
if (ANTIGRAVITY_MODEL_IDS[trimmed])
|
|
251
|
+
return true;
|
|
252
|
+
const lower = trimmed.toLowerCase();
|
|
253
|
+
for (const [key, slug] of Object.entries(ANTIGRAVITY_MODEL_IDS)) {
|
|
254
|
+
if (key.toLowerCase() === lower || slug.toLowerCase() === lower)
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
if (trimmed.includes('/') ||
|
|
258
|
+
trimmed.startsWith('deepseek') ||
|
|
259
|
+
trimmed.startsWith('qwen') ||
|
|
260
|
+
trimmed.startsWith('kimi') ||
|
|
261
|
+
trimmed.startsWith('gpt-4') ||
|
|
262
|
+
trimmed.startsWith('gpt-5') ||
|
|
263
|
+
trimmed.startsWith('o1') ||
|
|
264
|
+
trimmed.startsWith('o3')) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
246
269
|
export function resolveAgyBinary() {
|
|
247
270
|
const envPath = process.env.PATH || '';
|
|
248
271
|
const searchDirs = [
|
|
@@ -676,7 +699,8 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
676
699
|
lastCumulativeUsage = null;
|
|
677
700
|
constructor(config = {}) {
|
|
678
701
|
super(config);
|
|
679
|
-
|
|
702
|
+
const candidate = config.model;
|
|
703
|
+
this.model = (candidate && isAntigravityModel(candidate)) ? candidate : 'Gemini 3.8 Flash (Low)';
|
|
680
704
|
this.command = config.command || resolveAgyBinary();
|
|
681
705
|
this.printTimeout = typeof config.printTimeout === 'string' && config.printTimeout.trim()
|
|
682
706
|
? config.printTimeout.trim()
|
|
@@ -936,10 +960,11 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
936
960
|
'--print-timeout',
|
|
937
961
|
launchOnly ? '90s' : this.printTimeout,
|
|
938
962
|
'--model',
|
|
939
|
-
modelSlug
|
|
940
|
-
'--effort',
|
|
941
|
-
effort
|
|
963
|
+
modelSlug
|
|
942
964
|
];
|
|
965
|
+
if (effort && (modelSlug.endsWith(`-${effort}`) || /-(low|medium|high|xhigh|max)$/i.test(modelSlug))) {
|
|
966
|
+
args.push('--effort', effort);
|
|
967
|
+
}
|
|
943
968
|
if (useConversation && this.currentConversationId) {
|
|
944
969
|
args.push('--conversation', this.currentConversationId);
|
|
945
970
|
}
|
|
@@ -246,6 +246,29 @@ export function isAntigravityProvider(provider?: string | null): boolean {
|
|
|
246
246
|
return p === 'antigravity' || p === 'agy' || p.startsWith('antigravity/') || p.startsWith('agy/');
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
export function isAntigravityModel(input?: string | null): boolean {
|
|
250
|
+
if (typeof input !== 'string' || !input.trim()) return false;
|
|
251
|
+
const trimmed = input.trim();
|
|
252
|
+
if (ANTIGRAVITY_MODEL_IDS[trimmed]) return true;
|
|
253
|
+
const lower = trimmed.toLowerCase();
|
|
254
|
+
for (const [key, slug] of Object.entries(ANTIGRAVITY_MODEL_IDS)) {
|
|
255
|
+
if (key.toLowerCase() === lower || slug.toLowerCase() === lower) return true;
|
|
256
|
+
}
|
|
257
|
+
if (
|
|
258
|
+
trimmed.includes('/') ||
|
|
259
|
+
trimmed.startsWith('deepseek') ||
|
|
260
|
+
trimmed.startsWith('qwen') ||
|
|
261
|
+
trimmed.startsWith('kimi') ||
|
|
262
|
+
trimmed.startsWith('gpt-4') ||
|
|
263
|
+
trimmed.startsWith('gpt-5') ||
|
|
264
|
+
trimmed.startsWith('o1') ||
|
|
265
|
+
trimmed.startsWith('o3')
|
|
266
|
+
) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
|
|
249
272
|
export function resolveAgyBinary(): string {
|
|
250
273
|
const envPath = process.env.PATH || '';
|
|
251
274
|
const searchDirs = [
|
|
@@ -694,7 +717,8 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
694
717
|
|
|
695
718
|
constructor(config: ProviderConfig = {}) {
|
|
696
719
|
super(config);
|
|
697
|
-
|
|
720
|
+
const candidate = config.model;
|
|
721
|
+
this.model = (candidate && isAntigravityModel(candidate)) ? candidate : 'Gemini 3.8 Flash (Low)';
|
|
698
722
|
this.command = config.command || resolveAgyBinary();
|
|
699
723
|
this.printTimeout = typeof config.printTimeout === 'string' && config.printTimeout.trim()
|
|
700
724
|
? config.printTimeout.trim()
|
|
@@ -969,11 +993,13 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
969
993
|
'--print-timeout',
|
|
970
994
|
launchOnly ? '90s' : this.printTimeout,
|
|
971
995
|
'--model',
|
|
972
|
-
modelSlug
|
|
973
|
-
'--effort',
|
|
974
|
-
effort
|
|
996
|
+
modelSlug
|
|
975
997
|
];
|
|
976
998
|
|
|
999
|
+
if (effort && (modelSlug.endsWith(`-${effort}`) || /-(low|medium|high|xhigh|max)$/i.test(modelSlug))) {
|
|
1000
|
+
args.push('--effort', effort);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
977
1003
|
if (useConversation && this.currentConversationId) {
|
|
978
1004
|
args.push('--conversation', this.currentConversationId);
|
|
979
1005
|
}
|
package/src/tui/modelPicker.js
CHANGED
|
@@ -9,7 +9,7 @@ import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
|
9
9
|
// @ts-expect-error untyped local TUI selectList
|
|
10
10
|
import { fuzzyFilter } from './selectList.js';
|
|
11
11
|
import { loadConfig, saveConfig } from '../config.js';
|
|
12
|
-
import { getAvailableProvidersOverview, resolveAvailableProvidersOverview } from '../dynamicCatalogue.js';
|
|
12
|
+
import { getAvailableProvidersOverview, resolveAvailableProvidersOverview, resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
13
13
|
async function showConfiguringAnimation(providerLabel) {
|
|
14
14
|
if (!process.stdout.isTTY)
|
|
15
15
|
return;
|
|
@@ -407,6 +407,10 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
407
407
|
config['providerKeys'][target.providerId] = existingKey;
|
|
408
408
|
}
|
|
409
409
|
store.saveConfig(config);
|
|
410
|
+
// Proactively refresh live models in the background for this active provider
|
|
411
|
+
if (existingKey || target.providerId === 'ollama') {
|
|
412
|
+
void resolveAvailableModels(target.providerId, { ...config, apiKey: existingKey }, true).catch(() => { });
|
|
413
|
+
}
|
|
410
414
|
if (options.loop) {
|
|
411
415
|
options.loop.config = config;
|
|
412
416
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
@@ -442,6 +446,8 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
442
446
|
config['providerKeys'] = providerKeys;
|
|
443
447
|
config['providerKeys'][target.providerId] = cleanKey;
|
|
444
448
|
store.saveConfig(config);
|
|
449
|
+
// Proactively refresh live models in the background with the newly saved key
|
|
450
|
+
void resolveAvailableModels(target.providerId, { ...config, apiKey: cleanKey }, true).catch(() => { });
|
|
445
451
|
if (options.loop) {
|
|
446
452
|
options.loop.config = config;
|
|
447
453
|
if (typeof options.loop.updateTierLimits === 'function') {
|
package/src/tui/modelPicker.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { loadConfig, saveConfig } from '../config.js';
|
|
|
13
13
|
import {
|
|
14
14
|
getAvailableProvidersOverview,
|
|
15
15
|
resolveAvailableProvidersOverview,
|
|
16
|
+
resolveAvailableModels,
|
|
16
17
|
type ProviderOverview
|
|
17
18
|
} from '../dynamicCatalogue.js';
|
|
18
19
|
|
|
@@ -511,6 +512,11 @@ export async function runInteractiveModelPicker(
|
|
|
511
512
|
}
|
|
512
513
|
store.saveConfig(config);
|
|
513
514
|
|
|
515
|
+
// Proactively refresh live models in the background for this active provider
|
|
516
|
+
if (existingKey || target.providerId === 'ollama') {
|
|
517
|
+
void resolveAvailableModels(target.providerId, { ...config, apiKey: existingKey }, true).catch(() => {});
|
|
518
|
+
}
|
|
519
|
+
|
|
514
520
|
if (options.loop) {
|
|
515
521
|
options.loop.config = config;
|
|
516
522
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
@@ -551,6 +557,9 @@ export async function runInteractiveModelPicker(
|
|
|
551
557
|
config['providerKeys'][target.providerId] = cleanKey;
|
|
552
558
|
store.saveConfig(config);
|
|
553
559
|
|
|
560
|
+
// Proactively refresh live models in the background with the newly saved key
|
|
561
|
+
void resolveAvailableModels(target.providerId, { ...config, apiKey: cleanKey }, true).catch(() => {});
|
|
562
|
+
|
|
554
563
|
if (options.loop) {
|
|
555
564
|
options.loop.config = config;
|
|
556
565
|
if (typeof options.loop.updateTierLimits === 'function') {
|
package/src/tui/setup.js
CHANGED
|
@@ -131,6 +131,9 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
|
|
|
131
131
|
else
|
|
132
132
|
delete saved.baseUrl;
|
|
133
133
|
store.saveConfig(saved);
|
|
134
|
+
if (apiKey || provider.id === 'ollama' || isLocalAgent(provider.id)) {
|
|
135
|
+
void resolveAvailableModels(provider.id, saved, true).catch(() => { });
|
|
136
|
+
}
|
|
134
137
|
return { provider: provider.id, model };
|
|
135
138
|
}
|
|
136
139
|
}
|
package/src/tui/setup.ts
CHANGED
|
@@ -126,6 +126,9 @@ export async function runSetup(ui: SetupUI, providers: SetupProvider[], store: {
|
|
|
126
126
|
const saved: Config = next;
|
|
127
127
|
if (baseUrl) saved.baseUrl = baseUrl; else delete saved.baseUrl;
|
|
128
128
|
store.saveConfig(saved);
|
|
129
|
+
if (apiKey || provider.id === 'ollama' || isLocalAgent(provider.id)) {
|
|
130
|
+
void resolveAvailableModels(provider.id, saved, true).catch(() => {});
|
|
131
|
+
}
|
|
129
132
|
return { provider: provider.id, model };
|
|
130
133
|
}
|
|
131
134
|
}
|