@causyne/agent 1.20.71 → 1.20.72
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/auth/openrouterAuth.js +23 -3
- package/src/auth/openrouterAuth.ts +24 -4
- package/src/commands.js +25 -2
- package/src/dynamicCatalogue.js +9 -35
- package/src/dynamicCatalogue.ts +8 -35
- package/src/tui/modelPicker.js +46 -19
- package/src/tui/modelPicker.ts +53 -21
package/package.json
CHANGED
|
@@ -449,10 +449,30 @@ export function disconnectOpenRouter(store = { loadConfig, saveConfig }) {
|
|
|
449
449
|
};
|
|
450
450
|
delete providerKeys['openrouter'];
|
|
451
451
|
currentConfig.providerKeys = providerKeys;
|
|
452
|
+
if (process.env.OPENROUTER_API_KEY) {
|
|
453
|
+
delete process.env.OPENROUTER_API_KEY;
|
|
454
|
+
}
|
|
452
455
|
if (currentConfig.provider === 'openrouter') {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
+
if (providerKeys['deepseek']) {
|
|
457
|
+
currentConfig.provider = 'deepseek';
|
|
458
|
+
currentConfig.model = 'deepseek-chat';
|
|
459
|
+
currentConfig.apiKey = providerKeys['deepseek'];
|
|
460
|
+
}
|
|
461
|
+
else if (providerKeys['anthropic']) {
|
|
462
|
+
currentConfig.provider = 'anthropic';
|
|
463
|
+
currentConfig.model = 'claude-3-7-sonnet';
|
|
464
|
+
currentConfig.apiKey = providerKeys['anthropic'];
|
|
465
|
+
}
|
|
466
|
+
else if (providerKeys['openai']) {
|
|
467
|
+
currentConfig.provider = 'openai';
|
|
468
|
+
currentConfig.model = 'gpt-4o';
|
|
469
|
+
currentConfig.apiKey = providerKeys['openai'];
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
currentConfig.provider = 'antigravity';
|
|
473
|
+
currentConfig.model = 'Gemini 3.8 Flash (Low)';
|
|
474
|
+
currentConfig.apiKey = '';
|
|
475
|
+
}
|
|
456
476
|
}
|
|
457
477
|
store.saveConfig(currentConfig);
|
|
458
478
|
return currentConfig;
|
|
@@ -531,7 +531,9 @@ export function saveOpenRouterKey(
|
|
|
531
531
|
/**
|
|
532
532
|
* Disconnect OpenRouter credentials from local vault.
|
|
533
533
|
*/
|
|
534
|
-
export function disconnectOpenRouter(
|
|
534
|
+
export function disconnectOpenRouter(
|
|
535
|
+
store: { loadConfig(): any; saveConfig(cfg: any): void } = { loadConfig, saveConfig }
|
|
536
|
+
): Record<string, any> {
|
|
535
537
|
const currentConfig = store.loadConfig() || {};
|
|
536
538
|
const providerKeys = {
|
|
537
539
|
...(currentConfig.providerKeys && typeof currentConfig.providerKeys === 'object' ? currentConfig.providerKeys : {})
|
|
@@ -540,10 +542,28 @@ export function disconnectOpenRouter(store: { loadConfig(): any; saveConfig(cfg:
|
|
|
540
542
|
delete providerKeys['openrouter'];
|
|
541
543
|
currentConfig.providerKeys = providerKeys;
|
|
542
544
|
|
|
545
|
+
if (process.env.OPENROUTER_API_KEY) {
|
|
546
|
+
delete process.env.OPENROUTER_API_KEY;
|
|
547
|
+
}
|
|
548
|
+
|
|
543
549
|
if (currentConfig.provider === 'openrouter') {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
550
|
+
if (providerKeys['deepseek']) {
|
|
551
|
+
currentConfig.provider = 'deepseek';
|
|
552
|
+
currentConfig.model = 'deepseek-chat';
|
|
553
|
+
currentConfig.apiKey = providerKeys['deepseek'];
|
|
554
|
+
} else if (providerKeys['anthropic']) {
|
|
555
|
+
currentConfig.provider = 'anthropic';
|
|
556
|
+
currentConfig.model = 'claude-3-7-sonnet';
|
|
557
|
+
currentConfig.apiKey = providerKeys['anthropic'];
|
|
558
|
+
} else if (providerKeys['openai']) {
|
|
559
|
+
currentConfig.provider = 'openai';
|
|
560
|
+
currentConfig.model = 'gpt-4o';
|
|
561
|
+
currentConfig.apiKey = providerKeys['openai'];
|
|
562
|
+
} else {
|
|
563
|
+
currentConfig.provider = 'antigravity';
|
|
564
|
+
currentConfig.model = 'Gemini 3.8 Flash (Low)';
|
|
565
|
+
currentConfig.apiKey = '';
|
|
566
|
+
}
|
|
547
567
|
}
|
|
548
568
|
|
|
549
569
|
store.saveConfig(currentConfig);
|
package/src/commands.js
CHANGED
|
@@ -1633,8 +1633,31 @@ export const COMMANDS = [
|
|
|
1633
1633
|
}
|
|
1634
1634
|
|
|
1635
1635
|
if (sub === 'disconnect') {
|
|
1636
|
-
disconnectOpenRouter();
|
|
1637
|
-
|
|
1636
|
+
const updatedConfig = disconnectOpenRouter();
|
|
1637
|
+
if (ctx.loop) {
|
|
1638
|
+
ctx.loop.config = updatedConfig;
|
|
1639
|
+
if (typeof ctx.loop.updateTierLimits === 'function') {
|
|
1640
|
+
ctx.loop.updateTierLimits();
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
if (ctx.prompt) {
|
|
1644
|
+
if (typeof ctx.prompt.updateModel === 'function') {
|
|
1645
|
+
ctx.prompt.updateModel(
|
|
1646
|
+
updatedConfig.provider || 'antigravity',
|
|
1647
|
+
updatedConfig.model || 'Gemini 3.8 Flash (Low)'
|
|
1648
|
+
);
|
|
1649
|
+
} else if (ctx.prompt.renderer?.status) {
|
|
1650
|
+
ctx.prompt.renderer.status.setSession({
|
|
1651
|
+
provider: updatedConfig.provider || 'antigravity',
|
|
1652
|
+
model: updatedConfig.model || 'Gemini 3.8 Flash (Low)'
|
|
1653
|
+
});
|
|
1654
|
+
if (typeof ctx.prompt.scheduleDraw === 'function') ctx.prompt.scheduleDraw();
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
return ok(
|
|
1658
|
+
`OpenRouter account disconnected and API key removed from local vault.\n` +
|
|
1659
|
+
`Active model reverted to ${updatedConfig.provider || 'antigravity'} / ${updatedConfig.model || 'Gemini 3.8 Flash (Low)'}.`
|
|
1660
|
+
);
|
|
1638
1661
|
}
|
|
1639
1662
|
|
|
1640
1663
|
if (sub === 'privacy' || sub === 'data-collection') {
|
package/src/dynamicCatalogue.js
CHANGED
|
@@ -80,6 +80,8 @@ export function getCuratedModels(provider) {
|
|
|
80
80
|
const norm = normalizeProviderKey(provider);
|
|
81
81
|
if (norm === 'antigravity')
|
|
82
82
|
return Object.keys(BASELINE_ANTIGRAVITY_MODELS);
|
|
83
|
+
if (norm === 'openrouter')
|
|
84
|
+
return ['openrouter/free'];
|
|
83
85
|
if (norm === 'pi')
|
|
84
86
|
return [...(MODEL_CATALOGUE['Pi (Local Peer)'] || ['default'])];
|
|
85
87
|
const peer = peerIdFromProviderKey(norm);
|
|
@@ -1009,41 +1011,10 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
1009
1011
|
}
|
|
1010
1012
|
}
|
|
1011
1013
|
if (norm === 'openrouter') {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
};
|
|
1017
|
-
if (apiKey)
|
|
1018
|
-
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
1019
|
-
const res = await fetch(`${host}/models`, {
|
|
1020
|
-
headers,
|
|
1021
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1022
|
-
});
|
|
1023
|
-
if (!res.ok)
|
|
1024
|
-
return ['openrouter/free'];
|
|
1025
|
-
const data = (await res.json());
|
|
1026
|
-
if (Array.isArray(data.data)) {
|
|
1027
|
-
const freeModels = data.data
|
|
1028
|
-
.filter((m) => {
|
|
1029
|
-
if (!m.id)
|
|
1030
|
-
return false;
|
|
1031
|
-
if (m.id === 'openrouter/free')
|
|
1032
|
-
return true;
|
|
1033
|
-
if (m.id.endsWith(':free'))
|
|
1034
|
-
return true;
|
|
1035
|
-
const promptZero = m.pricing?.prompt === '0' || m.pricing?.prompt === 0;
|
|
1036
|
-
const complZero = m.pricing?.completion === '0' || m.pricing?.completion === 0;
|
|
1037
|
-
return promptZero && complZero;
|
|
1038
|
-
})
|
|
1039
|
-
.map((m) => m.id || '')
|
|
1040
|
-
.filter(Boolean)
|
|
1041
|
-
.sort();
|
|
1042
|
-
if (!freeModels.includes('openrouter/free')) {
|
|
1043
|
-
freeModels.unshift('openrouter/free');
|
|
1044
|
-
}
|
|
1045
|
-
return freeModels;
|
|
1046
|
-
}
|
|
1014
|
+
// OpenRouter automatically routes free inference server-side via openrouter/free.
|
|
1015
|
+
// Auto-detection of transient individual :free endpoints is disabled specifically
|
|
1016
|
+
// for OpenRouter to prevent routing failures and privacy mismatches, while
|
|
1017
|
+
// keeping ACP and local peer dynamic auto-detection fully active.
|
|
1047
1018
|
return ['openrouter/free'];
|
|
1048
1019
|
}
|
|
1049
1020
|
if (norm === 'openai-compatible') {
|
|
@@ -1106,6 +1077,9 @@ function resolveEffectiveApiKey(norm, config = {}) {
|
|
|
1106
1077
|
*/
|
|
1107
1078
|
export async function resolveAvailableModels(provider, config = {}, forceRefresh = false) {
|
|
1108
1079
|
const norm = normalizeProviderKey(provider);
|
|
1080
|
+
if (norm === 'openrouter') {
|
|
1081
|
+
return { models: ['openrouter/free'], source: 'catalogue' };
|
|
1082
|
+
}
|
|
1109
1083
|
const curated = getCuratedModels(norm);
|
|
1110
1084
|
const localAgent = isLocalOrAcpProvider(norm);
|
|
1111
1085
|
const effectiveKey = resolveEffectiveApiKey(norm, config);
|
package/src/dynamicCatalogue.ts
CHANGED
|
@@ -101,6 +101,7 @@ export function peerIdFromProviderKey(provider: string): string | null {
|
|
|
101
101
|
export function getCuratedModels(provider: string): string[] {
|
|
102
102
|
const norm = normalizeProviderKey(provider);
|
|
103
103
|
if (norm === 'antigravity') return Object.keys(BASELINE_ANTIGRAVITY_MODELS);
|
|
104
|
+
if (norm === 'openrouter') return ['openrouter/free'];
|
|
104
105
|
if (norm === 'pi') return [...(MODEL_CATALOGUE['Pi (Local Peer)'] || ['default'])];
|
|
105
106
|
const peer = peerIdFromProviderKey(norm);
|
|
106
107
|
if (peer) return [...(PEER_MODEL_CATALOGUE[peer] ?? [])];
|
|
@@ -1075,41 +1076,10 @@ export async function fetchLiveModels(
|
|
|
1075
1076
|
}
|
|
1076
1077
|
|
|
1077
1078
|
if (norm === 'openrouter') {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
};
|
|
1083
|
-
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
|
|
1084
|
-
const res = await fetch(`${host}/models`, {
|
|
1085
|
-
headers,
|
|
1086
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1087
|
-
});
|
|
1088
|
-
if (!res.ok) return ['openrouter/free'];
|
|
1089
|
-
const data = (await res.json()) as {
|
|
1090
|
-
data?: Array<{
|
|
1091
|
-
id?: string;
|
|
1092
|
-
pricing?: { prompt?: string | number; completion?: string | number };
|
|
1093
|
-
}>;
|
|
1094
|
-
};
|
|
1095
|
-
if (Array.isArray(data.data)) {
|
|
1096
|
-
const freeModels = data.data
|
|
1097
|
-
.filter((m) => {
|
|
1098
|
-
if (!m.id) return false;
|
|
1099
|
-
if (m.id === 'openrouter/free') return true;
|
|
1100
|
-
if (m.id.endsWith(':free')) return true;
|
|
1101
|
-
const promptZero = m.pricing?.prompt === '0' || m.pricing?.prompt === 0;
|
|
1102
|
-
const complZero = m.pricing?.completion === '0' || m.pricing?.completion === 0;
|
|
1103
|
-
return promptZero && complZero;
|
|
1104
|
-
})
|
|
1105
|
-
.map((m) => m.id || '')
|
|
1106
|
-
.filter(Boolean)
|
|
1107
|
-
.sort();
|
|
1108
|
-
if (!freeModels.includes('openrouter/free')) {
|
|
1109
|
-
freeModels.unshift('openrouter/free');
|
|
1110
|
-
}
|
|
1111
|
-
return freeModels;
|
|
1112
|
-
}
|
|
1079
|
+
// OpenRouter automatically routes free inference server-side via openrouter/free.
|
|
1080
|
+
// Auto-detection of transient individual :free endpoints is disabled specifically
|
|
1081
|
+
// for OpenRouter to prevent routing failures and privacy mismatches, while
|
|
1082
|
+
// keeping ACP and local peer dynamic auto-detection fully active.
|
|
1113
1083
|
return ['openrouter/free'];
|
|
1114
1084
|
}
|
|
1115
1085
|
|
|
@@ -1179,6 +1149,9 @@ export async function resolveAvailableModels(
|
|
|
1179
1149
|
forceRefresh = false
|
|
1180
1150
|
): Promise<ModelResolutionResult> {
|
|
1181
1151
|
const norm = normalizeProviderKey(provider);
|
|
1152
|
+
if (norm === 'openrouter') {
|
|
1153
|
+
return { models: ['openrouter/free'], source: 'catalogue' };
|
|
1154
|
+
}
|
|
1182
1155
|
const curated = getCuratedModels(norm);
|
|
1183
1156
|
const localAgent = isLocalOrAcpProvider(norm);
|
|
1184
1157
|
const effectiveKey = resolveEffectiveApiKey(norm, config);
|
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 { startLoopbackAuth, saveOpenRouterKey } from '../auth/openrouterAuth.js';
|
|
12
|
+
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
13
13
|
import { getAvailableProvidersOverview, resolveAvailableProvidersOverview, resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
14
14
|
async function showConfiguringAnimation(providerLabel) {
|
|
15
15
|
if (!process.stdout.isTTY)
|
|
@@ -172,36 +172,50 @@ export function buildModelPickerItems(config, overview, options = {}) {
|
|
|
172
172
|
}
|
|
173
173
|
// 3. Free Cloud Models (OpenRouter Free)
|
|
174
174
|
if (tab === 'all' || tab === 'free') {
|
|
175
|
-
const openrouterPeer = overview.byok.find(p => p.id === 'openrouter');
|
|
176
175
|
const isConfigured = Boolean((config.provider === 'openrouter' && config.apiKey) ||
|
|
177
176
|
config.providerKeys?.openrouter ||
|
|
178
177
|
process.env.OPENROUTER_API_KEY);
|
|
179
178
|
const isCurrentProvider = activeProvider === 'openrouter';
|
|
180
|
-
const models = openrouterPeer?.models && openrouterPeer.models.length > 0
|
|
181
|
-
? openrouterPeer.models
|
|
182
|
-
: ['openrouter/free'];
|
|
183
179
|
const catTitle = isConfigured
|
|
184
180
|
? 'Free Cloud · OpenRouter (ready)'
|
|
185
181
|
: 'Free Cloud · OpenRouter (connect account)';
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
const isCurrent = isCurrentProvider && (activeModel === 'openrouter/free' || !activeModel);
|
|
183
|
+
const desc = isCurrent
|
|
184
|
+
? '● active (free)'
|
|
185
|
+
: (isConfigured ? 'free inference' : 'connect OpenRouter · free');
|
|
186
|
+
// Canonical auto-routing free model (OpenRouter automatically routes free inference)
|
|
187
|
+
items.push({
|
|
188
|
+
id: 'openrouter/openrouter/free',
|
|
189
|
+
label: 'openrouter/free',
|
|
190
|
+
category: catTitle,
|
|
191
|
+
description: desc,
|
|
192
|
+
value: {
|
|
193
|
+
type: 'free',
|
|
194
|
+
providerId: 'openrouter',
|
|
195
|
+
modelId: 'openrouter/free',
|
|
196
|
+
providerLabel: 'OpenRouter Free',
|
|
197
|
+
installed: true,
|
|
198
|
+
isCurrent,
|
|
199
|
+
isConfigured,
|
|
200
|
+
envVar: 'OPENROUTER_API_KEY'
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
// Provide first-class in-place Disconnect / Unlink action when configured
|
|
204
|
+
if (isConfigured) {
|
|
191
205
|
items.push({
|
|
192
|
-
id:
|
|
193
|
-
label:
|
|
206
|
+
id: 'openrouter:disconnect',
|
|
207
|
+
label: 'Disconnect OpenRouter (unlink account)',
|
|
194
208
|
category: catTitle,
|
|
195
|
-
description:
|
|
209
|
+
description: 'unlink & remove key',
|
|
196
210
|
value: {
|
|
197
|
-
type: '
|
|
211
|
+
type: 'action',
|
|
198
212
|
providerId: 'openrouter',
|
|
199
|
-
modelId:
|
|
213
|
+
modelId: 'disconnect',
|
|
200
214
|
providerLabel: 'OpenRouter Free',
|
|
201
215
|
installed: true,
|
|
202
|
-
isCurrent,
|
|
203
|
-
isConfigured,
|
|
204
|
-
|
|
216
|
+
isCurrent: false,
|
|
217
|
+
isConfigured: true,
|
|
218
|
+
action: 'disconnect'
|
|
205
219
|
}
|
|
206
220
|
});
|
|
207
221
|
}
|
|
@@ -457,7 +471,20 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
457
471
|
notifyPrompt(target.providerId, target.modelId);
|
|
458
472
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
459
473
|
}
|
|
460
|
-
// Case 2:
|
|
474
|
+
// Case 2: Disconnect / Unlink action (e.g. Disconnect OpenRouter)
|
|
475
|
+
if (target.action === 'disconnect' || target.modelId === 'disconnect') {
|
|
476
|
+
const updatedConfig = disconnectOpenRouter(store);
|
|
477
|
+
if (options.loop) {
|
|
478
|
+
options.loop.config = updatedConfig;
|
|
479
|
+
if (typeof options.loop.updateTierLimits === 'function') {
|
|
480
|
+
options.loop.updateTierLimits();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)');
|
|
484
|
+
return (`✓ Disconnected OpenRouter. Account and API credentials have been unlinked from Causyne Agent.\n` +
|
|
485
|
+
`Active model reverted to ${updatedConfig.provider || 'antigravity'} / ${updatedConfig.model || 'Gemini 3.8 Flash (Low)'}.`);
|
|
486
|
+
}
|
|
487
|
+
// Case 3: OpenRouter Free Models with instant 1-Enter OAuth PKCE flow
|
|
461
488
|
if (target.providerId === 'openrouter') {
|
|
462
489
|
let existingKey = '';
|
|
463
490
|
const providerKeys = config['providerKeys'] && typeof config['providerKeys'] === 'object' ? config['providerKeys'] : {};
|
package/src/tui/modelPicker.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
|
10
10
|
// @ts-expect-error untyped local TUI selectList
|
|
11
11
|
import { fuzzyFilter } from './selectList.js';
|
|
12
12
|
import { loadConfig, saveConfig } from '../config.js';
|
|
13
|
-
import { startLoopbackAuth, saveOpenRouterKey } from '../auth/openrouterAuth.js';
|
|
13
|
+
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
14
14
|
import {
|
|
15
15
|
getAvailableProvidersOverview,
|
|
16
16
|
resolveAvailableProvidersOverview,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from '../dynamicCatalogue.js';
|
|
20
20
|
|
|
21
21
|
export interface ModelPickerItemValue {
|
|
22
|
-
type: 'acp' | 'byok' | 'free' | 'toggle';
|
|
22
|
+
type: 'acp' | 'byok' | 'free' | 'action' | 'toggle';
|
|
23
23
|
providerId: string;
|
|
24
24
|
modelId: string;
|
|
25
25
|
providerLabel: string;
|
|
@@ -29,7 +29,7 @@ export interface ModelPickerItemValue {
|
|
|
29
29
|
envVar?: string | undefined;
|
|
30
30
|
setupInstruction?: string | undefined;
|
|
31
31
|
isToggle?: boolean | undefined;
|
|
32
|
-
action?: 'expand' | 'collapse' | undefined;
|
|
32
|
+
action?: 'expand' | 'collapse' | 'disconnect' | undefined;
|
|
33
33
|
peerKey?: string | undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -236,40 +236,56 @@ export function buildModelPickerItems(
|
|
|
236
236
|
|
|
237
237
|
// 3. Free Cloud Models (OpenRouter Free)
|
|
238
238
|
if (tab === 'all' || tab === 'free') {
|
|
239
|
-
const openrouterPeer = overview.byok.find(p => p.id === 'openrouter');
|
|
240
239
|
const isConfigured = Boolean(
|
|
241
240
|
(config.provider === 'openrouter' && config.apiKey) ||
|
|
242
241
|
config.providerKeys?.openrouter ||
|
|
243
242
|
process.env.OPENROUTER_API_KEY
|
|
244
243
|
);
|
|
245
244
|
const isCurrentProvider = activeProvider === 'openrouter';
|
|
246
|
-
const models = openrouterPeer?.models && openrouterPeer.models.length > 0
|
|
247
|
-
? openrouterPeer.models
|
|
248
|
-
: ['openrouter/free'];
|
|
249
245
|
|
|
250
246
|
const catTitle = isConfigured
|
|
251
247
|
? 'Free Cloud · OpenRouter (ready)'
|
|
252
248
|
: 'Free Cloud · OpenRouter (connect account)';
|
|
253
249
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
250
|
+
const isCurrent = isCurrentProvider && (activeModel === 'openrouter/free' || !activeModel);
|
|
251
|
+
const desc = isCurrent
|
|
252
|
+
? '● active (free)'
|
|
253
|
+
: (isConfigured ? 'free inference' : 'connect OpenRouter · free');
|
|
254
|
+
|
|
255
|
+
// Canonical auto-routing free model (OpenRouter automatically routes free inference)
|
|
256
|
+
items.push({
|
|
257
|
+
id: 'openrouter/openrouter/free',
|
|
258
|
+
label: 'openrouter/free',
|
|
259
|
+
category: catTitle,
|
|
260
|
+
description: desc,
|
|
261
|
+
value: {
|
|
262
|
+
type: 'free',
|
|
263
|
+
providerId: 'openrouter',
|
|
264
|
+
modelId: 'openrouter/free',
|
|
265
|
+
providerLabel: 'OpenRouter Free',
|
|
266
|
+
installed: true,
|
|
267
|
+
isCurrent,
|
|
268
|
+
isConfigured,
|
|
269
|
+
envVar: 'OPENROUTER_API_KEY'
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Provide first-class in-place Disconnect / Unlink action when configured
|
|
274
|
+
if (isConfigured) {
|
|
259
275
|
items.push({
|
|
260
|
-
id:
|
|
261
|
-
label:
|
|
276
|
+
id: 'openrouter:disconnect',
|
|
277
|
+
label: 'Disconnect OpenRouter (unlink account)',
|
|
262
278
|
category: catTitle,
|
|
263
|
-
description:
|
|
279
|
+
description: 'unlink & remove key',
|
|
264
280
|
value: {
|
|
265
|
-
type: '
|
|
281
|
+
type: 'action',
|
|
266
282
|
providerId: 'openrouter',
|
|
267
|
-
modelId:
|
|
283
|
+
modelId: 'disconnect',
|
|
268
284
|
providerLabel: 'OpenRouter Free',
|
|
269
285
|
installed: true,
|
|
270
|
-
isCurrent,
|
|
271
|
-
isConfigured,
|
|
272
|
-
|
|
286
|
+
isCurrent: false,
|
|
287
|
+
isConfigured: true,
|
|
288
|
+
action: 'disconnect'
|
|
273
289
|
}
|
|
274
290
|
});
|
|
275
291
|
}
|
|
@@ -558,7 +574,23 @@ export async function runInteractiveModelPicker(
|
|
|
558
574
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
559
575
|
}
|
|
560
576
|
|
|
561
|
-
// Case 2:
|
|
577
|
+
// Case 2: Disconnect / Unlink action (e.g. Disconnect OpenRouter)
|
|
578
|
+
if (target.action === 'disconnect' || target.modelId === 'disconnect') {
|
|
579
|
+
const updatedConfig = disconnectOpenRouter(store);
|
|
580
|
+
if (options.loop) {
|
|
581
|
+
options.loop.config = updatedConfig;
|
|
582
|
+
if (typeof options.loop.updateTierLimits === 'function') {
|
|
583
|
+
options.loop.updateTierLimits();
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)');
|
|
587
|
+
return (
|
|
588
|
+
`✓ Disconnected OpenRouter. Account and API credentials have been unlinked from Causyne Agent.\n` +
|
|
589
|
+
`Active model reverted to ${updatedConfig.provider || 'antigravity'} / ${updatedConfig.model || 'Gemini 3.8 Flash (Low)'}.`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Case 3: OpenRouter Free Models with instant 1-Enter OAuth PKCE flow
|
|
562
594
|
if (target.providerId === 'openrouter') {
|
|
563
595
|
let existingKey = '';
|
|
564
596
|
const providerKeys: Record<string, string> =
|